mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Merge pull request #7698 from tuka217/promotion-priority-bug
[Promotion] Promotion with priority equals to null should be last
This commit is contained in:
commit
b562a924f9
6 changed files with 58 additions and 2 deletions
|
|
@ -6,7 +6,8 @@ Feature: Editing promotion
|
|||
|
||||
Background:
|
||||
Given the store operates on a single channel in "United States"
|
||||
And there is a promotion "Christmas sale"
|
||||
And there is a promotion "Christmas sale" with priority 0
|
||||
And there is a promotion "Holiday sale" with priority 1
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
|
|
@ -59,3 +60,11 @@ Feature: Editing promotion
|
|||
Given this promotion gives "$10.00" discount to every order
|
||||
When the store also operates on another channel named "EU-WEB"
|
||||
Then I should be able to modify a "Christmas sale" promotion
|
||||
|
||||
@ui
|
||||
Scenario: Remove priority from existing promotion
|
||||
Given I want to modify a "Christmas sale" promotion
|
||||
When I remove its priority
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And the "Christmas sale" promotion should have priority 1
|
||||
|
|
|
|||
|
|
@ -117,6 +117,14 @@ final class ManagingPromotionsContext implements Context
|
|||
$this->createPage->nameIt($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I remove its priority
|
||||
*/
|
||||
public function iRemoveItsPriority()
|
||||
{
|
||||
$this->updatePage->setPriority(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the :promotionName promotion should appear in the registry
|
||||
* @Then the :promotionName promotion should exist in the registry
|
||||
|
|
@ -603,6 +611,16 @@ final class ManagingPromotionsContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given the :promotion promotion should have priority :priority
|
||||
*/
|
||||
public function thePromotionsShouldHavePriority(PromotionInterface $promotion, $priority)
|
||||
{
|
||||
$this->iWantToModifyAPromotion($promotion);
|
||||
|
||||
Assert::same($this->updatePage->getPriority(), $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $element
|
||||
* @param string $expectedMessage
|
||||
|
|
|
|||
|
|
@ -24,6 +24,22 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
use NamesIt;
|
||||
use ChecksCodeImmutability;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$this->getDocument()->fillField('Priority', $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
return $this->getElement('priority')->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -116,6 +132,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
{
|
||||
return [
|
||||
'code' => '#sylius_promotion_code',
|
||||
'priority' => '#sylius_promotion_priority',
|
||||
'coupon_based' => '#sylius_promotion_couponBased',
|
||||
'ends_at' => '#sylius_promotion_endsAt',
|
||||
'ends_at_date' => '#sylius_promotion_endsAt_date',
|
||||
|
|
|
|||
|
|
@ -19,6 +19,17 @@ use Sylius\Behat\Page\Admin\Crud\UpdatePageInterface as BaseUpdatePageInterface;
|
|||
*/
|
||||
interface UpdatePageInterface extends BaseUpdatePageInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param int|null $priority
|
||||
*/
|
||||
public function setPriority($priority);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPriority();
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\PromotionBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\PromotionBundle\Form\EventListener\SetPriorityFormSubscriber;
|
||||
use Sylius\Bundle\ResourceBundle\Form\EventSubscriber\AddCodeFormSubscriber;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class Promotion implements PromotionInterface
|
|||
*/
|
||||
public function setPriority($priority)
|
||||
{
|
||||
$this->priority = $priority;
|
||||
$this->priority = null === $priority ? -1 : $priority;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue