Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OptionTier.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Mtf\Client\Element\SimpleElement;
11 use Magento\Mtf\Client\Locator;
12 
17 {
23  protected $buttonFormLocator = '[data-action="add_new_row"]';
24 
30  protected $customerGroup = '//*[contains(@name, "[cust_group]")]';
31 
37  private $tierPriceRows = ".//*[@data-index='tier_price']/tbody/tr";
38 
46  public function fillOptions(array $fields, SimpleElement $element = null)
47  {
48  foreach ($fields['value'] as $key => $option) {
49  $this->_rootElement->find($this->buttonFormLocator)->click();
50  ++$key;
51  parent::fillOptions($option, $element->find('tbody tr:nth-child(' . $key . ')'));
52  }
53 
54  return $this;
55  }
56 
64  public function getDataOptions(array $fields = null, SimpleElement $element = null)
65  {
66  $data = [];
67  if (isset($fields['value']) && is_array($fields['value'])) {
68  foreach ($fields['value'] as $key => $option) {
69  $data[$key++] = parent::getDataOptions($option, $element->find('tbody tr:nth-child(' . $key . ')'));
70  }
71  }
72 
73  return $data;
74  }
75 
84  public function getFieldsData($fields = null, SimpleElement $element = null)
85  {
86  $fieldsData = [];
87  $rows = $this->_rootElement->getElements($this->tierPriceRows, Locator::SELECTOR_XPATH);
88 
89  if (null !== $rows) {
90  foreach ($rows as $row) {
91  $data = $this->dataMapping($fields);
92  if ($row->find($data['value_type']['selector'])->getValue() == "fixed") {
93  unset($data['percentage_value']);
94  }
95  $fieldsData[] = $this->_getData($data, $row);
96  }
97  }
98 
99  return $fieldsData;
100  }
101 
108  public function isVisibleCustomerGroup(CustomerGroup $customerGroup)
109  {
110  $this->_rootElement->find($this->buttonFormLocator)->click();
111 
112  $options = $this->_rootElement->find($this->customerGroup, Locator::SELECTOR_XPATH)->getText();
113  return false !== strpos($options, $customerGroup->getCustomerGroupCode());
114  }
115 
121  public function hasGroupPriceOptions()
122  {
123  return $this->_rootElement->find('tbody tr')->isPresent();
124  }
125 
131  public function waitTierPriceFormLocks()
132  {
133  $this->_rootElement->waitUntil(
134  function () {
135  return $this->isVisible() ? null : true;
136  }
137  );
138  }
139 }
$fields
Definition: details.phtml:14
$element
Definition: element.phtml:12