Completed
Push — master ( 0729b3...dbaae6 )
by Kamil
18:26
created

ProductAssociationContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 1 Features 2
Metric Value
wmc 4
c 4
b 1
f 2
lcom 0
cbo 3
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A iCreateAssociationType() 0 6 1
A thereAreFollowingAssociationTypes() 0 10 2
A iWantToCreateNewAssociationType() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\ProductBundle\Behat;
13
14
use Behat\Gherkin\Node\TableNode;
15
use Sylius\Bundle\ResourceBundle\Behat\DefaultContext;
16
use Sylius\Component\Association\Model\AssociationType;
17
18
/**
19
 * @author Leszek Prabucki <[email protected]>
20
 */
21
class ProductAssociationContext extends DefaultContext
22
{
23
    /**
24
     * @When I create :typeName association type with :code code
25
     */
26
    public function iCreateAssociationType($typeName, $code)
27
    {
28
        $this->fillField('Name', $code);
29
        $this->fillField('Code', $typeName);
30
        $this->pressButton('Create');
31
    }
32
33
    /**
34
     * @Given there are following association types:
35
     */
36
    public function thereAreFollowingAssociationTypes(TableNode $table)
37
    {
38
        foreach ($table->getHash() as $row) {
39
            $associationType = $this->getService('sylius.factory.product_association_type')->createNew();
40
            $associationType->setName($row['name']);
41
            $associationType->setCode($row['code']);
42
            $this->getEntityManager()->persist($associationType);
43
        }
44
        $this->getEntityManager()->flush();
45
    }
46
47
    /**
48
     * @Given I want to create new association type
49
     */
50
    public function iWantToCreateNewAssociationType()
51
    {
52
        $this->iAmOnThePage('product association type creation');
53
    }
54
}
55