forked from LiveCarta/PayPal-PHP-SDK
Update Webhooks API
This commit is contained in:
56
tests/PayPal/Test/Api/VerifyWebhookSignatureResponseTest.php
Normal file
56
tests/PayPal/Test/Api/VerifyWebhookSignatureResponseTest.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\VerifyWebhookSignatureResponse;
|
||||
|
||||
/**
|
||||
* Class VerifyWebhookSignatureResponse
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class VerifyWebhookSignatureResponseTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object VerifyWebhookSignatureResponse
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"verification_status":"TestSample"}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return VerifyWebhookSignatureResponse
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new VerifyWebhookSignatureResponse(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return VerifyWebhookSignatureResponse
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new VerifyWebhookSignatureResponse(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getVerificationStatus());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param VerifyWebhookSignatureResponse $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getVerificationStatus(), "TestSample");
|
||||
}
|
||||
|
||||
}
|
||||
111
tests/PayPal/Test/Api/VerifyWebhookSignatureTest.php
Normal file
111
tests/PayPal/Test/Api/VerifyWebhookSignatureTest.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\VerifyWebhookSignatureResponse;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Api\VerifyWebhookSignature;
|
||||
|
||||
/**
|
||||
* Class VerifyWebhookSignature
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class VerifyWebhookSignatureTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object VerifyWebhookSignature
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"auth_algo":"TestSample","cert_url":"http://www.google.com","transmission_id":"TestSample","transmission_sig":"TestSample","transmission_time":"TestSample","webhook_id":"TestSample","webhook_event":' .WebhookEventTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return VerifyWebhookSignature
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new VerifyWebhookSignature(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return VerifyWebhookSignature
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new VerifyWebhookSignature(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getAuthAlgo());
|
||||
$this->assertNotNull($obj->getCertUrl());
|
||||
$this->assertNotNull($obj->getTransmissionId());
|
||||
$this->assertNotNull($obj->getTransmissionSig());
|
||||
$this->assertNotNull($obj->getTransmissionTime());
|
||||
$this->assertNotNull($obj->getWebhookId());
|
||||
$this->assertNotNull($obj->getWebhookEvent());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param VerifyWebhookSignature $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getAuthAlgo(), "TestSample");
|
||||
$this->assertEquals($obj->getCertUrl(), "http://www.google.com");
|
||||
$this->assertEquals($obj->getTransmissionId(), "TestSample");
|
||||
$this->assertEquals($obj->getTransmissionSig(), "TestSample");
|
||||
$this->assertEquals($obj->getTransmissionTime(), "TestSample");
|
||||
$this->assertEquals($obj->getWebhookId(), "TestSample");
|
||||
$this->assertEquals($obj->getWebhookEvent(), WebhookEventTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage CertUrl is not a fully qualified URL
|
||||
*/
|
||||
public function testUrlValidationForCertUrl()
|
||||
{
|
||||
$obj = new VerifyWebhookSignature();
|
||||
$obj->setCertUrl(null);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param VerifyWebhookSignature $obj
|
||||
*/
|
||||
public function testPost($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
VerifyWebhookSignatureResponseTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->post($mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
public function mockProvider()
|
||||
{
|
||||
$obj = self::getObject();
|
||||
$mockApiContext = $this->getMockBuilder('ApiContext')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
return array(
|
||||
array($obj, $mockApiContext),
|
||||
array($obj, null)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\WebhookEventList;
|
||||
|
||||
/**
|
||||
@@ -55,4 +56,6 @@ class WebhookEventListTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($obj->getCount(), 123);
|
||||
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\WebhookEvent;
|
||||
use PayPal\Exception\PayPalConnectionException;
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\WebhookEventList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Api\WebhookEvent;
|
||||
|
||||
/**
|
||||
* Class WebhookEvent
|
||||
@@ -19,7 +21,7 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"id":"TestSample","create_time":"TestSample","resource_type":"TestSample","event_type":"TestSample","summary":"TestSample","resource":"TestSampleObject","links":' .LinksTest::getJson() . '}';
|
||||
return '{"id":"TestSample","create_time":"TestSample","resource_type":"TestSample","event_version":"TestSample","event_type":"TestSample","summary":"TestSample","resource":"TestSampleObject","status":"TestSample","transmissions":"TestSampleObject","links":' .LinksTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,9 +45,12 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNotNull($obj->getId());
|
||||
$this->assertNotNull($obj->getCreateTime());
|
||||
$this->assertNotNull($obj->getResourceType());
|
||||
$this->assertNotNull($obj->getEventVersion());
|
||||
$this->assertNotNull($obj->getEventType());
|
||||
$this->assertNotNull($obj->getSummary());
|
||||
$this->assertNotNull($obj->getResource());
|
||||
$this->assertNotNull($obj->getStatus());
|
||||
$this->assertNotNull($obj->getTransmissions());
|
||||
$this->assertNotNull($obj->getLinks());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
@@ -60,9 +65,12 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($obj->getId(), "TestSample");
|
||||
$this->assertEquals($obj->getCreateTime(), "TestSample");
|
||||
$this->assertEquals($obj->getResourceType(), "TestSample");
|
||||
$this->assertEquals($obj->getEventVersion(), "TestSample");
|
||||
$this->assertEquals($obj->getEventType(), "TestSample");
|
||||
$this->assertEquals($obj->getSummary(), "TestSample");
|
||||
$this->assertEquals($obj->getResource(), "TestSampleObject");
|
||||
$this->assertEquals($obj->getStatus(), "TestSample");
|
||||
$this->assertEquals($obj->getTransmissions(), "TestSampleObject");
|
||||
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
|
||||
}
|
||||
|
||||
@@ -72,17 +80,17 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGet($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->get("eventId", $mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->get("eventId", $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
@@ -91,17 +99,18 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testResend($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
self::getJson()
|
||||
));
|
||||
$eventResend = EventResendTest::getObject();
|
||||
|
||||
$result = $obj->resend($mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->resend($eventResend, $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
@@ -110,60 +119,18 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testList($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventListTest::getJson()
|
||||
));
|
||||
$params = array();
|
||||
|
||||
$result = $obj->all($params, $mockApiContext, $mockPayPalRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param WebhookEvent $obj
|
||||
*/
|
||||
public function testValidateWebhook($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventTest::getJson()
|
||||
));
|
||||
|
||||
$result = WebhookEvent::validateAndGetReceivedEvent('{"id":"123"}', $mockApiContext, $mockPayPalRestCall);
|
||||
//$result = $obj->get("eventId", $mockApiContext, $mockPayPalRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param WebhookEvent $obj
|
||||
* @param ApiContext $mockApiContext
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Webhook Event Id provided in the data is incorrect. This could happen if anyone other than PayPal is faking the incoming webhook data.
|
||||
*/
|
||||
public function testValidateWebhook404($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->throwException(new PayPalConnectionException(null, "404 not found", 404)));
|
||||
|
||||
$result = WebhookEvent::validateAndGetReceivedEvent('{"id":"123"}', $mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->all($params, $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
@@ -178,45 +145,4 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
array($obj, null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Body cannot be null or empty
|
||||
*/
|
||||
public function testValidateWebhookNull($mockApiContext)
|
||||
{
|
||||
WebhookEvent::validateAndGetReceivedEvent(null, $mockApiContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Body cannot be null or empty
|
||||
*/
|
||||
public function testValidateWebhookEmpty($mockApiContext)
|
||||
{
|
||||
WebhookEvent::validateAndGetReceivedEvent('', $mockApiContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Request Body is not a valid JSON.
|
||||
*/
|
||||
public function testValidateWebhookInvalid($mockApiContext)
|
||||
{
|
||||
WebhookEvent::validateAndGetReceivedEvent('something-invalid', $mockApiContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param $mockApiContext ApiContext
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Id attribute not found in JSON. Possible reason could be invalid JSON Object
|
||||
*/
|
||||
public function testValidateWebhookValidJSONWithoutId($obj, $mockApiContext)
|
||||
{
|
||||
WebhookEvent::validateAndGetReceivedEvent('{"summary":"json"}', $mockApiContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\WebhookEventTypeList;
|
||||
|
||||
/**
|
||||
@@ -51,4 +52,6 @@ class WebhookEventTypeListTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->assertEquals($obj->getEventTypes(), WebhookEventTypeTest::getObject());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\WebhookEventTypeList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Api\WebhookEventType;
|
||||
|
||||
/**
|
||||
@@ -17,7 +21,7 @@ class WebhookEventTypeTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"name":"TestSample","description":"TestSample"}';
|
||||
return '{"name":"TestSample","description":"TestSample","status":"TestSample"}';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,6 +44,7 @@ class WebhookEventTypeTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getName());
|
||||
$this->assertNotNull($obj->getDescription());
|
||||
$this->assertNotNull($obj->getStatus());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
@@ -52,6 +57,7 @@ class WebhookEventTypeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->assertEquals($obj->getName(), "TestSample");
|
||||
$this->assertEquals($obj->getDescription(), "TestSample");
|
||||
$this->assertEquals($obj->getStatus(), "TestSample");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,17 +66,17 @@ class WebhookEventTypeTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSubscribedEventTypes($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventTypeListTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->subscribedEventTypes("webhookId", $mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->subscribedEventTypes("webhookId", $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
@@ -79,17 +85,17 @@ class WebhookEventTypeTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testAvailableEventTypes($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventTypeListTest::getJson()
|
||||
WebhookEventTypeListTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->availableEventTypes($mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->availableEventTypes($mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalModel;
|
||||
use PayPal\Api\WebhookList;
|
||||
|
||||
/**
|
||||
@@ -51,4 +52,6 @@ class WebhookListTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->assertEquals($obj->getWebhooks(), WebhookTest::getObject());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PayPalResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\WebhookList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Api\Webhook;
|
||||
|
||||
/**
|
||||
@@ -67,24 +71,23 @@ class WebhookTest extends \PHPUnit_Framework_TestCase
|
||||
$obj = new Webhook();
|
||||
$obj->setUrl(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testCreate($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
self::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->create($mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->create($mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
@@ -93,17 +96,17 @@ class WebhookTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGet($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->get("webhookId", $mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->get("webhookId", $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
@@ -112,17 +115,18 @@ class WebhookTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetAll($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookListTest::getJson()
|
||||
));
|
||||
$params = array();
|
||||
|
||||
$result = $obj->getAll($mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->getAllWithParams($params, $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
@@ -131,18 +135,18 @@ class WebhookTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testUpdate($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
self::getJson()
|
||||
));
|
||||
$patchRequest = PatchRequestTest::getObject();
|
||||
|
||||
$result = $obj->update($patchRequest, $mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
@@ -151,17 +155,17 @@ class WebhookTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDelete($obj, $mockApiContext)
|
||||
{
|
||||
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPayPalRestCall->expects($this->any())
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
true
|
||||
));
|
||||
|
||||
$result = $obj->delete($mockApiContext, $mockPayPalRestCall);
|
||||
$result = $obj->delete($mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user