1 | <?php |
||
9 | class PaymentTest extends \PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | /** |
||
12 | * @var Payment |
||
13 | */ |
||
14 | private $payment; |
||
15 | |||
16 | /** |
||
17 | * @var DateTime |
||
18 | */ |
||
19 | private $escrowEndDate; |
||
20 | |||
21 | /** |
||
22 | * @var PaymentMethod |
||
23 | */ |
||
24 | private $paymentMethod; |
||
25 | |||
26 | protected function setUp() |
||
27 | { |
||
28 | $this->escrowEndDate = new DateTime("2015-01-01"); |
||
29 | $this->paymentMethod = $this->createMock(PaymentMethod::class); |
||
30 | $this->payment = new Payment($this->paymentMethod, 123, 2, 3, 4, 5, 1, $this->escrowEndDate); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @test |
||
35 | */ |
||
36 | public function constructShouldConfigureTheAttributes() |
||
37 | { |
||
38 | $this->assertAttributeSame($this->paymentMethod, 'paymentMethod', $this->payment); |
||
39 | $this->assertAttributeEquals(123, 'grossAmount', $this->payment); |
||
40 | $this->assertAttributeEquals(2, 'discountAmount', $this->payment); |
||
41 | $this->assertAttributeEquals(3, 'feeAmount', $this->payment); |
||
42 | $this->assertAttributeEquals(4, 'netAmount', $this->payment); |
||
43 | $this->assertAttributeEquals(5, 'extraAmount', $this->payment); |
||
44 | $this->assertAttributeEquals(1, 'installmentCount', $this->payment); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @test |
||
49 | */ |
||
50 | public function getPaymentMethodShouldReturnTheConfiredPaymentMethod() |
||
51 | { |
||
52 | $this->assertSame($this->paymentMethod, $this->payment->getPaymentMethod()); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @test |
||
57 | */ |
||
58 | public function getGrossAmountShouldReturnTheConfiredGrossAmount() |
||
59 | { |
||
60 | $this->assertEquals(123, $this->payment->getGrossAmount()); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @test |
||
65 | */ |
||
66 | public function getDiscountAmountShouldReturnTheConfiredDiscountAmount() |
||
67 | { |
||
68 | $this->assertEquals(2, $this->payment->getDiscountAmount()); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @test |
||
73 | */ |
||
74 | public function getFeeAmountShouldReturnTheConfiredFeeAmount() |
||
75 | { |
||
76 | $this->assertEquals(3, $this->payment->getFeeAmount()); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @test |
||
81 | */ |
||
82 | public function getNetAmountShouldReturnTheConfiredNetAmount() |
||
83 | { |
||
84 | $this->assertEquals(4, $this->payment->getNetAmount()); |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * @test |
||
89 | */ |
||
90 | public function getExtraAmountShouldReturnTheConfiredExtraAmount() |
||
91 | { |
||
92 | $this->assertEquals(5, $this->payment->getExtraAmount()); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @test |
||
97 | */ |
||
98 | public function getInstallmentCountShouldReturnTheConfiredInstallmentCount() |
||
99 | { |
||
100 | $this->assertEquals(1, $this->payment->getInstallmentCount()); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @test |
||
105 | */ |
||
106 | public function getEscrowEndDateShouldReturnTheConfiredEscrowEndDate() |
||
107 | { |
||
108 | $this->assertSame($this->escrowEndDate, $this->payment->getEscrowEndDate()); |
||
109 | } |
||
110 | } |
||
111 |