| @@ 164-185 (lines=22) @@ | ||
| 161 | $this->getTotal()->shouldReturn(1000); |
|
| 162 | } |
|
| 163 | ||
| 164 | function it_has_proper_total_after_order_item_unit_price_change( |
|
| 165 | AdjustmentInterface $adjustment1, |
|
| 166 | AdjustmentInterface $adjustment2, |
|
| 167 | OrderItemInterface $orderItem |
|
| 168 | ) { |
|
| 169 | $orderItem->recalculateUnitsTotal()->shouldBeCalledTimes(2); |
|
| 170 | ||
| 171 | $adjustment1->isNeutral()->willReturn(false); |
|
| 172 | $adjustment1->setAdjustable($this)->shouldBeCalled(); |
|
| 173 | $adjustment1->getAmount()->willReturn(100); |
|
| 174 | ||
| 175 | $adjustment2->isNeutral()->willReturn(false); |
|
| 176 | $adjustment2->setAdjustable($this)->shouldBeCalled(); |
|
| 177 | $adjustment2->getAmount()->willReturn(50); |
|
| 178 | ||
| 179 | $this->addAdjustment($adjustment1); |
|
| 180 | $this->addAdjustment($adjustment2); |
|
| 181 | ||
| 182 | $orderItem->getUnitPrice()->willReturn(500); |
|
| 183 | ||
| 184 | $this->getTotal()->shouldReturn(650); |
|
| 185 | } |
|
| 186 | ||
| 187 | function it_recalculates_its_total_properly_after_adjustment_amount_change( |
|
| 188 | AdjustmentInterface $adjustment1, |
|
| @@ 326-341 (lines=16) @@ | ||
| 323 | $this->getTotal()->shouldReturn(0); |
|
| 324 | } |
|
| 325 | ||
| 326 | function it_has_total_quantity(OrderItemInterface $orderItem1, OrderItemInterface $orderItem2) |
|
| 327 | { |
|
| 328 | $orderItem1->getQuantity()->willReturn(10); |
|
| 329 | $orderItem1->setOrder($this)->shouldBeCalled(); |
|
| 330 | $orderItem1->getTotal()->willReturn(500); |
|
| 331 | ||
| 332 | $orderItem2->getQuantity()->willReturn(30); |
|
| 333 | $orderItem2->setOrder($this)->shouldBeCalled(); |
|
| 334 | $orderItem2->equals($orderItem1)->willReturn(false); |
|
| 335 | $orderItem2->getTotal()->willReturn(1000); |
|
| 336 | ||
| 337 | $this->addItem($orderItem1); |
|
| 338 | $this->addItem($orderItem2); |
|
| 339 | ||
| 340 | $this->getTotalQuantity()->shouldReturn(40); |
|
| 341 | } |
|
| 342 | ||
| 343 | function it_calculates_correct_total(OrderItemInterface $item1, OrderItemInterface $item2, AdjustmentInterface $adjustment1, AdjustmentInterface $adjustment2) |
|
| 344 | { |
|