/** * {@inheritdoc} */ public function revert(PromotionSubjectInterface $subject, PromotionInterface $promotion) { foreach ($promotion->getActions() as $action) { $this->getActionCommandByType($action->getType())->revert($subject, $action->getConfiguration(), $promotion); } $subject->removePromotion($promotion); }
function it_reverts_all_actions_registered(ServiceRegistryInterface $registry, PromotionActionCommandInterface $action, PromotionSubjectInterface $subject, PromotionInterface $promotion, PromotionActionInterface $actionModel) { $configuration = []; $registry->get('test_action')->willReturn($action); $promotion->getActions()->willReturn([$actionModel]); $actionModel->getType()->willReturn('test_action'); $actionModel->getConfiguration()->willReturn($configuration); $action->revert($subject, $configuration, $promotion)->shouldBeCalled(); $subject->removePromotion($promotion)->shouldBeCalled(); $this->revert($subject, $promotion); }
function it_should_revert_all_actions_registered(ServiceRegistryInterface $registry, PromotionActionInterface $action, PromotionSubjectInterface $subject, PromotionInterface $promotion, ActionInterface $actionModel) { $configuration = array(); $registry->get(ActionInterface::TYPE_FIXED_DISCOUNT)->shouldBeCalled()->willReturn($action); $promotion->getActions()->shouldBeCalled()->willReturn(array($actionModel)); $actionModel->getType()->shouldBeCalled()->willReturn(ActionInterface::TYPE_FIXED_DISCOUNT); $actionModel->getConfiguration()->shouldBeCalled()->willReturn($configuration); $action->revert($subject, $configuration, $promotion)->shouldBeCalled(); $subject->removePromotion($promotion)->shouldBeCalled(); $this->revert($subject, $promotion); }