| @@ 11-81 (lines=71) @@ | ||
| 8 | use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; |
|
| 9 | use Sylius\Component\Core\Model\ProductInterface; |
|
| 10 | ||
| 11 | final class ProductBlockContext implements Context |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @var SharedStorageInterface |
|
| 15 | */ |
|
| 16 | private $sharedStorage; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var ExampleFactoryInterface |
|
| 20 | */ |
|
| 21 | private $productBlockExampleFactory; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var ObjectManager |
|
| 25 | */ |
|
| 26 | private $productBlockManager; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @param SharedStorageInterface $sharedStorage |
|
| 30 | * @param ExampleFactoryInterface $productBlockExampleFactory |
|
| 31 | * @param ObjectManager $productBlockManager |
|
| 32 | */ |
|
| 33 | public function __construct( |
|
| 34 | SharedStorageInterface $sharedStorage, |
|
| 35 | ExampleFactoryInterface $productBlockExampleFactory, |
|
| 36 | ObjectManager $productBlockManager |
|
| 37 | ) { |
|
| 38 | $this->sharedStorage = $sharedStorage; |
|
| 39 | $this->productBlockExampleFactory = $productBlockExampleFactory; |
|
| 40 | $this->productBlockManager = $productBlockManager; |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @Given the store has product block :name |
|
| 45 | */ |
|
| 46 | public function theStoreHasProductBlock($name) |
|
| 47 | { |
|
| 48 | $productBlock = $this->productBlockExampleFactory->create(['name' => $name]); |
|
| 49 | ||
| 50 | $this->productBlockManager->persist($productBlock); |
|
| 51 | $this->productBlockManager->flush(); |
|
| 52 | ||
| 53 | $this->sharedStorage->set('product_block', $productBlock); |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @Given /^the store has product block "([^"]+)" with (body|title|link) "([^"]+)"$/ |
|
| 58 | */ |
|
| 59 | public function theStoreHasProductBlockWithField($name, $field, $value) |
|
| 60 | { |
|
| 61 | $productBlock = $this->productBlockExampleFactory->create(['name' => $name, $field => $value]); |
|
| 62 | ||
| 63 | $this->productBlockManager->persist($productBlock); |
|
| 64 | $this->productBlockManager->flush(); |
|
| 65 | ||
| 66 | $this->sharedStorage->set('product_block', $productBlock); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @Given /^the store has product block "([^"]+)" with (product "[^"]+")$/ |
|
| 71 | */ |
|
| 72 | public function theStoreHasProductBlockWithProduct($name, ProductInterface $product) |
|
| 73 | { |
|
| 74 | $productBlock = $this->productBlockExampleFactory->create(['name' => $name, 'product' => $product]); |
|
| 75 | ||
| 76 | $this->productBlockManager->persist($productBlock); |
|
| 77 | $this->productBlockManager->flush(); |
|
| 78 | ||
| 79 | $this->sharedStorage->set('product_block', $productBlock); |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| @@ 11-81 (lines=71) @@ | ||
| 8 | use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; |
|
| 9 | use Sylius\Component\Core\Model\TaxonInterface; |
|
| 10 | ||
| 11 | final class TaxonBlockContext implements Context |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * @var SharedStorageInterface |
|
| 15 | */ |
|
| 16 | private $sharedStorage; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var ExampleFactoryInterface |
|
| 20 | */ |
|
| 21 | private $taxonBlockExampleFactory; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @var ObjectManager |
|
| 25 | */ |
|
| 26 | private $taxonBlockManager; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @param SharedStorageInterface $sharedStorage |
|
| 30 | * @param ExampleFactoryInterface $taxonBlockExampleFactory |
|
| 31 | * @param ObjectManager $taxonBlockManager |
|
| 32 | */ |
|
| 33 | public function __construct( |
|
| 34 | SharedStorageInterface $sharedStorage, |
|
| 35 | ExampleFactoryInterface $taxonBlockExampleFactory, |
|
| 36 | ObjectManager $taxonBlockManager |
|
| 37 | ) { |
|
| 38 | $this->sharedStorage = $sharedStorage; |
|
| 39 | $this->taxonBlockExampleFactory = $taxonBlockExampleFactory; |
|
| 40 | $this->taxonBlockManager = $taxonBlockManager; |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @Given the store has taxon block :name |
|
| 45 | */ |
|
| 46 | public function theStoreHasTaxonBlock($name) |
|
| 47 | { |
|
| 48 | $taxonBlock = $this->taxonBlockExampleFactory->create(['name' => $name]); |
|
| 49 | ||
| 50 | $this->taxonBlockManager->persist($taxonBlock); |
|
| 51 | $this->taxonBlockManager->flush(); |
|
| 52 | ||
| 53 | $this->sharedStorage->set('taxon_block', $taxonBlock); |
|
| 54 | } |
|
| 55 | ||
| 56 | /** |
|
| 57 | * @Given /^the store has taxon block "([^"]+)" with (body|title|link) "([^"]+)"$/ |
|
| 58 | */ |
|
| 59 | public function theStoreHasTaxonBlockWithField($name, $field, $value) |
|
| 60 | { |
|
| 61 | $taxonBlock = $this->taxonBlockExampleFactory->create(['name' => $name, $field => $value]); |
|
| 62 | ||
| 63 | $this->taxonBlockManager->persist($taxonBlock); |
|
| 64 | $this->taxonBlockManager->flush(); |
|
| 65 | ||
| 66 | $this->sharedStorage->set('taxon_block', $taxonBlock); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @Given /^the store has taxon block "([^"]+)" with (taxon "[^"]+")$/ |
|
| 71 | */ |
|
| 72 | public function theStoreHasTaxonBlockWithTaxon($name, TaxonInterface $taxon) |
|
| 73 | { |
|
| 74 | $taxonBlock = $this->taxonBlockExampleFactory->create(['name' => $name, 'taxon' => $taxon]); |
|
| 75 | ||
| 76 | $this->taxonBlockManager->persist($taxonBlock); |
|
| 77 | $this->taxonBlockManager->flush(); |
|
| 78 | ||
| 79 | $this->sharedStorage->set('taxon_block', $taxonBlock); |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||