7f24e7bb623d7ae0eddff991428ab57124528a33
[WP-Plugins/glm-member-db.git] /
1 <?php
2
3 namespace PayPal\Test\Api;
4
5 use PayPal\Api\Amount;
6 use PayPal\Test\Constants;
7
8 class AmountTest extends \PHPUnit_Framework_TestCase {
9
10         private $amounts;
11
12         public static $currency = "USD";
13         public static $total = "1.12";  
14
15         public static function createAmount() {
16                 $amount = new Amount();
17                 $amount->setCurrency(self::$currency);
18                 $amount->setTotal(self::$total);
19                 
20                 return $amount;
21         }
22         
23         public function setup() {
24                 $this->amounts['partial'] = self::createAmount();
25                 
26                 $amount = self::createAmount();
27                 $amount->setDetails(DetailsTest::createAmountDetails());
28                 $this->amounts['full'] = $amount;
29         }
30
31         public function testGetterSetter() {
32                 $this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency());
33                 $this->assertEquals(self::$total, $this->amounts['partial']->getTotal());
34                 $this->assertEquals(DetailsTest::$fee, $this->amounts['full']->getDetails()->getFee());
35         }
36         
37         public function testSerializeDeserialize() {
38                 $a1 = $this->amounts['partial'];
39                 
40                 $a2 = new Amount();
41                 $a2->fromJson($a1->toJson());
42                 
43                 $this->assertEquals($a1, $a2);
44         }
45 }