f2e0ba337b2c3625d3995fecae2778a9e18b7921
[WP-Plugins/glm-member-db.git] /
1 <?php
2
3 namespace PayPal\Test\Api;
4
5 use PayPal\Api\SubTransaction;
6
7 use PayPal\Api\Transaction;
8 use PayPal\Test\Constants;
9
10 class TransactionTest extends \PHPUnit_Framework_TestCase {
11
12         private $transaction;
13
14         public static $description = "desc . . . ";
15         public static $total = "1.12";  
16
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()) );
24                 return $transaction;
25         }
26         
27         public function setup() {
28                 $this->transaction = self::createTransaction();
29         }
30
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());
39         }
40         
41         public function testSerializeDeserialize() {
42                 $t1 = $this->transaction;
43                 
44                 $t2 = new Transaction();
45                 $t2->fromJson($t1->toJson());
46                 
47                 $this->assertEquals($t1, $t2);
48         }
49 }