Skip to content

Commit ebc3c56

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-31058
2 parents 3edb99c + e673fcf commit ebc3c56

File tree

250 files changed

+7803
-4088
lines changed

Some content is hidden

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

250 files changed

+7803
-4088
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Fixture;
8+
9+
use Magento\Mtf\Fixture\FixtureInterface;
10+
11+
/**
12+
* Parent fixture data source class.
13+
*/
14+
class DataSource implements FixtureInterface
15+
{
16+
/**
17+
* Data set configuration settings.
18+
*
19+
* @var array
20+
*/
21+
protected $params;
22+
23+
/**
24+
* Value data.
25+
*
26+
* @var array
27+
*/
28+
protected $data;
29+
30+
/**
31+
* Persist entity.
32+
*
33+
* @return void
34+
*/
35+
public function persist()
36+
{
37+
//
38+
}
39+
40+
/**
41+
* Return prepared data set.
42+
*
43+
* @param string $key [optional]
44+
* @return mixed
45+
*
46+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
47+
*/
48+
public function getData($key = null)
49+
{
50+
return $this->data;
51+
}
52+
53+
/**
54+
* Return data set configuration settings.
55+
*
56+
* @return array
57+
*/
58+
public function getDataConfig()
59+
{
60+
return $this->params;
61+
}
62+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Backend\Test\TestCase\NavigateMenuTest">
10+
<variation name="NavigateMenuTest1">
11+
<data name="menuItem" xsi:type="string">System > Notifications</data>
12+
<data name="pageTitle" xsi:type="string">Notifications</data>
13+
<constraint name="Magento\Backend\Test\Constraint\AssertBackendPageIsAvailable"/>
14+
</variation>
15+
</testCase>
16+
</config>

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Admin/Login.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,37 @@
1010
use Magento\Mtf\Client\Locator;
1111

1212
/**
13-
* Class Login
14-
* Login form for backend user
15-
*
13+
* Login form for backend user.
1614
*/
1715
class Login extends Form
1816
{
1917
/**
20-
* 'Log in' button
18+
* 'Log in' button.
2119
*
2220
* @var string
2321
*/
2422
protected $submit = '.action-login';
2523

2624
/**
27-
* Submit login form
25+
* Submit login form.
2826
*/
2927
public function submit()
3028
{
3129
$this->_rootElement->find($this->submit, Locator::SELECTOR_CSS)->click();
3230
}
31+
32+
/**
33+
* Wait for Login form is not visible in the page.
34+
*
35+
* @return void
36+
*/
37+
public function waitFormNotVisible()
38+
{
39+
$form = $this->_rootElement;
40+
$this->browser->waitUntil(
41+
function () use ($form) {
42+
return $form->isVisible() ? null : true;
43+
}
44+
);
45+
}
3346
}

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

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,43 @@
66
namespace Magento\Backend\Test\Block;
77

88
use Magento\Mtf\Block\Block;
9+
use Magento\Mtf\Client\Locator;
910

1011
/**
11-
* Class Menu
12-
* Class top menu navigation block
12+
* Top menu navigation block.
1313
*/
1414
class Menu extends Block
1515
{
1616
/**
17-
* Returns array of parent menu items present on dashboard menu
17+
* Main menu selector.
18+
*
19+
* @var string
20+
*/
21+
protected $mainMenu = './/li/a[span="%s"]';
22+
23+
/**
24+
* Submenu selector.
25+
*
26+
* @var string
27+
*/
28+
protected $subMenu = './/li[a[span="%s"]]/div[@class="submenu" and @style="display: block;"]';
29+
30+
/**
31+
* Submenu item selector.
32+
*
33+
* @var string
34+
*/
35+
protected $subMenuItem = './/a[span="%s"]';
36+
37+
/**
38+
* Parent menu item.
39+
*
40+
* @var string
41+
*/
42+
protected $parentMenuLevel = 'li.parent.level-0:nth-of-type(%s)';
43+
44+
/**
45+
* Returns array of parent menu items present on dashboard menu.
1846
*
1947
* @return array
2048
*/
@@ -24,14 +52,49 @@ public function getTopMenuItems()
2452
$menuItems = [];
2553
$counter = 1;
2654
$textSelector = 'a span';
27-
while ($navigationMenu->find('li.parent.level-0:nth-of-type(' . $counter . ')')->isVisible()) {
55+
while ($navigationMenu->find(sprintf($this->parentMenuLevel, $counter))->isVisible()) {
2856
$menuItems[] = strtolower(
29-
$navigationMenu->find('li.parent.level-0:nth-of-type(' . $counter . ')')
57+
$navigationMenu->find(sprintf($this->parentMenuLevel, $counter))
3058
->find($textSelector)
3159
->getText()
3260
);
3361
$counter++;
3462
}
3563
return $menuItems;
3664
}
65+
66+
/**
67+
* Open backend page via menu.
68+
*
69+
* @param string $menuItem
70+
* @return void
71+
* @throws \Exception
72+
*/
73+
public function navigate($menuItem)
74+
{
75+
$menuChain = array_map('trim', explode('>', $menuItem));
76+
$mainMenu = $menuChain[0];
77+
$subMenu = isset($menuChain[1]) ? $menuChain[1] : null;
78+
79+
// Click on element in main menu
80+
$mainMenuElement = $this->_rootElement->find(sprintf($this->mainMenu, $mainMenu), Locator::SELECTOR_XPATH);
81+
if (!$mainMenuElement->isVisible()) {
82+
throw new \Exception('Main menu item "' . $mainMenu . '" is not visible.');
83+
}
84+
$mainMenuElement->click();
85+
86+
// Click on element in submenu
87+
if ($subMenu === null) {
88+
return;
89+
}
90+
$subMenuSelector = sprintf($this->subMenu, $mainMenu);
91+
$this->waitForElementVisible($subMenuSelector, Locator::SELECTOR_XPATH);
92+
$subMenuItem = $this->_rootElement->find($subMenuSelector, Locator::SELECTOR_XPATH)
93+
->find(sprintf($this->subMenuItem, $subMenu), Locator::SELECTOR_XPATH);
94+
if (!$subMenuItem->isVisible()) {
95+
throw new \Exception('Submenu item "' . $subMenu . '" is not visible in "' . $mainMenu . '"');
96+
}
97+
$subMenuItem->click();
98+
$this->waitForElementNotVisible($subMenuSelector, Locator::SELECTOR_XPATH);
99+
}
37100
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Block\Page;
8+
9+
use Magento\Mtf\Block\Block;
10+
11+
/**
12+
* 404 error backend block.
13+
*/
14+
class Error extends Block
15+
{
16+
/**
17+
* Get block text content.
18+
*
19+
* @return string
20+
*/
21+
public function getContent()
22+
{
23+
return $this->_rootElement->getText();
24+
}
25+
}

dev/tests/functional/tests/app/Magento/Backend/Test/Block/Page/Main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Mtf\Block\Block;
1010

1111
/**
12-
* Main block.
12+
* Main dashboard block.
1313
*/
1414
class Main extends Block
1515
{
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Constraint;
8+
9+
use Magento\Backend\Test\Fixture\GlobalSearch;
10+
use Magento\Backend\Test\Page\Adminhtml\Dashboard;
11+
use Magento\Mtf\Constraint\AbstractConstraint;
12+
13+
/**
14+
* Assert backend page title and it's availability.
15+
*/
16+
class AssertBackendPageIsAvailable extends AbstractConstraint
17+
{
18+
const ERROR_TEXT = '404 Error';
19+
20+
/**
21+
* Assert that backend page has correct title and 404 Error is absent on the page.
22+
*
23+
* @param Dashboard $dashboard
24+
* @param string $pageTitle
25+
* @return void
26+
*/
27+
public function processAssert(Dashboard $dashboard, $pageTitle)
28+
{
29+
\PHPUnit_Framework_Assert::assertEquals(
30+
$pageTitle,
31+
$dashboard->getTitleBlock()->getTitle(),
32+
'Invalid page title is displayed.'
33+
);
34+
\PHPUnit_Framework_Assert::assertNotContains(
35+
self::ERROR_TEXT,
36+
$dashboard->getErrorBlock()->getContent(),
37+
"404 Error is displayed on '$pageTitle' page."
38+
);
39+
}
40+
41+
/**
42+
* Returns a string representation of the object.
43+
*
44+
* @return string
45+
*/
46+
public function toString()
47+
{
48+
return 'Backend has correct title and 404 page content is absent.';
49+
}
50+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Backend\Test\Constraint;
8+
9+
use Magento\Store\Test\Fixture\Store;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\Backend\Test\Page\Adminhtml\SystemConfig;
12+
use Magento\Cms\Test\Page\CmsIndex;
13+
14+
/**
15+
* Assert that store can be localized.
16+
*/
17+
class AssertStoreCanBeLocalized extends AbstractConstraint
18+
{
19+
/**
20+
* Assert that locale options can be changed and checks new text on index page.
21+
*
22+
* @param SystemConfig $systemConfig
23+
* @param Store $store
24+
* @param CmsIndex $cmsIndex
25+
* @param string $locale
26+
* @param string $welcomeText
27+
* @return void
28+
*/
29+
public function processAssert(SystemConfig $systemConfig, Store $store, CmsIndex $cmsIndex, $locale, $welcomeText)
30+
{
31+
// Set locale options
32+
$systemConfig->open();
33+
$systemConfig->getPageActions()->selectStore($store->getGroupId() . "/" . $store->getName());
34+
$configGroup = $systemConfig->getForm()->getGroup('Locale Options');
35+
$configGroup->open();
36+
$configGroup->setValue('select-groups-locale-fields-code-value', $locale);
37+
$systemConfig->getPageActions()->save();
38+
$systemConfig->getMessagesBlock()->waitSuccessMessage();
39+
40+
// Check presents income text on index page
41+
$cmsIndex->open();
42+
$cmsIndex->getStoreSwitcherBlock()->selectStoreView($store->getName());
43+
44+
\PHPUnit_Framework_Assert::assertTrue(
45+
$cmsIndex->getSearchBlock()->isPlaceholderContains($welcomeText),
46+
"Locale not applied."
47+
);
48+
}
49+
50+
/**
51+
* Returns a string representation of the object.
52+
*
53+
* @return string
54+
*/
55+
public function toString()
56+
{
57+
return 'Store locale has changed successfully.';
58+
}
59+
}

0 commit comments

Comments
 (0)