Skip to content

Commit 2015f5c

Browse files
author
Aponasenko, Dmytro(daponasenko)
committed
Merge pull request #334 from magento-qmt/develop
[Mavericks] Functional tests maintenance
2 parents 6ae22a2 + 341848e commit 2015f5c

File tree

74 files changed

+324
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+324
-272
lines changed

dev/tests/functional/.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
**/var
22
/composer.lock
3-
/config/*
43
/generated
54
/lib/Magento/Mtf/Util/Generate/testcase.xml
65
/vendor
7-
!/config/application.yml.dist
8-
!/config/handler.yml.dist
9-
!/config/isolation.yml.dist
10-
!/config/server.yml.dist
116
phpunit.xml
127
credentials.xml

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc25",
3+
"magento/mtf": "1.0.0-rc26",
44
"php": "~5.5.0|~5.6.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2",

dev/tests/functional/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<env name="testsuite_rule_path" value="Magento/Mtf/TestSuite/InjectableTests" />
3636
<env name="log_directory" value="var/log" />
3737
<env name="events_preset" value="base" />
38-
<env name="module_whitelist" value="Magento_Install,Magento_Core" />
38+
<env name="module_whitelist" value="Magento_Install" />
3939
<env name="basedir" value="var/log" />
4040
<env name="credentials_file_path" value="./credentials.xml.dist" />
4141
</php>

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Messages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function getSuccessMessages()
7070
$elements = $this->_rootElement->getElements($this->successMessage);
7171

7272
$messages = [];
73-
foreach ($elements as $key => $element) {
74-
$messages[$key] = $element->getText();
73+
foreach ($elements as $element) {
74+
$messages[] = $element->getText();
7575
}
7676

7777
return count($messages) > 1 ? $messages : $messages[0];

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Mtf\Block\BlockFactory;
1010
use Magento\Mtf\Block\Mapper;
1111
use Magento\Mtf\Client\Locator;
12+
use Magento\Mtf\Client\ElementInterface;
1213
use Magento\Mtf\Fixture\FixtureInterface;
1314
use Magento\Mtf\Fixture\InjectableFixture;
1415
use Magento\Mtf\Client\BrowserInterface;
@@ -84,10 +85,10 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
8485
{
8586
$context = ($element === null) ? $this->_rootElement : $element;
8687
foreach ($tabs as $tabName => $tabFields) {
87-
$tabElement = $this->getTabElement($tabName);
88+
$tab = $this->getTab($tabName);
8889
$this->openTab($tabName);
89-
$tabElement->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
90-
$this->updateUnassignedFields($tabElement);
90+
$tab->fillFormTab(array_merge($tabFields, $this->unassignedFields), $context);
91+
$this->updateUnassignedFields($tab);
9192
}
9293
if (!empty($this->unassignedFields)) {
9394
$this->fillMissedFields($tabs);
@@ -99,13 +100,13 @@ protected function fillTabs(array $tabs, SimpleElement $element = null)
99100
/**
100101
* Update array with fields which aren't assigned to any tab
101102
*
102-
* @param Tab $tabElement
103+
* @param Tab $tab
103104
*/
104-
protected function updateUnassignedFields(Tab $tabElement)
105+
protected function updateUnassignedFields(Tab $tab)
105106
{
106107
$this->unassignedFields = array_diff_key(
107108
$this->unassignedFields,
108-
array_intersect_key($this->unassignedFields, $tabElement->setFields)
109+
array_intersect_key($this->unassignedFields, $tab->setFields)
109110
);
110111
}
111112

