forked from LiveCarta/PayPal-PHP-SDK
76 lines
2.3 KiB
PHP
76 lines
2.3 KiB
PHP
<?php
|
|
namespace PayPal\Test\Api;
|
|
|
|
use PayPal\Api\CreditCardHistory;
|
|
|
|
use PayPal\Api\Address;
|
|
use PayPal\Api\CreditCard;
|
|
use PayPal\Test\Constants;
|
|
|
|
class CreditCardHistoryTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
private $cards;
|
|
|
|
public static $id = "id";
|
|
public static $validUntil = "2013-02-28T00:00:00Z";
|
|
public static $state = "created";
|
|
public static $payerId = "payer-id";
|
|
public static $cardType = "visa";
|
|
public static $cardNumber = "4417119669820331";
|
|
public static $expireMonth = 11;
|
|
public static $expireYear = "2019";
|
|
public static $cvv = "012";
|
|
public static $firstName = "V";
|
|
public static $lastName = "C";
|
|
|
|
public static function createCreditCard() {
|
|
$card = new CreditCard();
|
|
$card->setType(self::$cardType);
|
|
$card->setNumber(self::$cardNumber);
|
|
$card->setExpireMonth(self::$expireMonth);
|
|
$card->setExpireYear(self::$expireYear);
|
|
$card->setCvv2(self::$cvv);
|
|
$card->setFirstName(self::$firstName);
|
|
$card->setLastName(self::$lastName);
|
|
$card->setId(self::$id);
|
|
$card->setValidUntil(self::$validUntil);
|
|
$card->setState(self::$state);
|
|
$card->setPayerId(self::$payerId);
|
|
return $card;
|
|
}
|
|
|
|
public function setup() {
|
|
|
|
$card = self::createCreditCard();
|
|
$card->setBillingAddress(AddressTest::createAddress());
|
|
$card->setLinks(array(LinksTest::createLinks()));
|
|
$this->cards['full'] = $card;
|
|
|
|
$card = self::createCreditCard();
|
|
$this->cards['partial'] = $card;
|
|
}
|
|
|
|
public function testGetterSetters() {
|
|
$cardHistory = new CreditCardHistory();
|
|
$cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full']));
|
|
$cardHistory->setCount(2);
|
|
|
|
$this->assertEquals(2, count($cardHistory->getCreditCards()));
|
|
}
|
|
|
|
|
|
public function testSerializationDeserialization() {
|
|
// Stop here and mark this test as incomplete.
|
|
$this->markTestIncomplete(
|
|
'This test is failing because of warning thrown by regex at https://github.com/paypal/sdk-core-php/blob/master/lib/common/PPReflectionUtil.php#L59.'
|
|
);
|
|
$cardHistory = new CreditCardHistory();
|
|
$cardHistory->setCreditCards(array($this->cards['partial'], $this->cards['full']));
|
|
$cardHistory->setCount(2);
|
|
|
|
$cardHistoryCopy = new CreditCardHistory();
|
|
$cardHistoryCopy->fromJson($cardHistory->toJSON());
|
|
|
|
$this->assertEquals($cardHistory, $cardHistoryCopy);
|
|
}
|
|
} |