3 namespace PayPal\Test\Api;
6 use PayPal\Test\Constants;
8 class AmountTest extends \PHPUnit_Framework_TestCase {
12 public static $currency = "USD";
13 public static $total = "1.12";
15 public static function createAmount() {
16 $amount = new Amount();
17 $amount->setCurrency(self::$currency);
18 $amount->setTotal(self::$total);
23 public function setup() {
24 $this->amounts['partial'] = self::createAmount();
26 $amount = self::createAmount();
27 $amount->setDetails(DetailsTest::createAmountDetails());
28 $this->amounts['full'] = $amount;
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());
37 public function testSerializeDeserialize() {
38 $a1 = $this->amounts['partial'];
41 $a2->fromJson($a1->toJson());
43 $this->assertEquals($a1, $a2);