forked from LiveCarta/PayPal-PHP-SDK
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
namespace PayPal\Test\Api;
|
|
|
|
use PayPal\Api\Amount;
|
|
use PayPal\Api\Authorization;
|
|
use PayPal\Api\Links;
|
|
use PayPal\Test\Constants;
|
|
|
|
class AuthorizationTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
private $authorizations = array();
|
|
|
|
public static $create_time = "2013-02-28T00:00:00Z";
|
|
public static $id = "AUTH-123";
|
|
public static $state = "Created";
|
|
public static $parent_payment = "PAY-12345";
|
|
|
|
public static $currency = "USD";
|
|
public static $total = "1.12";
|
|
|
|
public static $href = "USD";
|
|
public static $rel = "1.12";
|
|
public static $method = "1.12";
|
|
|
|
public static function createAuthorization() {
|
|
$authorization = new Authorization();
|
|
$authorization->setCreateTime(self::$create_time);
|
|
$authorization->setId(self::$id);
|
|
$authorization->setState(self::$state);
|
|
|
|
$authorization->setAmount(AmountTest::createAmount());
|
|
$authorization->setLinks(array(LinksTest::createLinks()));
|
|
|
|
return $authorization;
|
|
}
|
|
|
|
public function setup() {
|
|
$authorization = new Authorization();
|
|
$authorization->setCreateTime(self::$create_time);
|
|
$authorization->setId(self::$id);
|
|
$authorization->setState(self::$state);
|
|
$authorization->setParentPayment(self::$parent_payment);
|
|
$this->authorizations['partial'] = $authorization;
|
|
|
|
|
|
$this->authorizations['full'] = self::createAuthorization();
|
|
}
|
|
|
|
public function testGetterSetter() {
|
|
$authorization = $this->authorizations['partial'];
|
|
$this->assertEquals(self::$create_time, $authorization->getCreateTime());
|
|
$this->assertEquals(self::$id, $authorization->getId());
|
|
$this->assertEquals(self::$state, $authorization->getState());
|
|
$this->assertEquals(self::$parent_payment, $authorization->getParentPayment());
|
|
|
|
$authorization = $this->authorizations['full'];
|
|
$this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency());
|
|
$this->assertEquals(1, count($authorization->getLinks()));
|
|
}
|
|
|
|
public function testSerializeDeserialize() {
|
|
$a1 = $this->authorizations['partial'];
|
|
|
|
$a2 = new Authorization();
|
|
$a2->fromJson($a1->toJson());
|
|
|
|
$this->assertEquals($a1, $a2);
|
|
}
|
|
} |