@@ -120,10 +121,10 @@ protected function updateUnassignedFields(Tab $tabElement)
120121
protected function fillMissedFields(array $tabs)
121122
{
122123
foreach (array_diff_key($this->tabs, $tabs) as $tabName => $tabData) {
123-
$tabElement = $this->getTabElement($tabName);
124+
$tab = $this->getTab($tabName);
124125
if ($this->openTab($tabName)) {
125-
$tabElement->fillFormTab($this->unassignedFields, $this->_rootElement);
126-
$this->updateUnassignedFields($tabElement);
126+
$tab->fillFormTab($this->unassignedFields, $this->_rootElement);
127+
$this->updateUnassignedFields($tab);
127128
if (empty($this->unassignedFields)) {
128129
break;
129130
}
@@ -154,15 +155,15 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
154155
if (null === $fixture) {
155156
foreach ($this->tabs as $tabName => $tab) {
156157
$this->openTab($tabName);
157-
$tabData = $this->getTabElement($tabName)->getDataFormTab();
158+
$tabData = $this->getTab($tabName)->getDataFormTab();
158159
$data = array_merge($data, $tabData);
159160
}
160161
} else {
161162
$isHasData = ($fixture instanceof InjectableFixture) ? $fixture->hasData() : true;
162163
$tabsFields = $isHasData ? $this->getFieldsByTabs($fixture) : [];
163164
foreach ($tabsFields as $tabName => $fields) {
164165
$this->openTab($tabName);
165-
$tabData = $this->getTabElement($tabName)->getDataFormTab($fields, $this->_rootElement);
166+
$tabData = $this->getTab($tabName)->getDataFormTab($fields, $this->_rootElement);
166167
$data = array_merge($data, $tabData);
167168
}
168169
}
@@ -249,41 +250,61 @@ private function getFixtureFieldsByTabsDeprecated(FixtureInterface $fixture)
249250
}
250251

251252
/**
252-
* Get tab element
253+
* Get tab class.
253254
*
254255
* @param string $tabName
255256
* @return Tab
256257
* @throws \Exception
257258
*/
258-
public function getTabElement($tabName)
259+
public function getTab($tabName)
259260
{
260261
$tabClass = $this->tabs[$tabName]['class'];
261-
/** @var Tab $tabElement */
262-
$tabElement = $this->blockFactory->create($tabClass, ['element' => $this->_rootElement]);
263-
if (!$tabElement instanceof Tab) {
262+
/** @var Tab $tab */
263+
$tab = $this->blockFactory->create($tabClass, ['element' => $this->_rootElement]);
264+
if (!$tab instanceof Tab) {
264265
throw new \Exception('Wrong Tab Class.');
265266
}
266-
$tabElement->setWrapper(isset($this->tabs[$tabName]['wrapper']) ? $this->tabs[$tabName]['wrapper'] : '');
267-
$tabElement->setMapping(isset($this->tabs[$tabName]['fields']) ? (array)$this->tabs[$tabName]['fields'] : []);
267+
$tab->setWrapper(isset($this->tabs[$tabName]['wrapper']) ? $this->tabs[$tabName]['wrapper'] : '');
268+
$tab->setMapping(isset($this->tabs[$tabName]['fields']) ? (array)$this->tabs[$tabName]['fields'] : []);
268269

269-
return $tabElement;
270+
return $tab;
270271
}
271272

272273
/**
273-
* Open tab
274+
* Get tab element.
274275
*
275276
* @param string $tabName
276-
* @return FormTabs
277+
* @return ElementInterface
277278
*/
278-
public function openTab($tabName)
279+
protected function getTabElement($tabName)
279280
{
280281
$selector = $this->tabs[$tabName]['selector'];
281282
$strategy = isset($this->tabs[$tabName]['strategy'])
282283
? $this->tabs[$tabName]['strategy']
283284
: Locator::SELECTOR_CSS;
284-
$tab = $this->_rootElement->find($selector, $strategy);
285-
$tab->click();
285+
return $this->_rootElement->find($selector, $strategy);
286+
}
286287

288+
/**
289+
* Open tab.
290+
*
291+
* @param string $tabName
292+
* @return FormTabs
293+
*/
294+
public function openTab($tabName)
295+
{
296+
$this->getTabElement($tabName)->click();
287297
return $this;
288298
}
299+
300+
/**
301+
* Check whether tab is visible.
302+
*
303+
* @param string $tabName
304+
* @return bool
305+
*/
306+
public function isTabVisible($tabName)
307+
{
308+
return $this->getTabElement($tabName)->isVisible();
309+
}
289310
}

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ protected function getTemplateBlock()
206206
* @param array $filters
207207
* @throws \Exception
208208
*/
209-
private function prepareForSearch(array $filters)
209+
protected function prepareForSearch(array $filters)
210210
{
211211
foreach ($filters as $key => $value) {
212212
if (isset($this->filters[$key])) {

dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertBestsellersOnDashboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function processAssert(OrderInjectable $order, Dashboard $dashboard)
3131
$dashboard->open();
3232
$dashboard->getStoreStatsBlock()->refreshData();
3333
/** @var \Magento\Backend\Test\Block\Dashboard\Tab\Products\Ordered $bestsellersGrid */
34-
$bestsellersGrid = $dashboard->getStoreStatsBlock()->getTabElement('bestsellers')->getBestsellersGrid();
34+
$bestsellersGrid = $dashboard->getStoreStatsBlock()->getTab('bestsellers')->getBestsellersGrid();
3535
$products = $order->getEntityId()['products'];
3636
foreach ($products as $product) {
3737
\PHPUnit_Framework_Assert::assertTrue(

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Edit/AttributeForm.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Backend\Test\Block\Widget\FormTabs;
1111
use Magento\Mtf\Client\Element\SimpleElement;
1212
use Magento\Mtf\Client\Element;
13-
use Magento\Mtf\Client\Locator;
1413
use Magento\Mtf\Fixture\FixtureInterface;
1514
use Magento\Mtf\Fixture\InjectableFixture;
1615

@@ -60,7 +59,7 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
6059
if ($this->isTabVisible($tabName)) {
6160
$this->openTab($tabName);
6261
$this->expandAllToggles();
63-
$tabData = $this->getTabElement($tabName)->getDataFormTab();
62+
$tabData = $this->getTab($tabName)->getDataFormTab();
6463
$data = array_merge($data, $tabData);
6564
}
6665
}
@@ -71,7 +70,7 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element
7170
if ($this->isTabVisible($tabName)) {
7271
$this->openTab($tabName);
7372
$this->expandAllToggles();
74-
$tabData = $this->getTabElement($tabName)->getDataFormTab($fields, $this->_rootElement);
73+
$tabData = $this->getTab($tabName)->getDataFormTab($fields, $this->_rootElement);
7574
$data = array_merge($data, $tabData);
7675
}
7776
}
@@ -104,19 +103,4 @@ public function openTab($tabName)
104103
$this->browser->find($this->pageTitle)->click(); // Handle menu overlap problem
105104
return parent::openTab($tabName);
106105
}
107-
108-
/**
109-
* Check if tab is visible.
110-
*
111-
* @param string $tabName
112-
* @return bool
113-
*/
114-
protected function isTabVisible($tabName)
115-
{
116-
$selector = $this->tabs[$tabName]['selector'];
117-
$strategy = isset($this->tabs[$tabName]['strategy'])
118-
? $this->tabs[$tabName]['strategy']
119-
: Locator::SELECTOR_CSS;
120-
return $this->_rootElement->find($selector, $strategy)->isVisible();
121-
}
122106
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ class Configure extends AbstractConfigureBlock
3131
*/
3232
protected $customOptionsSelector = '#product_composite_configure_fields_options';
3333

34+
/**
35+
* Product quantity selector.
36+
*
37+
* @var string
38+
*/
39+
protected $qty = '[name="qty"]';
40+
3441
/**
3542
* Selector for "Ok" button.
3643
*
@@ -53,7 +60,7 @@ class Configure extends AbstractConfigureBlock
5360
*/
5461
public function setQty($qty)
5562
{
56-
$this->_fill($this->dataMapping(['qty' => $qty]));
63+
$this->_rootElement->find($this->qty)->setValue($qty);
5764
}
5865

5966
/**

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/ProductDetails/ProductOnlineSwitcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ProductOnlineSwitcher extends SimpleElement
2727
*
2828
* @var string
2929
*/
30-
protected $topPage = './ancestor::body//*[@class="page-main-actions"]';
30+
protected $topPage = './ancestor::body//*[contains(@class,"page-header")]';
3131

3232
/**
3333
* Set value

0 commit comments

Comments
 (0)