1 | <?php |
||
9 | use PHPSC\PagSeguro\Customer\Customer; |
||
10 | use PHPSC\PagSeguro\Customer\Phone; |
||
11 | use PHPSC\PagSeguro\Customer\Address; |
||
12 | |||
13 | /** |
||
14 | * @author Luís Otávio Cobucci Oblonczyk <[email protected]> |
||
15 | */ |
||
16 | class CheckoutTest extends \PHPUnit_Framework_TestCase |
||
17 | { |
||
18 | /** |
||
19 | * @var Checkout |
||
20 | */ |
||
21 | private $checkout; |
||
22 | |||
23 | /** |
||
24 | * @var Order |
||
25 | */ |
||
26 | private $order; |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | protected function setUp() |
||
32 | { |
||
33 | $this->order = new Order(); |
||
34 | $this->checkout = new Checkout($this->order); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @test |
||
39 | */ |
||
40 | public function constructShouldConfigureAttributes() |
||
41 | { |
||
42 | $this->assertAttributeSame($this->order, 'order', $this->checkout); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @test |
||
47 | */ |
||
48 | public function constructShouldCreateANewOrderWhenItWasntInformed() |
||
49 | { |
||
50 | $this->assertAttributeInstanceOf( |
||
51 | Order::class, |
||
52 | 'order', |
||
53 | new Checkout() |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | public function getOrderShouldReturnConfiguredOrder() |
||
58 | { |
||
59 | $this->assertSame($this->order, $this->checkout->getOrder()); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @test |
||
64 | */ |
||
65 | public function setCustomerShouldConfigureTheReference() |
||
66 | { |
||
67 | $customer = new Customer('[email protected]'); |
||
68 | $this->checkout->setCustomer($customer); |
||
69 | |||
70 | $this->assertAttributeSame($customer, 'customer', $this->checkout); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @test |
||
75 | */ |
||
76 | public function setRedirectToShouldConfigureTheRedirectionUri() |
||
77 | { |
||
78 | $this->checkout->setRedirectTo('http://test.com'); |
||
79 | |||
80 | $this->assertAttributeEquals('http://test.com', 'redirectTo', $this->checkout); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @test |
||
85 | */ |
||
86 | public function setMaxAgeShouldConfigureTheMaximumAge() |
||
87 | { |
||
88 | $this->checkout->setMaxAge(1); |
||
89 | |||
90 | $this->assertAttributeEquals(1, 'maxAge', $this->checkout); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @test |
||
95 | */ |
||
96 | public function setMaxUsesShouldTheNumberOfUses() |
||
97 | { |
||
98 | $this->checkout->setMaxUses(1); |
||
99 | |||
100 | $this->assertAttributeEquals(1, 'maxUses', $this->checkout); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @test |
||
105 | */ |
||
106 | public function getMaxAgeShouldReturnConfiguredMaxAge() |
||
107 | { |
||
108 | $this->checkout->setMaxAge(12); |
||
109 | |||
110 | $this->assertEquals(12, $this->checkout->getMaxAge()); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @test |
||
115 | */ |
||
116 | public function getMaxUsesShouldReturnConfiguredMaxUses() |
||
117 | { |
||
118 | $this->checkout->setMaxUses(7); |
||
119 | |||
120 | $this->assertEquals(7, $this->checkout->getMaxUses()); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @test |
||
125 | */ |
||
126 | public function getRedirectToShouldReturnConfiguredRedirectTo() |
||
127 | { |
||
128 | $this->checkout->setRedirectTo('someRedirect'); |
||
129 | |||
130 | $this->assertEquals('someRedirect', $this->checkout->getRedirectTo()); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @test |
||
135 | */ |
||
136 | public function getCustomerShouldReturnConfiguredCustomer() |
||
137 | { |
||
138 | $customer = $this->createMock(Customer::class); |
||
139 | $this->checkout->setCustomer($customer); |
||
140 | |||
141 | $this->assertSame($customer, $this->checkout->getCustomer()); |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * @test |
||
146 | */ |
||
147 | public function setNotificationURLShouldConfigureTheNotificationUri() |
||
218 |