function it_throws_exception_if_any_array_element_is_not_adjustment(AdjustmentInterface $adjustment1, AdjustmentInterface $adjustment2) { $adjustment1->getLabel()->willReturn('tax 1'); $adjustment1->getAmount()->willReturn(1000); $adjustment2->getLabel()->willReturn('tax 1'); $adjustment2->getAmount()->willReturn(3000); $this->shouldThrow(new \InvalidArgumentException('Each adjustments array element must implement ' . AdjustmentInterface::class . '.'))->during('aggregate', array(array($adjustment1, $adjustment2, 'badObject'))); }
function it_throws_exception_if_any_array_element_is_not_adjustment(AdjustmentInterface $adjustment1, AdjustmentInterface $adjustment2) { $adjustment1->getLabel()->willReturn('tax 1'); $adjustment1->getAmount()->willReturn(1000); $adjustment2->getLabel()->willReturn('tax 1'); $adjustment2->getAmount()->willReturn(3000); $this->shouldThrow(\InvalidArgumentException::class)->during('aggregate', [[$adjustment1, $adjustment2, 'badObject']]); }
/** * Helper method */ protected function addShippingAndTaxAdjustments(OrderInterface $order, AdjustmentInterface $shippingAdjustment, AdjustmentInterface $taxAdjustment) { $shippingAdjustment->getLabel()->willReturn(OrderInterface::SHIPPING_ADJUSTMENT); $shippingAdjustment->setAdjustable($order)->shouldBeCalled(); $taxAdjustment->getLabel()->willReturn(OrderInterface::TAX_ADJUSTMENT); $taxAdjustment->setAdjustable($order)->shouldBeCalled(); $order->addAdjustment($shippingAdjustment); $order->addAdjustment($taxAdjustment); }