-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Simple product creation barcode duplication behat test
- Loading branch information
1 parent
b75e974
commit 45ae1bd
Showing
6 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@managing_product_barcodes | ||
Feature: Adding a new product with duplicated barcode | ||
In order to prevent barcode duplicates | ||
As an Administrator | ||
I want to see validation error when trying to add product with non-unique barcode | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has "Standard" shipping category | ||
And the store has a product "Stabilo Point 88-57 Azure" | ||
And this product has barcode "4006381333931" | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Adding a new simple product with barcode | ||
Given I want to create a new simple product | ||
When I specify its code as "BOARD_DICE_BREWING" | ||
And I name it "Dice Brewing" in "English (United States)" | ||
And I set its slug to "dice-brewing" in "English (United States)" | ||
And I set its price to "$10.00" for "United States" channel | ||
And I set its barcode to "4006381333931" | ||
And I try to add it | ||
Then I should be notified that product with this barcode already exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Loevgaard\SyliusBarcodePlugin\Behat\Context\Setup; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Loevgaard\SyliusBarcodePlugin\Model\ProductVariantInterface; | ||
use Sylius\Component\Core\Model\ProductInterface; | ||
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface; | ||
|
||
final class ProductContext implements Context | ||
{ | ||
/** @var ObjectManager */ | ||
private $objectManager; | ||
|
||
/** @var ProductVariantResolverInterface */ | ||
private $defaultVariantResolver; | ||
|
||
public function __construct( | ||
ObjectManager $objectManager, | ||
ProductVariantResolverInterface $defaultVariantResolver | ||
) { | ||
$this->objectManager = $objectManager; | ||
$this->defaultVariantResolver = $defaultVariantResolver; | ||
} | ||
|
||
/** | ||
* @Given :product has barcode :barcode | ||
* @Given /^(this product) has barcode "([^"]+)"$/ | ||
* @Given :product has no barcode | ||
* @Given /^(this product) has no barcode$/ | ||
*/ | ||
public function productHasBarcode(ProductInterface $product, ?string $barcode = null) | ||
{ | ||
/** @var ProductVariantInterface $productVariant */ | ||
$productVariant = $this->defaultVariantResolver->getVariant($product); | ||
$productVariant->setBarcode($barcode); | ||
|
||
$this->objectManager->flush(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters