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"
|
||||
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
|
||||
Given the store classifies its products as "T-Shirts"
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ final class ProductContext implements Context
|
|||
*/
|
||||
public function storeHasAProductPricedAtBelongingToTheTaxon(
|
||||
string $productName,
|
||||
int $price = 100,
|
||||
int $price,
|
||||
TaxonInterface $taxon,
|
||||
): void {
|
||||
$product = $this->createProduct($productName, $price);
|
||||
|
|
@ -98,6 +98,20 @@ final class ProductContext implements Context
|
|||
$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
|
||||
*/
|
||||
|
|
@ -1293,12 +1307,7 @@ final class ProductContext implements Context
|
|||
return (int) round((float) str_replace(['€', '£', '$'], '', $price) * 100, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $productName
|
||||
*
|
||||
* @return ProductInterface
|
||||
*/
|
||||
private function createProduct($productName, int $price = 100, ChannelInterface $channel = null)
|
||||
private function createProduct(string $productName, int $price = 100, ChannelInterface $channel = null): ProductInterface
|
||||
{
|
||||
if (null === $channel && $this->sharedStorage->has('channel')) {
|
||||
$channel = $this->sharedStorage->get('channel');
|
||||
|
|
|
|||
|
|
@ -122,12 +122,7 @@ final class TaxonomyContext implements Context
|
|||
$this->objectManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return TaxonInterface
|
||||
*/
|
||||
private function createTaxon($name)
|
||||
private function createTaxon(string $name): TaxonInterface
|
||||
{
|
||||
/** @var TaxonInterface $taxon */
|
||||
$taxon = $this->taxonFactory->createNew();
|
||||
|
|
|
|||
|
|
@ -8,12 +8,17 @@ default:
|
|||
- sylius.behat.context.hook.doctrine_orm
|
||||
|
||||
- sylius.behat.context.transform.channel
|
||||
- sylius.behat.context.transform.product
|
||||
- sylius.behat.context.transform.shared_storage
|
||||
- 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.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
|
||||
filters:
|
||||
tags: "@managing_taxons&&@api"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue