This repository has been archived on 2026-04-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PayPal-PHP-SDK/tests/PayPal/Test/Api/AuthorizationTest.php
Ganesh Hegde 50b09bdbde testcases updated
updated testcases to match new json schema
and updates with camel case function names
2013-05-28 10:08:34 +05:30

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);
}
}