Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PromoForm.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Mtf\Client\Locator;
11 use Magento\Mtf\Fixture\FixtureInterface;
12 use Magento\Mtf\Client\Element\SimpleElement;
14 
18 class PromoForm extends FormSections
19 {
25  private $templateBlockSelector = './ancestor::body';
26 
35  public function fill(FixtureInterface $fixture, SimpleElement $element = null, array $replace = null)
36  {
37  $this->waitPageToLoad();
38  $sections = $this->getFixtureFieldsByContainers($fixture);
39  if ($replace) {
40  $sections = $this->prepareData($sections, $replace);
41  }
42  return $this->fillContainers($sections, $element);
43  }
44 
52  protected function prepareData(array $tabs, array $replace)
53  {
54  foreach ($replace as $tabName => $fields) {
55  foreach ($fields as $key => $pairs) {
56  if (isset($tabs[$tabName][$key])) {
57  $tabs[$tabName][$key]['value'] = str_replace(
58  array_keys($pairs),
59  array_values($pairs),
60  $tabs[$tabName][$key]['value']
61  );
62  }
63  }
64  }
65 
66  return $tabs;
67  }
68 
74  protected function waitPageToLoad()
75  {
76  $this->waitForElementVisible($this->header);
77  $this->getTemplateBlock()->waitLoader();
78  }
79 
85  private function getTemplateBlock()
86  {
87  return $this->blockFactory->create(
88  Template::class,
89  ['element' => $this->_rootElement->find($this->templateBlockSelector, Locator::SELECTOR_XPATH)]
90  );
91  }
92 }
fill(FixtureInterface $fixture, SimpleElement $element=null, array $replace=null)
Definition: PromoForm.php:35
$fields
Definition: details.phtml:14
$element
Definition: element.phtml:12