mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Behat][API] Add step implementation for not seeing disabled variants
This commit is contained in:
parent
41274eb8d7
commit
debb53d38f
4 changed files with 34 additions and 5 deletions
|
|
@ -114,6 +114,13 @@ final class Request implements RequestInterface
|
|||
private function mergeArraysUniquely(array $firstArray, array $secondArray): array
|
||||
{
|
||||
foreach ($secondArray as $key => $value) {
|
||||
if (is_string($key) && str_ends_with($key, '[]')) {
|
||||
$key = substr($key, 0, -2);
|
||||
$firstArray[$key][] = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($value) && is_array(@$firstArray[$key])) {
|
||||
$value = $this->mergeArraysUniquely($firstArray[$key], $value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -579,6 +579,18 @@ final class ProductContext implements Context
|
|||
Assert::false($this->hasProductOptionWithNameAndValue($optionName, $optionValueValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^I should be able to select the "([^"]+)" and "([^"]+)" ([^\s]+) option values$/
|
||||
*/
|
||||
public function iShouldBeAbleToSelectTheAndColorOptionValues(
|
||||
string $optionValueValue1,
|
||||
string $optionValueValue2,
|
||||
string $optionName,
|
||||
): void {
|
||||
Assert::true($this->hasProductOptionWithNameAndValue($optionName, $optionValueValue1));
|
||||
Assert::true($this->hasProductOptionWithNameAndValue($optionName, $optionValueValue2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be able to select between :count variants
|
||||
*/
|
||||
|
|
@ -741,12 +753,10 @@ final class ProductContext implements Context
|
|||
|
||||
private function hasProductOptionWithNameAndValue(string $expectedOptionName, string $expectedOptionValueValue): bool
|
||||
{
|
||||
$response = $this->client->getLastResponse();
|
||||
|
||||
$productVariants = $this->responseChecker->getCollection(
|
||||
$this->client->index(
|
||||
Resources::PRODUCT_VARIANTS,
|
||||
['product' => $this->responseChecker->getValue($response, '@id')],
|
||||
['product' => $this->iriConverter->getIriFromItem($this->sharedStorage->get('product'))],
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,11 +75,11 @@ final class ProductVariantContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @When /^I filter variants by ("[^"]+" option value)$/
|
||||
* @When /^I filter (?:them|variants) by ("[^"]+" option value)$/
|
||||
*/
|
||||
public function iFilterVariantsByOption(ProductOptionValueInterface $optionValue): void
|
||||
{
|
||||
$this->client->addFilter('optionValues', $this->iriConverter->getIriFromItem($optionValue));
|
||||
$this->client->addFilter('optionValues[]', $this->iriConverter->getIriFromItem($optionValue));
|
||||
$response = $this->client->filter();
|
||||
|
||||
$this->sharedStorage->set('product_variant_collection', $this->responseChecker->getCollection($response));
|
||||
|
|
@ -350,6 +350,17 @@ final class ProductVariantContext implements Context
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should not see any variants
|
||||
*/
|
||||
public function iShouldNotSeeAnyVariants(): void
|
||||
{
|
||||
Assert::same(
|
||||
count($this->sharedStorage->get('product_variant_collection')),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
private function findVariant(?ProductVariantInterface $variant): array
|
||||
{
|
||||
$response = $this->sharedStorage->has('response') ? $this->sharedStorage->get('response') : $this->client->getLastResponse();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ default:
|
|||
- sylius.behat.context.transform.locale
|
||||
- sylius.behat.context.transform.product
|
||||
- sylius.behat.context.transform.product_association_type
|
||||
- sylius.behat.context.transform.product_option_value
|
||||
- sylius.behat.context.transform.product_variant
|
||||
- sylius.behat.context.transform.shared_storage
|
||||
- sylius.behat.context.transform.taxon
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue