Skip to content

Commit

Permalink
minor #14934 Cover accessing non-existing product via API scenario (j…
Browse files Browse the repository at this point in the history
…akubtobiasz)

This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT


Commits
-------

895ae9f Cover accessing non-existing product via API scenario
  • Loading branch information
Rafikooo committed Apr 14, 2023
2 parents b6c348f + 895ae9f commit e9dfe33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Accessing a product which does not exist
Background:
Given the store operates on a single channel in "United States"

@ui
@ui @api
Scenario: Accessing a product which does not exist
When I try to reach unexistent product
Then I should be informed that the product does not exist
17 changes: 17 additions & 0 deletions src/Sylius/Behat/Context/Api/Shop/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Product\Model\ProductVariantInterface;
use Symfony\Component\HttpFoundation\Request as HttpRequest;
use Symfony\Component\HttpFoundation\Response;
use Webmozart\Assert\Assert;

final class ProductContext implements Context
Expand Down Expand Up @@ -60,6 +61,14 @@ public function iViewProduct(ProductInterface $product): void
$this->sharedStorage->remove('product_attributes');
}

/**
* @When I try to reach unexistent product
*/
public function iTryToReachUnexistentProduct(): void
{
$this->client->show(Resources::PRODUCTS, 'unexistent');
}

/**
* @When I view product :product in the :localeCode locale
* @When /^I check (this product)'s details in the ("([^"]+)" locale)$/
Expand Down Expand Up @@ -631,6 +640,14 @@ public function iShouldSeeAsItsLowestPriceBeforeTheDiscount(int $lowestPriceBefo
Assert::same($variant['lowestPriceBeforeDiscount'], $lowestPriceBeforeDiscount);
}

/**
* @Then I should be informed that the product does not exist
*/
public function iShouldBeInformedThatTheProductDoesNotExist(): void
{
Assert::same($this->client->getLastResponse()->getStatusCode(), Response::HTTP_NOT_FOUND);
}

private function hasProductWithPrice(
array $products,
int $price,
Expand Down

0 comments on commit e9dfe33

Please sign in to comment.