@@ 10-67 (lines=58) @@ | ||
7 | use Sylius\Behat\Service\SharedStorageInterface; |
|
8 | use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; |
|
9 | ||
10 | final class CustomBlockContext implements Context |
|
11 | { |
|
12 | /** |
|
13 | * @var SharedStorageInterface |
|
14 | */ |
|
15 | private $sharedStorage; |
|
16 | ||
17 | /** |
|
18 | * @var ExampleFactoryInterface |
|
19 | */ |
|
20 | private $customBlockExampleFactory; |
|
21 | ||
22 | /** |
|
23 | * @var ObjectManager |
|
24 | */ |
|
25 | private $customBlockManager; |
|
26 | ||
27 | /** |
|
28 | * @param SharedStorageInterface $sharedStorage |
|
29 | * @param ExampleFactoryInterface $customBlockExampleFactory |
|
30 | * @param ObjectManager $customBlockManager |
|
31 | */ |
|
32 | public function __construct( |
|
33 | SharedStorageInterface $sharedStorage, |
|
34 | ExampleFactoryInterface $customBlockExampleFactory, |
|
35 | ObjectManager $customBlockManager |
|
36 | ) { |
|
37 | $this->sharedStorage = $sharedStorage; |
|
38 | $this->customBlockExampleFactory = $customBlockExampleFactory; |
|
39 | $this->customBlockManager = $customBlockManager; |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * @Given the store has custom block :name |
|
44 | */ |
|
45 | public function theStoreHasCustomBlock($name) |
|
46 | { |
|
47 | $customBlock = $this->customBlockExampleFactory->create(['name' => $name]); |
|
48 | ||
49 | $this->customBlockManager->persist($customBlock); |
|
50 | $this->customBlockManager->flush(); |
|
51 | ||
52 | $this->sharedStorage->set('custom_block', $customBlock); |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * @Given /^the store has custom block "([^"]+)" with (body|title|link) "([^"]+)"$/ |
|
57 | */ |
|
58 | public function theStoreHasCustomBlockWithField($name, $field, $value) |
|
59 | { |
|
60 | $customBlock = $this->customBlockExampleFactory->create(['name' => $name, $field => $value]); |
|
61 | ||
62 | $this->customBlockManager->persist($customBlock); |
|
63 | $this->customBlockManager->flush(); |
|
64 | ||
65 | $this->sharedStorage->set('custom_block', $customBlock); |
|
66 | } |
|
67 | } |
|
68 |
@@ 10-72 (lines=63) @@ | ||
7 | use Sylius\Behat\Service\SharedStorageInterface; |
|
8 | use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface; |
|
9 | ||
10 | final class StringBlockContext implements Context |
|
11 | { |
|
12 | /** |
|
13 | * @var SharedStorageInterface |
|
14 | */ |
|
15 | private $sharedStorage; |
|
16 | ||
17 | /** |
|
18 | * @var ExampleFactoryInterface |
|
19 | */ |
|
20 | private $stringBlockExampleFactory; |
|
21 | ||
22 | /** |
|
23 | * @var ObjectManager |
|
24 | */ |
|
25 | private $stringBlockManager; |
|
26 | ||
27 | /** |
|
28 | * @param SharedStorageInterface $sharedStorage |
|
29 | * @param ExampleFactoryInterface $stringBlockExampleFactory |
|
30 | * @param ObjectManager $stringBlockManager |
|
31 | */ |
|
32 | public function __construct( |
|
33 | SharedStorageInterface $sharedStorage, |
|
34 | ExampleFactoryInterface $stringBlockExampleFactory, |
|
35 | ObjectManager $stringBlockManager |
|
36 | ) { |
|
37 | $this->sharedStorage = $sharedStorage; |
|
38 | $this->stringBlockExampleFactory = $stringBlockExampleFactory; |
|
39 | $this->stringBlockManager = $stringBlockManager; |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * @Given the store has string block :name |
|
44 | */ |
|
45 | public function theStoreHasStringBlock($name) |
|
46 | { |
|
47 | $stringBlock = $this->stringBlockExampleFactory->create([ |
|
48 | 'name' => $name, |
|
49 | ]); |
|
50 | ||
51 | $this->stringBlockManager->persist($stringBlock); |
|
52 | $this->stringBlockManager->flush(); |
|
53 | ||
54 | $this->sharedStorage->set('string_block', $stringBlock); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * @Given the store has string block :name with body :body |
|
59 | */ |
|
60 | public function theStoreHasStringBlockWithBody($name, $body) |
|
61 | { |
|
62 | $stringBlock = $this->stringBlockExampleFactory->create([ |
|
63 | 'name' => $name, |
|
64 | 'body' => $body, |
|
65 | ]); |
|
66 | ||
67 | $this->stringBlockManager->persist($stringBlock); |
|
68 | $this->stringBlockManager->flush(); |
|
69 | ||
70 | $this->sharedStorage->set('string_block', $stringBlock); |
|
71 | } |
|
72 | } |
|
73 |