Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AttributeForm.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Mtf\Client\Element\SimpleElement;
13 use Magento\Mtf\Fixture\FixtureInterface;
14 use Magento\Mtf\Fixture\InjectableFixture;
15 
19 class AttributeForm extends FormTabs
20 {
26  protected $closedToggle = '.admin__collapsible-block-wrapper:not(.opened) [data-toggle="collapse"]';
27 
33  protected $propertiesTab = '#product_attribute_tabs_main';
34 
40  protected $pageTitle = '.page-title';
41 
53  public function getData(FixtureInterface $fixture = null, SimpleElement $element = null)
54  {
55  $this->waitForElementVisible($this->propertiesTab);
56  $data = [];
57  if (null === $fixture) {
58  foreach ($this->getTabs() as $tabName => $tab) {
59  if ($this->isTabVisible($tabName)) {
60  $this->openTab($tabName);
61  $this->expandAllToggles();
62  $tabData = $this->getTab($tabName)->getFieldsData();
63  $data = array_merge($data, $tabData);
64  }
65  }
66  } else {
67  $isHasData = ($fixture instanceof InjectableFixture) ? $fixture->hasData() : true;
68  $tabsFields = $isHasData ? $this->getFixtureFieldsByContainers($fixture) : [];
69  foreach ($tabsFields as $tabName => $fields) {
70  if ($this->isTabVisible($tabName)) {
71  $this->openTab($tabName);
72  $this->expandAllToggles();
73  $tabData = $this->getTab($tabName)->getFieldsData($fields, $this->_rootElement);
74  $data = array_merge($data, $tabData);
75  }
76  }
77  }
78 
79  return $this->removeEmptyValues($data);
80  }
81 
88  protected function removeEmptyValues($input)
89  {
90  if (!is_array($input)) {
91  return $input;
92  }
93  $filteredArray = [];
94  foreach ($input as $key => $value) {
95  if ($value) {
96  $filteredArray[$key] = $this->removeEmptyValues($value);
97  }
98  }
99 
100  return $filteredArray;
101  }
102 
108  protected function expandAllToggles()
109  {
110  $closedToggles = $this->_rootElement->getElements($this->closedToggle);
111  foreach ($closedToggles as $toggle) {
112  $toggle->click();
113  }
114  }
115 
122  public function openTab($tabName)
123  {
124  $this->browser->find($this->pageTitle)->click(); // Handle menu overlap problem
125  return parent::openTab($tabName);
126  }
127 }
$fields
Definition: details.phtml:14
$value
Definition: gender.phtml:16
getData(FixtureInterface $fixture=null, SimpleElement $element=null)
$element
Definition: element.phtml:12