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
|
|
|
|