Completed
Pull Request — master (#25)
by Kamil
03:01
created

theStoreHasProductBlockWithProduct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace Lakion\SyliusCmsBundle\Tests\Behat\Context\Setup;
4
5
use Behat\Behat\Context\Context;
6
use Doctrine\Common\Persistence\ObjectManager;
7
use Sylius\Behat\Service\SharedStorageInterface;
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 View Code Duplication
    public function theStoreHasProductBlock($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 View Code Duplication
    public function theStoreHasProductBlockWithField($name, $field, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 View Code Duplication
    public function theStoreHasProductBlockWithProduct($name, ProductInterface $product)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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