Skip to content

Commit

Permalink
Get product by slug api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
paullla committed Nov 16, 2021
1 parent e125bb1 commit 03d2c26
Show file tree
Hide file tree
Showing 47 changed files with 524 additions and 60 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fail-fast: false
matrix:
php: ["7.4", "8.0"]
symfony: ["^4.4", "5.2.*", "5.3.*"]
symfony: ["^4.4", "5.3.*"]

steps:
-
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
strategy:
matrix:
php: ["8.0"]
symfony: ["5.2.*"]
symfony: ["5.3.*"]
postgres: ["13.3"]

env:
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs:
strategy:
matrix:
php: ["8.0"]
symfony: ["5.2.*"]
symfony: ["5.3.*"]
mariadb: ["10.4.10"]

env:
Expand Down Expand Up @@ -327,7 +327,7 @@ jobs:
fail-fast: false
matrix:
php: ["7.4", "8.0"]
symfony: ["^4.4", "5.2.*", "5.3.*"]
symfony: ["^4.4", "5.3.*"]
node: ["14.x"]
mysql: ["5.7", "8.0"]

Expand Down Expand Up @@ -456,7 +456,7 @@ jobs:
fail-fast: false
matrix:
php: ["7.4", "8.0"]
symfony: ["^4.4", "5.2.*", "5.3.*"]
symfony: ["^4.4", "5.3.*"]
node: ["14.x"]
mysql: ["5.7", "8.0"]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
fail-fast: false
matrix:
php: ["7.4", "8.0"]
symfony: ["^4.4", "5.2.*"]
symfony: ["^4.4", "5.3.*"]
package: "${{ fromJson(needs.list.outputs.packages) }}"

steps:
Expand Down
76 changes: 38 additions & 38 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"payum/payum": "^1.6",
"payum/payum-bundle": "^2.4",
"php-http/guzzle6-adapter": "^2.0",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"ramsey/uuid": "^3.9",
"sonata-project/block-bundle": "^4.2",
"stof/doctrine-extensions-bundle": "^1.4",
Expand All @@ -69,46 +68,46 @@
"sylius/resource": "^1.7",
"sylius/resource-bundle": "^1.7",
"sylius/theme-bundle": "^2.1.1",
"symfony/asset": "^4.4 || ^5.2",
"symfony/config": "^4.4 || ^5.2",
"symfony/console": "^4.4 || ^5.2",
"symfony/dependency-injection": "^4.4 || ^5.2",
"symfony/doctrine-bridge": "^4.4 || ^5.2",
"symfony/event-dispatcher": "^4.4 || ^5.2",
"symfony/expression-language": "^4.4 || ^5.2",
"symfony/filesystem": "^4.4 || ^5.2",
"symfony/finder": "^4.4 || ^5.2",
"symfony/form": "^4.4 || ^5.2",
"symfony/framework-bundle": "^4.4 || ^5.2",
"symfony/http-foundation": "^4.4 || ^5.2",
"symfony/http-kernel": "^4.4 || ^5.2",
"symfony/intl": "^4.4 || ^5.2",
"symfony/messenger": "^4.4 || ^5.2",
"symfony/asset": "^4.4 || ^5.3",
"symfony/config": "^4.4 || ^5.3",
"symfony/console": "^4.4 || ^5.3",
"symfony/dependency-injection": "^4.4 || ^5.3",
"symfony/doctrine-bridge": "^4.4 || ^5.3",
"symfony/event-dispatcher": "^4.4 || ^5.3",
"symfony/expression-language": "^4.4 || ^5.3",
"symfony/filesystem": "^4.4 || ^5.3",
"symfony/finder": "^4.4 || ^5.3",
"symfony/form": "^4.4 || ^5.3",
"symfony/framework-bundle": "^4.4 || ^5.3",
"symfony/http-foundation": "^4.4 || ^5.3",
"symfony/http-kernel": "^4.4 || ^5.3",
"symfony/intl": "^4.4 || ^5.3",
"symfony/messenger": "^4.4 || ^5.3",
"symfony/monolog-bundle": "^3.5",
"symfony/options-resolver": "^4.4 || ^5.2",
"symfony/options-resolver": "^4.4 || ^5.3",
"symfony/polyfill-iconv": "^1.17",
"symfony/polyfill-intl-icu": "^1.22",
"symfony/polyfill-mbstring": "^1.17",
"symfony/polyfill-php80": "^1.17",
"symfony/process": "^4.4 || ^5.2",
"symfony/property-access": "^4.4 || ^5.2",
"symfony/property-info": "^4.4 || ^5.2",
"symfony/proxy-manager-bridge": "^4.4 || ^5.2",
"symfony/routing": "^4.4 || ^5.2",
"symfony/security-bundle": "^4.4 || ^5.2",
"symfony/security-core": "^4.4 || ^5.2",
"symfony/security-csrf": "^4.4 || ^5.2",
"symfony/security-guard": "^4.4 || ^5.2",
"symfony/security-http": "^4.4 || ^5.2",
"symfony/serializer": "^4.4 || ^5.2",
"symfony/string": "^5.2",
"symfony/process": "^4.4 || ^5.3",
"symfony/property-access": "^4.4 || ^5.3",
"symfony/property-info": "^4.4 || ^5.3",
"symfony/proxy-manager-bridge": "^4.4 || ^5.3",
"symfony/routing": "^4.4 || ^5.3",
"symfony/security-bundle": "^4.4 || ^5.3",
"symfony/security-core": "^4.4 || ^5.3",
"symfony/security-csrf": "^4.4 || ^5.3",
"symfony/security-guard": "^4.4 || ^5.3",
"symfony/security-http": "^4.4 || ^5.3",
"symfony/serializer": "^4.4 || ^5.3",
"symfony/string": "^5.3",
"symfony/swiftmailer-bundle": "^3.4",
"symfony/templating": "^4.4 || ^5.2",
"symfony/templating": "^4.4 || ^5.3",
"symfony/thanks": "^1.2",
"symfony/translation": "^4.4 || ^5.2",
"symfony/twig-bundle": "^4.4 || ^5.2",
"symfony/validator": "^4.4 || ^5.2",
"symfony/yaml": "^4.4 || ^5.2",
"symfony/translation": "^4.4 || ^5.3",
"symfony/twig-bundle": "^4.4 || ^5.3",
"symfony/validator": "^4.4 || ^5.3",
"symfony/yaml": "^4.4 || ^5.3",
"twig/intl-extra": "^2.12",
"twig/twig": "^2.12",
"webmozart/assert": "^1.9",
Expand Down Expand Up @@ -191,16 +190,17 @@
"phpstan/phpstan": "0.12.96",
"phpstan/phpstan-doctrine": "0.12.33",
"phpunit/phpunit": "^8.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"psalm/plugin-mockery": "0.7.0",
"psr/event-dispatcher": "^1.0",
"rector/rector": "^0.11.52",
"stripe/stripe-php": "^6.43",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
"symfony/browser-kit": "^4.4 || ^5.3",
"symfony/debug-bundle": "^4.4 || ^5.3",
"symfony/dotenv": "^4.4 || ^5.3",
"symfony/flex": "^1.7",
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"symfony/web-profiler-bundle": "^4.4 || ^5.3",
"vimeo/psalm": "4.7.2"
},
"suggest": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ Feature: Viewing a product details using permalink

