mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[API][Behat][Taxon] Add step implementation
This commit is contained in:
parent
9eb7a3134a
commit
cc137a567c
5 changed files with 33 additions and 16 deletions
|
|
@ -32,7 +32,7 @@ Feature: Deleting a taxon
|
||||||
When I try to delete taxon named "Caps"
|
When I try to delete taxon named "Caps"
|
||||||
Then I should be notified that I cannot delete a menu taxon of any channel
|
Then I should be notified that I cannot delete a menu taxon of any channel
|
||||||
|
|
||||||
@todo
|
@api
|
||||||
Scenario: Deleting a taxon that is a main taxon of a product
|
Scenario: Deleting a taxon that is a main taxon of a product
|
||||||
Given the store classifies its products as "T-Shirts"
|
Given the store classifies its products as "T-Shirts"
|
||||||
And the store has a product "T-Shirts PHP"
|
And the store has a product "T-Shirts PHP"
|
||||||
|
|
|
||||||
|
|
@ -362,6 +362,14 @@ final class ManagingProductsContext implements Context
|
||||||
Assert::same($mainTaxon, $this->iriConverter->getIriFromItem($taxon));
|
Assert::same($mainTaxon, $this->iriConverter->getIriFromItem($taxon));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then the product :product should no longer have a main taxon
|
||||||
|
*/
|
||||||
|
public function theProductShouldNoLongerHaveAMainTaxon(ProductInterface $product): void
|
||||||
|
{
|
||||||
|
Assert::null($product->getMainTaxon());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then the product :product should have the :taxon taxon
|
* @Then the product :product should have the :taxon taxon
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ final class ProductContext implements Context
|
||||||
*/
|
*/
|
||||||
public function storeHasAProductPricedAtBelongingToTheTaxon(
|
public function storeHasAProductPricedAtBelongingToTheTaxon(
|
||||||
string $productName,
|
string $productName,
|
||||||
int $price = 100,
|
int $price,
|
||||||
TaxonInterface $taxon,
|
TaxonInterface $taxon,
|
||||||
): void {
|
): void {
|
||||||
$product = $this->createProduct($productName, $price);
|
$product = $this->createProduct($productName, $price);
|
||||||
|
|
@ -98,6 +98,20 @@ final class ProductContext implements Context
|
||||||
$this->saveProduct($product);
|
$this->saveProduct($product);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^the store(?:| also) has a product "([^"]+)" belonging to the ("[^"]+" taxon)$/
|
||||||
|
* @Given /^the store(?:| also) has a product "([^"]+)" belonging to (this taxon)$/
|
||||||
|
*/
|
||||||
|
public function storeHasAProductBelongingToTheTaxon(
|
||||||
|
string $productName,
|
||||||
|
TaxonInterface $taxon,
|
||||||
|
): void {
|
||||||
|
$product = $this->createProduct($productName);
|
||||||
|
$this->productTaxonContext->itBelongsTo($product, $taxon);
|
||||||
|
|
||||||
|
$this->saveProduct($product);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given the store has :numberOfProducts products
|
* @Given the store has :numberOfProducts products
|
||||||
*/
|
*/
|
||||||
|
|
@ -1293,12 +1307,7 @@ final class ProductContext implements Context
|
||||||
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function createProduct(string $productName, int $price = 100, ChannelInterface $channel = null): ProductInterface
|
||||||
* @param string $productName
|
|
||||||
*
|
|
||||||
* @return ProductInterface
|
|
||||||
*/
|
|
||||||
private function createProduct($productName, int $price = 100, ChannelInterface $channel = null)
|
|
||||||
{
|
{
|
||||||
if (null === $channel && $this->sharedStorage->has('channel')) {
|
if (null === $channel && $this->sharedStorage->has('channel')) {
|
||||||
$channel = $this->sharedStorage->get('channel');
|
$channel = $this->sharedStorage->get('channel');
|
||||||
|
|
|
||||||
|
|
@ -122,12 +122,7 @@ final class TaxonomyContext implements Context
|
||||||
$this->objectManager->flush();
|
$this->objectManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private function createTaxon(string $name): TaxonInterface
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return TaxonInterface
|
|
||||||
*/
|
|
||||||
private function createTaxon($name)
|
|
||||||
{
|
{
|
||||||
/** @var TaxonInterface $taxon */
|
/** @var TaxonInterface $taxon */
|
||||||
$taxon = $this->taxonFactory->createNew();
|
$taxon = $this->taxonFactory->createNew();
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,17 @@ default:
|
||||||
- sylius.behat.context.hook.doctrine_orm
|
- sylius.behat.context.hook.doctrine_orm
|
||||||
|
|
||||||
- sylius.behat.context.transform.channel
|
- sylius.behat.context.transform.channel
|
||||||
|
- sylius.behat.context.transform.product
|
||||||
|
- sylius.behat.context.transform.shared_storage
|
||||||
- sylius.behat.context.transform.taxon
|
- sylius.behat.context.transform.taxon
|
||||||
|
|
||||||
- sylius.behat.context.setup.channel
|
|
||||||
- sylius.behat.context.setup.taxonomy
|
|
||||||
- sylius.behat.context.setup.admin_api_security
|
- sylius.behat.context.setup.admin_api_security
|
||||||
|
- sylius.behat.context.setup.channel
|
||||||
|
- sylius.behat.context.setup.product
|
||||||
|
- sylius.behat.context.setup.product_taxon
|
||||||
|
- sylius.behat.context.setup.taxonomy
|
||||||
|
|
||||||
|
- sylius.behat.context.api.admin.managing_products
|
||||||
- sylius.behat.context.api.admin.managing_taxons
|
- sylius.behat.context.api.admin.managing_taxons
|
||||||
filters:
|
filters:
|
||||||
tags: "@managing_taxons&&@api"
|
tags: "@managing_taxons&&@api"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue