3 namespace PayPal\Test\Api;
5 use PayPal\Api\SubTransaction;
7 use PayPal\Api\Transaction;
8 use PayPal\Test\Constants;
10 class TransactionTest extends \PHPUnit_Framework_TestCase {
14 public static $description = "desc . . . ";
15 public static $total = "1.12";
17 public static function createTransaction() {
18 $transaction = new Transaction();
19 $transaction->setAmount(AmountTest::createAmount());
20 $transaction->setDescription(self::$description);
21 $transaction->setItemList(ItemListTest::createItemList());
22 $transaction->setPayee(PayeeTest::createPayee());
23 $transaction->setRelatedResources( array(RelatedResourcesTest::createRelatedResources()) );
27 public function setup() {
28 $this->transaction = self::createTransaction();
31 public function testGetterSetter() {
32 $this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency());
33 $this->assertEquals(self::$description, $this->transaction->getDescription());
34 $items = $this->transaction->getItemList()->getItems();
35 $this->assertEquals(ItemTest::$quantity, $items[0]->getQuantity());
36 $this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail());
37 $resources = $this->transaction->getRelatedResources();
38 $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime());
41 public function testSerializeDeserialize() {
42 $t1 = $this->transaction;
44 $t2 = new Transaction();
45 $t2->fromJson($t1->toJson());
47 $this->assertEquals($t1, $t2);