Background:
Given the store operates on a single channel in "United States"
And the store has a product "T-shirt banana"

@ui
@ui @no-api
Scenario: Accessing a detailed product page using permalink
Given the store has a product "T-shirt banana"
When I open page "en_US/products/t-shirt-banana"
Then I should be on "T-shirt banana" product detailed page
And I should see the product name "T-shirt banana"

@api
Scenario: Viewing a detailed page with product's slug
When I view product "T-shirt banana" using slug
Then I should be redirected to "T-shirt banana" product
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@applying_catalog_promotions
Feature: Applying catalog promotion with proper priorities
In order to be attracted to products
As a Visitor
I want to see discounted products in the catalog

Background:
Given the store operates on a single channel in "United States"
And the store has a "T-Shirt" configurable product
And this product has "PHP T-Shirt" variant priced at "$100.00"
And there is a catalog promotion "Clothes sale" with priority 10 that reduces price by "30%" and applies on "PHP T-Shirt" variant
And there is a catalog promotion "Winter sale" with priority 100 that reduces price by "50%" and applies on "PHP T-Shirt" variant

@api @ui
Scenario: Applying catalog promotion with descending order by their priority
When I view "PHP T-Shirt" variant of the "T-Shirt" product
Then I should see this variant is discounted from "$100.00" to "$35.00" with "Winter sale" and "Clothes sale" promotions
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Feature: Browsing catalog promotions
Given the store operates on a single channel in "United States"
And there are catalog promotions named "Summer sale" and "Winter sale"
And the catalog promotion "Winter sale" operates between "2021-11-10" and "2022-01-08"
And its priority is 100
And I am logged in as an administrator

@api @ui
Expand All @@ -16,3 +17,4 @@ Feature: Browsing catalog promotions
Then there should be 2 catalog promotions on the list
And the catalog promotions named "Summer sale" and "Winter sale" should be in the registry
And the catalog promotion named "Winter sale" should operate between "2021-11-10" and "2022-01-08"
And it should have priority equal to 100
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,14 @@ Feature: Creating a catalog promotion
And "Winter sale" catalog promotion should apply to "PHP T-Shirt" variant and "Kotlin T-Shirt" variant
And it should operate between yesterday and tomorrow
And it should be active

