Updated Payment APIs

- Updated SDK Models to latest Payment APIs
- Updated Unit Tests
This commit is contained in:
Jay Patel
2015-02-26 15:03:59 -06:00
parent 241d80cd17
commit 3e43f93f9b
93 changed files with 6079 additions and 1735 deletions

View File

@@ -2,45 +2,58 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentHistory;
use PayPal\Test\Constants;
/**
* Class PaymentHistory
*
* @package PayPal\Test\Api
*/
class PaymentHistoryTest extends \PHPUnit_Framework_TestCase
{
/** @var PaymentHistory */
private $history;
public static $count = 10;
public static $nextId = "11";
public static function createPaymentHistory()
/**
* Gets Json String of Object PaymentHistory
* @return string
*/
public static function getJson()
{
$history = new PaymentHistory();
$history->setCount(self::$count);
$history->setNextId(self::$nextId);
$history->setPayments(array(PaymentTest::createPayment()));
return $history;
return '{"payments":' .PaymentTest::getJson() . ',"count":123,"next_id":"TestSample"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return PaymentHistory
*/
public static function getObject()
{
$this->history = PaymentHistoryTest::createPaymentHistory();
return new PaymentHistory(self::getJson());
}
public function testGetterSetters()
{
$this->assertEquals(self::$count, $this->history->getCount());
$this->assertEquals(self::$nextId, $this->history->getNextId());
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentHistory
*/
public function testSerializationDeserialization()
{
$obj = new PaymentHistory(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPayments());
$this->assertNotNull($obj->getCount());
$this->assertNotNull($obj->getNextId());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param PaymentHistory $obj
*/
public function testGetters($obj)
{
$history = new PaymentHistory();
$history->fromJson($this->history->toJSON());
$this->assertEquals($history, $this->history);
$this->assertEquals($obj->getPayments(), PaymentTest::getObject());
$this->assertEquals($obj->getCount(), 123);
$this->assertEquals($obj->getNextId(), "TestSample");
}
}
}