Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a348bd

Browse files
committed
[API] move const to core, cs fixes
1 parent 5e36c5c commit 8a348bd

12 files changed

Lines changed: 21 additions & 33 deletions

File tree

features/promotion/managing_catalog_promotions/creating_catalog_promotion.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Feature: Creating a catalog promotion
2727
And I specify its label as "Winter -50%" in "English (United States)"
2828
And I describe it as "This promotion gives a 50% discount on all products" in "English (United States)"
2929
And it applies on variants "PHP T-Shirt" variant and "Kotlin T-Shirt" variant
30-
And I add the percentage discount catalog promotion action configured with amount of "50%"
30+
And it gives the "50%" percentage discount
3131
And I add it
3232
Then there should be 1 new catalog promotion on the list
3333
And it should have "winter_sale" code and "Winter sale" name

features/promotion/managing_catalog_promotions/editing_catalog_promotion.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ Feature: Editing catalog promotion
5252

5353
@api
5454
Scenario: Editing catalog promotion action
55-
When I want "Christmas sale" catalog promotion to have "40%" discount
55+
When I edit "Christmas sale" catalog promotion to have "40%" discount
5656
Then I should be notified that it has been successfully edited
5757
And this catalog promotion should have "40%" percentage discount

src/Sylius/Behat/Context/Api/Admin/ManagingCatalogPromotionsContext.php

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,16 @@ public function iWantToModifyACatalogPromotion(CatalogPromotionInterface $catalo
172172
}
173173

174174
/**
175-
* @When I add the percentage discount catalog promotion action configured with amount of :amount
175+
* @When it gives the :amount percentage discount
176176
*/
177177
public function iAddThePercentageDiscountCatalogPromotionActionConfiguredWithAmountOf(string $amount): void
178178
{
179-
$actions = [
180-
[
181-
'type' => CatalogPromotionInterface::TYPE_PERCENTAGE_DISCOUNT,
182-
'configuration' => [
183-
'amount' => $amount
184-
],
179+
$actions = [[
180+
'type' => CatalogPromotionActionInterface::TYPE_PERCENTAGE_DISCOUNT,
181+
'configuration' => [
182+
'amount' => $amount
185183
],
186-
];
184+
]];
187185

188186
$this->client->addRequestData('actions', $actions);
189187
}
@@ -240,13 +238,13 @@ public function iWantCatalogPromotionToBeAppliedOn(CatalogPromotionInterface $ca
240238
}
241239

242240
/**
243-
* @When /^I want ("[^"]+" catalog promotion) to have "([^"]+)" discount$/
241+
* @When /^I edit ("[^"]+" catalog promotion) to have "([^"]+)" discount$/
244242
*/
245243
public function iWantPromotionToHaveDiscount(CatalogPromotionInterface $catalogPromotion, string $amount): void
246244
{
247245
$this->client->buildUpdateRequest($catalogPromotion->getCode());
248246
$rules = [[
249-
'type' => CatalogPromotionInterface::TYPE_PERCENTAGE_DISCOUNT,
247+
'type' => CatalogPromotionActionInterface::TYPE_PERCENTAGE_DISCOUNT,
250248
'configuration' => [
251249
'amount' => $amount,
252250
],
@@ -266,14 +264,6 @@ public function thereShouldBeNewCatalogPromotionOnTheList(int $amount = 0): void
266264
Assert::count($this->responseChecker->getCollection($this->client->index()), $amount);
267265
}
268266

269-
/**
270-
* @Then I should be notified that it has been successfully created
271-
*/
272-
public function iShouldBeNotifiedThatItHasBeenSuccessfullyCreated(): void
273-
{
274-
Assert::same($this->client->getLastResponse()->getStatusCode(), 201);
275-
}
276-
277267
/**
278268
* @Then /^it should have "([^"]+)" discount$/
279269
*/
@@ -292,7 +282,7 @@ public function itShouldHavePercentageDiscount(string $amount): void
292282
$catalogPromotionAction = $this->responseChecker->getResponseContent($this->client->getLastResponse())['actions'][0];
293283

294284
Assert::same($amount, $catalogPromotionAction['configuration']['amount']);
295-
Assert::same(CatalogPromotionInterface::TYPE_PERCENTAGE_DISCOUNT, $catalogPromotionAction['type']);
285+
Assert::same(CatalogPromotionActionInterface::TYPE_PERCENTAGE_DISCOUNT, $catalogPromotionAction['type']);
296286
}
297287

298288
/**

src/Sylius/Bundle/ApiBundle/Resources/config/serialization/CatalogPromotion.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
<group>admin:catalog_promotion:read</group>
5050
<group>admin:catalog_promotion:create</group>
5151
<group>admin:catalog_promotion:update</group>
52-
5352
</attribute>
5453
</class>
5554
</serializer>

src/Sylius/Bundle/CoreBundle/Migrations/Version20210826063828.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class Version20210826063828 extends AbstractMigration
1414
{
1515
public function getDescription(): string
1616
{
17-
return '';
17+
return 'Add catalog promotion actions';
1818
}
1919

2020
public function up(Schema $schema): void

src/Sylius/Bundle/PromotionBundle/Resources/config/doctrine/model/CatalogPromotionAction.orm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<generator strategy="AUTO" />
1818
</id>
1919

20-
<field name="type" type="string" />
20+
<field name="type" />
2121
<field name="configuration" type="array" />
2222

2323
<many-to-one field="catalogPromotion" target-entity="Sylius\Component\Promotion\Model\CatalogPromotionInterface" inversed-by="actions">

src/Sylius/Component/Core/Model/CatalogPromotionInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818

1919
interface CatalogPromotionInterface extends BaseCatalogPromotionInterface, ChannelsAwareInterface
2020
{
21+
public const TYPE_CONTAINS_VARIANTS = 'contains_variants';
2122
}

src/Sylius/Component/Promotion/Model/CatalogPromotion.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public function __construct()
4646
$this->initializeTranslationsCollection();
4747

4848
$this->rules = new ArrayCollection();
49-
5049
$this->actions = new ArrayCollection();
5150
}
5251

src/Sylius/Component/Promotion/Model/CatalogPromotionAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CatalogPromotionAction implements CatalogPromotionActionInterface
1818
/** @var mixed */
1919
protected $id;
2020

21-
protected ?string $type;
21+
protected ?string $type = null;
2222

2323
protected array $configuration = [];
2424

src/Sylius/Component/Promotion/Model/CatalogPromotionActionInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
interface CatalogPromotionActionInterface extends ResourceInterface
1919
{
20+
public const TYPE_PERCENTAGE_DISCOUNT = 'percentage_product_discount';
21+
2022
public function setType(?string $type): void;
2123

2224
public function setConfiguration(array $configuration): void;

0 commit comments

Comments
 (0)