1 | <?php |
||
9 | class PreApprovalTest extends \PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | public function testAttributesShouldValuesEmpty() |
||
12 | { |
||
13 | $preApproval = new PreApproval; |
||
14 | |||
15 | $this->assertAttributeEmpty('name', $preApproval); |
||
16 | $this->assertAttributeEmpty('chargeType', $preApproval); |
||
17 | $this->assertAttributeEmpty('details', $preApproval); |
||
18 | $this->assertAttributeEmpty('period', $preApproval); |
||
19 | $this->assertAttributeEmpty('finalDate', $preApproval); |
||
20 | $this->assertAttributeEmpty('maxTotalAmount', $preApproval); |
||
21 | $this->assertAttributeEmpty('amountPerPayment', $preApproval); |
||
22 | $this->assertAttributeEmpty('maxAmountPerPayment', $preApproval); |
||
23 | $this->assertAttributeEmpty('maxPaymentsPerPeriod', $preApproval); |
||
24 | $this->assertAttributeEmpty('maxAmountPerPeriod', $preApproval); |
||
25 | $this->assertAttributeEmpty('initialDate', $preApproval); |
||
26 | } |
||
27 | |||
28 | public function testSetChargeTypeShouldThrowInvalidArgumentException() |
||
29 | { |
||
30 | $this->setExpectedException('InvalidArgumentException', 'You should inform a valid charge type'); |
||
31 | |||
32 | $preApproval = new PreApproval; |
||
33 | $preApproval->setChargeType('other'); |
||
34 | } |
||
35 | |||
36 | public function testSetPeriodShouldThrowInvalidArgumentException() |
||
37 | { |
||
38 | $this->setExpectedException('InvalidArgumentException', 'You should inform a valid period'); |
||
39 | |||
40 | $preApproval = new PreApproval; |
||
41 | $preApproval->setPeriod('other'); |
||
42 | } |
||
43 | |||
44 | public function testSettersAndGettersAttributes() |
||
45 | { |
||
46 | $preApproval = new PreApproval; |
||
47 | |||
48 | $preApproval->setName('Name Assinatura'); |
||
49 | $preApproval->setChargeType('auto'); |
||
50 | $preApproval->setDetails('Cobranca Mensal'); |
||
51 | $preApproval->setPeriod('MONTHLY'); |
||
52 | $preApproval->setFinalDate(new DateTime('2016-11-18')); |
||
53 | $preApproval->setMaxTotalAmount(3000); |
||
54 | $preApproval->setAmountPerPayment(100); |
||
55 | $preApproval->setMaxAmountPerPayment(150); |
||
56 | $preApproval->setMaxPaymentsPerPeriod(12); |
||
57 | $preApproval->setMaxAmountPerPeriod(1200); |
||
58 | $preApproval->setInitialDate(new DateTime('2015-11-18')); |
||
59 | |||
60 | $this->assertAttributeEquals('Name Assinatura', 'name', $preApproval); |
||
61 | $this->assertAttributeEquals('auto', 'chargeType', $preApproval); |
||
62 | $this->assertAttributeEquals('Cobranca Mensal', 'details', $preApproval); |
||
63 | $this->assertAttributeEquals('MONTHLY', 'period', $preApproval); |
||
64 | $this->assertAttributeEquals(new DateTime('2016-11-18'), 'finalDate', $preApproval); |
||
65 | $this->assertAttributeEquals(3000, 'maxTotalAmount', $preApproval); |
||
66 | $this->assertAttributeEquals(100, 'amountPerPayment', $preApproval); |
||
67 | $this->assertAttributeEquals(150, 'maxAmountPerPayment', $preApproval); |
||
68 | $this->assertAttributeEquals(12, 'maxPaymentsPerPeriod', $preApproval); |
||
69 | $this->assertAttributeEquals(1200, 'maxAmountPerPeriod', $preApproval); |
||
70 | $this->assertAttributeEquals(new DateTime('2015-11-18'), 'initialDate', $preApproval); |
||
71 | |||
72 | $this->assertEquals('Name Assinatura', $preApproval->getName()); |
||
73 | $this->assertEquals('auto', $preApproval->getChargeType()); |
||
74 | $this->assertEquals('Cobranca Mensal', $preApproval->getDetails()); |
||
75 | $this->assertEquals('MONTHLY', $preApproval->getPeriod()); |
||
76 | $this->assertEquals(new DateTime('2016-11-18'), $preApproval->getFinalDate()); |
||
77 | $this->assertEquals(3000, $preApproval->getMaxTotalAmount()); |
||
78 | $this->assertEquals(100, $preApproval->getAmountPerPayment()); |
||
79 | $this->assertEquals(150, $preApproval->getMaxAmountPerPayment()); |
||
80 | $this->assertEquals(12, $preApproval->getMaxPaymentsPerPeriod()); |
||
81 | $this->assertEquals(1200, $preApproval->getMaxAmountPerPeriod()); |
||
82 | $this->assertEquals(new DateTime('2015-11-18'), $preApproval->getInitialDate()); |
||
83 | } |
||
84 | } |
||
85 |