mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Promotion] Added shipping discount creation method to factory
This commit is contained in:
parent
8c4ec34605
commit
7006ae046e
3 changed files with 29 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,11 @@ interface ActionFactoryInterface extends FactoryInterface
|
|||
* @return ActionInterface
|
||||
*/
|
||||
public function createPercentageDiscount($percentage);
|
||||
|
||||
/**
|
||||
* @param float $percentage
|
||||
*
|
||||
* @return ActionInterface
|
||||
*/
|
||||
public function createShippingDiscount($percentage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue