Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variant without options values generation #10242

Merged
merged 7 commits into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add new steps in context
  • Loading branch information
Tomanhez committed Mar 27, 2019
commit b8b478f024cc04dc8a4089cfcf10a734e9496f89
22 changes: 22 additions & 0 deletions src/Sylius/Behat/Context/Setup/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,26 @@ public function thisProductHasOptionWithValues(ProductInterface $product, $optio
$this->objectManager->flush();
}

/**
* @Given /^(this product) has option "([^"]+)" without values$/
Tomanhez marked this conversation as resolved.
Show resolved Hide resolved
*/
public function thisProductHasOptionWithoutValues(ProductInterface $product, string $optionName): void
{
/** @var ProductOptionInterface $option */
$option = $this->productOptionFactory->createNew();

$option->setName($optionName);
$option->setCode(StringInflector::nameToUppercaseCode($optionName));

$this->sharedStorage->set(sprintf('%s_option', $optionName), $option);

$product->addOption($option);
$product->setVariantSelectionMethod(ProductInterface::VARIANT_SELECTION_MATCH);

$this->objectManager->persist($option);
$this->objectManager->flush();
}

/**
* @Given /^there (?:is|are) (\d+) unit(?:|s) of (product "([^"]+)") available in the inventory$/
*/
Expand Down Expand Up @@ -923,4 +943,6 @@ private function createChannelPricingForChannel(int $price, ChannelInterface $ch

return $channelPricing;
}


Tomanhez marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public function theProductVariantShouldNotAppearInTheShop($productVariantCode, P

/**
* @Then the :product product should have no variants
* @Given (this product) should have no variants
Tomanhez marked this conversation as resolved.
Show resolved Hide resolved

Tomanhez marked this conversation as resolved.
Show resolved Hide resolved
*/
public function theProductShouldHaveNoVariants(ProductInterface $product)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,17 @@ public function iShouldBeNotifiedThatPricesInAllChannelsMustBeDefined()
);
}

/**
* @Then I should be notified that it has been impossible generate
*/
public function iShouldBeNotifiedThatItHasBeenImpossibleGenerate(): void
Tomanhez marked this conversation as resolved.
Show resolved Hide resolved
{
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);

Assert::same($currentPage->getValidationMessageForForm(), 'Variant without options can not exist');
Tomanhez marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @When I save my changes
* @When I try to save my changes
Expand Down