1 | <?php |
||
10 | class OrderTest extends \PHPUnit_Framework_TestCase |
||
11 | { |
||
12 | /** |
||
13 | * @var ItemCollection |
||
14 | */ |
||
15 | private $items; |
||
16 | |||
17 | /** |
||
18 | * @var Order |
||
19 | */ |
||
20 | private $order; |
||
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | protected function setUp() |
||
26 | { |
||
27 | $this->items = $this->createMock(ItemCollection::class); |
||
28 | $this->order = new Order($this->items); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @test |
||
33 | */ |
||
34 | public function constructShouldConfigureItemsAndCurrency() |
||
35 | { |
||
36 | $this->assertAttributeSame($this->items, 'items', $this->order); |
||
37 | $this->assertAttributeEquals('BRL', 'currency', $this->order); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @test |
||
42 | */ |
||
43 | public function constructShouldCreateAnItemCollectionWhenItWasntInformed() |
||
44 | { |
||
45 | $this->assertAttributeInstanceOf(ItemCollection::class, 'items', new Order()); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @test |
||
50 | */ |
||
51 | public function getItemsShouldReturnConfiguredItemCollection() |
||
52 | { |
||
53 | $this->assertSame($this->items, $this->order->getItems()); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @test |
||
58 | */ |
||
59 | public function getCurrencyShouldReturnConfiguredCurrency() |
||
60 | { |
||
61 | $this->assertEquals('BRL', $this->order->getCurrency()); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @test |
||
66 | */ |
||
67 | public function getReferenceShouldReturnConfiguredReference() |
||
68 | { |
||
69 | $this->order->setReference('someRef'); |
||
70 | |||
71 | $this->assertEquals('someRef', $this->order->getReference()); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @test |
||
76 | */ |
||
77 | public function getExtraAmountShouldReturnConfiguredExtraAmount() |
||
78 | { |
||
79 | $this->order->setExtraAmount(123); |
||
80 | |||
81 | $this->assertEquals(123, $this->order->getExtraAmount()); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @test |
||
86 | */ |
||
87 | public function getShippingShouldReturnConfiguredShipping() |
||
88 | { |
||
89 | $shipping = new Shipping(1); |
||
90 | $this->order->setShipping($shipping); |
||
91 | |||
92 | $this->assertSame($shipping, $this->order->getShipping()); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @test |
||
97 | */ |
||
98 | public function setReferenceShouldChangeTheAttribute() |
||
99 | { |
||
100 | $this->order->setReference('test'); |
||
101 | |||
102 | $this->assertAttributeEquals('test', 'reference', $this->order); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @test |
||
107 | */ |
||
108 | public function setShippingShouldChangeTheAttribute() |
||
109 | { |
||
110 | $shipping = new Shipping(1); |
||
111 | $this->order->setShipping($shipping); |
||
112 | |||
113 | $this->assertAttributeSame($shipping, 'shipping', $this->order); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @test |
||
118 | */ |
||
119 | public function setExtraAmountShouldChangeTheAttribute() |
||
120 | { |
||
121 | $this->order->setExtraAmount(10); |
||
122 | |||
123 | $this->assertAttributeEquals(10, 'extraAmount', $this->order); |
||
124 | } |
||
125 | } |
||
126 |