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\Behat\Page\Admin\ProductAttribute; |
13
|
|
|
|
14
|
|
|
use Sylius\Behat\Behaviour\SpecifiesItsCode; |
15
|
|
|
use Sylius\Behat\Page\Admin\Crud\CreatePage as BaseCreatePage; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Anna Walasek <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class CreatePage extends BaseCreatePage implements CreatePageInterface |
21
|
|
|
{ |
22
|
|
|
use SpecifiesItsCode; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var int |
26
|
|
|
*/ |
27
|
|
|
private $choiceListIndex = 0; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function nameIt($name, $language) |
33
|
|
|
{ |
34
|
|
|
$this->getDocument()->fillField(sprintf('sylius_product_attribute_translations_%s_name', $language), $name); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public function isTypeDisabled() |
41
|
|
|
{ |
42
|
|
|
return 'disabled' === $this->getElement('type')->getAttribute('disabled'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
|
|
public function addAttributeValue($value) |
49
|
|
|
{ |
50
|
|
|
$this->getDocument()->clickLink('Add'); |
51
|
|
|
$this->getElement('attribute_choice_list_element', ['%index%' => $this->choiceListIndex])->setValue($value); |
52
|
|
|
$this->choiceListIndex++; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
protected function getDefinedElements() |
59
|
|
|
{ |
60
|
|
|
return array_merge(parent::getDefinedElements(), [ |
61
|
|
|
'attribute_choice_list' => 'div[data-form-collection="list"]', |
62
|
|
|
'attribute_choice_list_element' => '#sylius_product_attribute_configuration_choices_%index%', |
63
|
|
|
'code' => '#sylius_product_attribute_code', |
64
|
|
|
'name' => '#sylius_product_attribute_translations_en_US_name', |
65
|
|
|
'type' => '#sylius_product_attribute_type', |
66
|
|
|
]); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|