forked from LiveCarta/PayPal-PHP-SDK
Auto-generated code for Webhooks API
This commit is contained in:
82
tests/PayPal/Test/Api/WebhookEventListTest.php
Normal file
82
tests/PayPal/Test/Api/WebhookEventListTest.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PPModel;
|
||||
use PayPal\Api\WebhookEventList;
|
||||
|
||||
/**
|
||||
* Class WebhookEventList
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class WebhookEventListTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object WebhookEventList
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"events":' .WebhookEventTest::getJson() . ',"count":123,"links":' .LinksTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return WebhookEventList
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new WebhookEventList(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return WebhookEventList
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new WebhookEventList(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getEvents());
|
||||
$this->assertNotNull($obj->getCount());
|
||||
$this->assertNotNull($obj->getLinks());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventList $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getEvents(), WebhookEventTest::getObject());
|
||||
$this->assertEquals($obj->getCount(), 123);
|
||||
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventList $obj
|
||||
*/
|
||||
public function testDeprecatedGetters($obj)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventList $obj
|
||||
*/
|
||||
public function testDeprecatedSetterNormalGetter($obj)
|
||||
{
|
||||
|
||||
//Test All Deprecated Getters and Normal Getters
|
||||
$this->testDeprecatedGetters($obj);
|
||||
$this->testGetters($obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
190
tests/PayPal/Test/Api/WebhookEventTest.php
Normal file
190
tests/PayPal/Test/Api/WebhookEventTest.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\ResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\WebhookEventList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PPRestCall;
|
||||
use PayPal\Api\WebhookEvent;
|
||||
|
||||
/**
|
||||
* Class WebhookEvent
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class WebhookEventTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object WebhookEvent
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"id":"TestSample","create_time":"TestSample","resource_type":"TestSample","event_type":"TestSample","summary":"TestSample","resource":"TestSampleObject","links":' .LinksTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return WebhookEvent
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new WebhookEvent(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return WebhookEvent
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new WebhookEvent(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getId());
|
||||
$this->assertNotNull($obj->getCreateTime());
|
||||
$this->assertNotNull($obj->getResourceType());
|
||||
$this->assertNotNull($obj->getEventType());
|
||||
$this->assertNotNull($obj->getSummary());
|
||||
$this->assertNotNull($obj->getResource());
|
||||
$this->assertNotNull($obj->getLinks());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEvent $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getId(), "TestSample");
|
||||
$this->assertEquals($obj->getCreateTime(), "TestSample");
|
||||
$this->assertEquals($obj->getResourceType(), "TestSample");
|
||||
$this->assertEquals($obj->getEventType(), "TestSample");
|
||||
$this->assertEquals($obj->getSummary(), "TestSample");
|
||||
$this->assertEquals($obj->getResource(), "TestSampleObject");
|
||||
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEvent $obj
|
||||
*/
|
||||
public function testDeprecatedGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getCreate_time(), "TestSample");
|
||||
$this->assertEquals($obj->getResource_type(), "TestSample");
|
||||
$this->assertEquals($obj->getEvent_type(), "TestSample");
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEvent $obj
|
||||
*/
|
||||
public function testDeprecatedSetterNormalGetter($obj)
|
||||
{
|
||||
|
||||
// Check for Create_time
|
||||
$obj->setCreateTime(null);
|
||||
$this->assertNull($obj->getCreate_time());
|
||||
$this->assertNull($obj->getCreateTime());
|
||||
$this->assertSame($obj->getCreateTime(), $obj->getCreate_time());
|
||||
$obj->setCreate_time("TestSample");
|
||||
$this->assertEquals($obj->getCreate_time(), "TestSample");
|
||||
|
||||
// Check for Resource_type
|
||||
$obj->setResourceType(null);
|
||||
$this->assertNull($obj->getResource_type());
|
||||
$this->assertNull($obj->getResourceType());
|
||||
$this->assertSame($obj->getResourceType(), $obj->getResource_type());
|
||||
$obj->setResource_type("TestSample");
|
||||
$this->assertEquals($obj->getResource_type(), "TestSample");
|
||||
|
||||
// Check for Event_type
|
||||
$obj->setEventType(null);
|
||||
$this->assertNull($obj->getEvent_type());
|
||||
$this->assertNull($obj->getEventType());
|
||||
$this->assertSame($obj->getEventType(), $obj->getEvent_type());
|
||||
$obj->setEvent_type("TestSample");
|
||||
$this->assertEquals($obj->getEvent_type(), "TestSample");
|
||||
|
||||
//Test All Deprecated Getters and Normal Getters
|
||||
$this->testDeprecatedGetters($obj);
|
||||
$this->testGetters($obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param WebhookEvent $obj
|
||||
*/
|
||||
public function testGet($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->get("eventId", $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param WebhookEvent $obj
|
||||
*/
|
||||
public function testResend($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
self::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->resend($mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param WebhookEvent $obj
|
||||
*/
|
||||
public function testList($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventListTest::getJson()
|
||||
));
|
||||
$params = array();
|
||||
|
||||
$result = $obj->all($params, $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)
|
||||
);
|
||||
}
|
||||
}
|
||||
87
tests/PayPal/Test/Api/WebhookEventTypeListTest.php
Normal file
87
tests/PayPal/Test/Api/WebhookEventTypeListTest.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PPModel;
|
||||
use PayPal\Api\WebhookEventTypeList;
|
||||
|
||||
/**
|
||||
* Class WebhookEventTypeList
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class WebhookEventTypeListTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object WebhookEventTypeList
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"event_types":' .WebhookEventTypeTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return WebhookEventTypeList
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new WebhookEventTypeList(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return WebhookEventTypeList
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new WebhookEventTypeList(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getEventTypes());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventTypeList $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getEventTypes(), WebhookEventTypeTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventTypeList $obj
|
||||
*/
|
||||
public function testDeprecatedGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getEvent_types(), WebhookEventTypeTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventTypeList $obj
|
||||
*/
|
||||
public function testDeprecatedSetterNormalGetter($obj)
|
||||
{
|
||||
|
||||
// Check for Event_types
|
||||
$obj->setEventTypes(null);
|
||||
$this->assertNull($obj->getEvent_types());
|
||||
$this->assertNull($obj->getEventTypes());
|
||||
$this->assertSame($obj->getEventTypes(), $obj->getEvent_types());
|
||||
$obj->setEvent_types(WebhookEventTypeTest::getObject());
|
||||
$this->assertEquals($obj->getEvent_types(), WebhookEventTypeTest::getObject());
|
||||
|
||||
//Test All Deprecated Getters and Normal Getters
|
||||
$this->testDeprecatedGetters($obj);
|
||||
$this->testGetters($obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
133
tests/PayPal/Test/Api/WebhookEventTypeTest.php
Normal file
133
tests/PayPal/Test/Api/WebhookEventTypeTest.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\ResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\WebhookEventList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PPRestCall;
|
||||
use PayPal\Api\WebhookEventType;
|
||||
|
||||
/**
|
||||
* Class WebhookEventType
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class WebhookEventTypeTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object WebhookEventType
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"name":"TestSample","description":"TestSample"}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return WebhookEventType
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new WebhookEventType(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return WebhookEventType
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new WebhookEventType(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getName());
|
||||
$this->assertNotNull($obj->getDescription());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventType $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getName(), "TestSample");
|
||||
$this->assertEquals($obj->getDescription(), "TestSample");
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventType $obj
|
||||
*/
|
||||
public function testDeprecatedGetters($obj)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookEventType $obj
|
||||
*/
|
||||
public function testDeprecatedSetterNormalGetter($obj)
|
||||
{
|
||||
|
||||
//Test All Deprecated Getters and Normal Getters
|
||||
$this->testDeprecatedGetters($obj);
|
||||
$this->testGetters($obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param WebhookEventType $obj
|
||||
*/
|
||||
public function testSubscribedEventTypes($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventListTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->subscribedEventTypes("webhookId", $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param WebhookEventType $obj
|
||||
*/
|
||||
public function testAvailableEventTypes($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookEventListTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->availableEventTypes($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)
|
||||
);
|
||||
}
|
||||
}
|
||||
78
tests/PayPal/Test/Api/WebhookListTest.php
Normal file
78
tests/PayPal/Test/Api/WebhookListTest.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\PPModel;
|
||||
use PayPal\Api\WebhookList;
|
||||
|
||||
/**
|
||||
* Class WebhookList
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class WebhookListTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object WebhookList
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"webhooks":' .WebhookTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return WebhookList
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new WebhookList(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return WebhookList
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new WebhookList(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getWebhooks());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookList $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getWebhooks(), WebhookTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookList $obj
|
||||
*/
|
||||
public function testDeprecatedGetters($obj)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param WebhookList $obj
|
||||
*/
|
||||
public function testDeprecatedSetterNormalGetter($obj)
|
||||
{
|
||||
|
||||
//Test All Deprecated Getters and Normal Getters
|
||||
$this->testDeprecatedGetters($obj);
|
||||
$this->testGetters($obj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
213
tests/PayPal/Test/Api/WebhookTest.php
Normal file
213
tests/PayPal/Test/Api/WebhookTest.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Common\ResourceModel;
|
||||
use PayPal\Validation\ArgumentValidator;
|
||||
use PayPal\Api\WebhookList;
|
||||
use PayPal\Rest\ApiContext;
|
||||
use PayPal\Transport\PPRestCall;
|
||||
use PayPal\Api\Webhook;
|
||||
|
||||
/**
|
||||
* Class Webhook
|
||||
*
|
||||
* @package PayPal\Test\Api
|
||||
*/
|
||||
class WebhookTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Gets Json String of Object Webhook
|
||||
* @return string
|
||||
*/
|
||||
public static function getJson()
|
||||
{
|
||||
return '{"id":"TestSample","url":"http://www.google.com","event_types":' .WebhookEventTypeTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Object Instance with Json data filled in
|
||||
* @return Webhook
|
||||
*/
|
||||
public static function getObject()
|
||||
{
|
||||
return new Webhook(self::getJson());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests for Serialization and Deserialization Issues
|
||||
* @return Webhook
|
||||
*/
|
||||
public function testSerializationDeserialization()
|
||||
{
|
||||
$obj = new Webhook(self::getJson());
|
||||
$this->assertNotNull($obj);
|
||||
$this->assertNotNull($obj->getId());
|
||||
$this->assertNotNull($obj->getUrl());
|
||||
$this->assertNotNull($obj->getEventTypes());
|
||||
$this->assertNotNull($obj->getLinks());
|
||||
$this->assertEquals(self::getJson(), $obj->toJson());
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getId(), "TestSample");
|
||||
$this->assertEquals($obj->getUrl(), "http://www.google.com");
|
||||
$this->assertEquals($obj->getEventTypes(), WebhookEventTypeTest::getObject());
|
||||
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testDeprecatedGetters($obj)
|
||||
{
|
||||
$this->assertEquals($obj->getEvent_types(), WebhookEventTypeTest::getObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testSerializationDeserialization
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testDeprecatedSetterNormalGetter($obj)
|
||||
{
|
||||
|
||||
// Check for Event_types
|
||||
$obj->setEventTypes(null);
|
||||
$this->assertNull($obj->getEvent_types());
|
||||
$this->assertNull($obj->getEventTypes());
|
||||
$this->assertSame($obj->getEventTypes(), $obj->getEvent_types());
|
||||
$obj->setEvent_types(WebhookEventTypeTest::getObject());
|
||||
$this->assertEquals($obj->getEvent_types(), WebhookEventTypeTest::getObject());
|
||||
|
||||
//Test All Deprecated Getters and Normal Getters
|
||||
$this->testDeprecatedGetters($obj);
|
||||
$this->testGetters($obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @expectedExceptionMessage Url is not a fully qualified URL
|
||||
*/
|
||||
public function testUrlValidationForUrl()
|
||||
{
|
||||
$obj = new Webhook();
|
||||
$obj->setUrl(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testCreate($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
self::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->create($mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testGet($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->get("webhookId", $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testGetAll($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
WebhookListTest::getJson()
|
||||
));
|
||||
|
||||
$result = $obj->getAll($mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testUpdate($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
self::getJson()
|
||||
));
|
||||
$patchRequest = PatchRequestTest::getObject();
|
||||
|
||||
$result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
/**
|
||||
* @dataProvider mockProvider
|
||||
* @param Webhook $obj
|
||||
*/
|
||||
public function testDelete($obj, $mockApiContext)
|
||||
{
|
||||
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PPRestCall')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$mockPPRestCall->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue(
|
||||
true
|
||||
));
|
||||
|
||||
$result = $obj->delete($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)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user