[Promotion] Added shipping discount creation method to factory

This commit is contained in:
Mateusz Zalewski 2016-02-23 14:19:42 +01:00
parent 8c4ec34605
commit 7006ae046e
3 changed files with 29 additions and 0 deletions

View file

@ -63,4 +63,16 @@ class ActionFactory implements ActionFactoryInterface
return $action;
}
/**
* {@inheritdoc}
*/
public function createShippingDiscount($percentage)
{
$action = $this->createNew();
$action->setType('shipping_discount');
$action->setConfiguration(['percentage' => $percentage]);
return $action;
}
}

View file

@ -32,4 +32,11 @@ interface ActionFactoryInterface extends FactoryInterface
* @return ActionInterface
*/
public function createPercentageDiscount($percentage);
/**
* @param float $percentage
*
* @return ActionInterface
*/
public function createShippingDiscount($percentage);
}

View file

@ -62,4 +62,14 @@ class ActionFactorySpec extends ObjectBehavior
$this->createPercentageDiscount(0.1)->shouldReturn($action);
}
function it_creates_shipping_discount_action_with_given_discount_rate($decoratedFactory, ActionInterface $action)
{
$decoratedFactory->createNew()->willReturn($action);
$action->setType('shipping_discount')->shouldBeCalled();
$action->setConfiguration(['percentage' => 0.1])->shouldBeCalled();
$this->createShippingDiscount(0.1)->shouldReturn($action);
}
}