@api @ui
Scenario: Creating a simple catalog promotion with code, name and priority
When I want to create a new catalog promotion
And I specify its code as "winter_sale"
And I name it "Winter sale"
And I set its priority to 10
And I add it
Then there should be 1 new catalog promotion on the list
And it should have "winter_sale" code and "Winter sale" name
And it should have priority equal to 10
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@managing_catalog_promotions
Feature: Browsing catalog promotions
Feature: Seeing catalog promotion's details
In order to have an overview of one of defined catalog promotions
As an Administrator
I want to be able to see its details
Expand All @@ -11,6 +11,7 @@ Feature: Browsing catalog promotions
And there is a catalog promotion "Winter sale" available in "Web-US" channel that reduces price by "30%" and applies on "PHP T-shirt" variant
And it applies also on "T-Shirt" product
And the catalog promotion "Winter sale" operates between "2021-11-10" and "2022-01-08"
And its priority is 1200
And I am logged in as an administrator

@api @ui
Expand All @@ -21,3 +22,4 @@ Feature: Browsing catalog promotions
And it should apply on "PHP T-Shirt" variant
And it should apply on "T-Shirt" product
And it should start at "2021-11-10" and end at "2022-01-08"
And its priority should be 1200
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ Feature: Validating a catalog promotion creation
And I try to add it
Then I should be notified that I can add only existing taxon
And there should be an empty list of catalog promotions
And there should be an empty list of catalog promotions

@api @ui @javascript
Scenario: Trying to create a catalog promotion with product type without products
Expand All @@ -161,4 +160,3 @@ Feature: Validating a catalog promotion creation
And I add catalog promotion scope for product with nonexistent products
And I try to add it
Then I should be notified that I can add only existing product
And there should be an empty list of catalog promotions
2 changes: 1 addition & 1 deletion src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function configureRoutes(RouteCollectionBuilder $routes): void

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment()) {
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
return MockerContainer::class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ public function iSpecifyItsAs(string $field, string $value): void
$this->client->addRequestData($field, $value);
}

/**
* @When I set its priority to :priority
*/
public function iSetsItsPriorityTo(int $priority): void
{
$this->client->addRequestData('priority', $priority);
}

/**
* @When I specify its :field as :value in :localeCode
*/
Expand Down Expand Up @@ -725,6 +733,17 @@ public function itShouldHaveCodeAndName(string $code, string $name): void
);
}

/**
* @Then it should have priority equal to :priority
*/
public function itShouldHavePriorityEqualTo(int $priority): void
{
Assert::true(
$this->responseChecker->hasItemWithValues($this->client->index(), ['priority' => $priority]),
sprintf('Cannot find catalog promotions with priority "%d"', $priority)
);
}

/**
* @Then the catalog promotions named :firstName and :secondName should be in the registry
*/
Expand Down Expand Up @@ -798,6 +817,17 @@ public function itShouldBe(CatalogPromotionInterface $catalogPromotion, string $
));
}

/**
* @Then /^(its) priority should be ([^"]+)$/
*/
public function itPriorityShouldBe(CatalogPromotionInterface $catalogPromotion, int $priority): void
{
Assert::true($this->responseChecker->hasItemWithValues(
$this->client->getLastResponse(),
['priority' => $priority]
));
}

/**
* @Then /^(this catalog promotion) should(?:| still) be (inactive|active)$/
*/
Expand Down
20 changes: 20 additions & 0 deletions src/Sylius/Behat/Context/Api/Shop/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ public function iOpenProductPage(ProductInterface $product): void
$this->sharedStorage->set('product_variant', $productVariant);
}

/**
* @When I view product :product using slug
*/
public function iViewProductUsingSlug(ProductInterface $product): void
{
$this->client->showByIri('/api/v2/shop/products-by-slug/'.$product->getSlug());

$this->sharedStorage->set('product', $product);
}

/**
* @Then I should be redirected to :product product
*/
public function iShouldBeRedirectedToProduct(ProductInterface $product): void
{
$response = $this->client->getLastResponse();

Assert::eq($response->headers->get('Location'), '/api/v2/shop/products/'.$product->getCode());
}

/**
* @When I browse products from taxon :taxon
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Context/Api/Shop/ProductVariantContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function theProductOriginalPriceShouldBe(int $originalPrice): void
* @Then /^I should see (this variant) is discounted from ("[^"]+") to ("[^"]+") with "([^"]+)" and "([^"]+)" promotions$/
* @Then /^I should see (this variant) is discounted from ("[^"]+") to ("[^"]+") with "([^"]+)", "([^"]+)" and "([^"]+)" promotions$/
*/
public function iShouldSeeVariantIsDiscountedFromToWithPromotion(
public function iShouldSeeVariantIsDiscountedFromToWithPromotions(
ProductVariantInterface $variant,
int $originalPrice,
int $price,
Expand All @@ -120,7 +120,7 @@ public function theVisitorShouldSeeThatTheVariantIsDiscountedWithPromotion(
$this->sharedStorage->set('token', null);
$this->client->show($productVariant->getCode());

$this->iShouldSeeVariantIsDiscountedFromToWithPromotion($productVariant, $originalPrice, $price, $promotionName);
$this->iShouldSeeVariantIsDiscountedFromToWithPromotions($productVariant, $originalPrice, $price, $promotionName);
}

/**
Expand Down
Loading

0 comments on commit 03d2c26

Please sign in to comment.