Skip to content

Commit 70702be

Browse files
author
Bohdan Korablov
committed
MAGETWO-61786: Implementation
1 parent a16e03b commit 70702be

File tree

7 files changed

+238
-1
lines changed

7 files changed

+238
-1
lines changed

dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/Form/Group.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,25 @@ public function getValue($tabName, $groupName, $fieldName)
125125
*/
126126
public function isFieldVisible($tabName, $groupName, $fieldName)
127127
{
128-
$this->_rootElement->find(
128+
return $this->_rootElement->find(
129129
sprintf($this->field, $tabName, $groupName, $fieldName),
130130
Locator::SELECTOR_CSS
131131
)->isVisible();
132132
}
133+
134+
/**
135+
* Check if a field is disabled in a given group.
136+
*
137+
* @param string $tabName
138+
* @param string $groupName
139+
* @param string $fieldName
140+
* @return bool
141+
*/
142+
public function isFieldDisabled($tabName, $groupName, $fieldName)
143+
{
144+
return $this->_rootElement->find(
145+
sprintf($this->field, $tabName, $groupName, $fieldName),
146+
Locator::SELECTOR_CSS
147+
)->isDisabled();
148+
}
133149
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Test\Block\System\Config;
7+
8+
use Magento\Mtf\Block\Block;
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Class Tabs.
13+
*/
14+
class Tabs extends Block
15+
{
16+
/**
17+
* Top tab selector.
18+
*
19+
* @var string
20+
*/
21+
private $topTab = ".//*//strong[contains(., '%s')]/parent::div";
22+
23+
/**
24+
* Selector of block with sub tabs.
25+
*
26+
* @var string
27+
*/
28+
private $subTabs = ".//*//strong[contains(., '%s')]/parent::div/parent::div/ul";
29+
30+
/**
31+
* Selector of specific sub tab.
32+
*
33+
* @var string
34+
*/
35+
private $subTab = 'li:nth-of-type(%s)';
36+
37+
/**
38+
* Get list of sub tabs of tab.
39+
*
40+
* @param string $tab
41+
* @return array
42+
*/
43+
public function getSubTabs($tab)
44+
{
45+
$subTabs = [];
46+
$textSelector = 'a span';
47+
48+
$subTabsBlock = $this->_rootElement->find(sprintf($this->subTabs, $tab), Locator::SELECTOR_XPATH);
49+
50+
if (!$subTabsBlock->isVisible()) {
51+
$this->_rootElement->find(sprintf($this->topTab, $tab), Locator::SELECTOR_XPATH)->click();
52+
}
53+
54+
$count = 1;
55+
while ($subTabsBlock->find(sprintf($this->subTab, $count))->isVisible()) {
56+
$subTabs[] = $subTabsBlock->find(sprintf($this->subTab, $count))
57+
->find($textSelector)
58+
->getText();
59+
$count++;
60+
}
61+
62+
return $subTabs;
63+
}
64+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Test\Constraint;
7+
8+
use Magento\Mtf\Constraint\AbstractConstraint;
9+
use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
10+
11+
/**
12+
* Assert that Developer section is not present in production mode.
13+
*/
14+
class AssertDeveloperSectionVisibility extends AbstractConstraint
15+
{
16+
/**
17+
* Assert Developer section is not present in production mode.
18+
*
19+
* @param SystemConfigEdit $configEdit
20+
* @return void
21+
*/
22+
public function processAssert(SystemConfigEdit $configEdit)
23+
{
24+
if ($_ENV['mage_mode'] === 'production') {
25+
\PHPUnit_Framework_Assert::assertFalse(
26+
in_array('Developer', $configEdit->getTabs()->getSubTabs('Advanced')),
27+
'Developer section should be hidden in production mode.'
28+
);
29+
} else {
30+
\PHPUnit_Framework_Assert::assertTrue(
31+
in_array('Developer', $configEdit->getTabs()->getSubTabs('Advanced')),
32+
'Developer section should be not hidden in developer or default mode.'
33+
);
34+
}
35+
}
36+
37+
/**
38+
* Returns a string representation of the object.
39+
*
40+
* @return string
41+
*/
42+
public function toString()
43+
{
44+
return 'Developer section has correct visibility.';
45+
}
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Test\Constraint;
7+
8+
use Magento\Mtf\Constraint\AbstractConstraint;
9+
use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
10+
11+
/**
12+
* Assert that Locale field has correct visibility.
13+
*/
14+
class AssertLocaleCodeVisibility extends AbstractConstraint
15+
{
16+
/**
17+
* Assert Locale field visibility.
18+
*
19+
* @param SystemConfigEdit $configEdit
20+
* @return void
21+
*/
22+
public function processAssert(SystemConfigEdit $configEdit)
23+
{
24+
if ($_ENV['mage_mode'] === 'production') {
25+
\PHPUnit_Framework_Assert::assertTrue(
26+
$configEdit->getForm()->getGroup('general', 'locale')->isFieldDisabled('general', 'locale', 'code'),
27+
'Locale field should be disabled in production mode.'
28+
);
29+
} else {
30+
\PHPUnit_Framework_Assert::assertFalse(
31+
$configEdit->getForm()->getGroup('general', 'locale')->isFieldDisabled('general', 'locale', 'code'),
32+
'Locale field should be not disabled in developer or default mode.'
33+
);
34+
}
35+
}
36+
37+
/**
38+
* Returns a string representation of the object.
39+
*
40+
* @return string
41+
*/
42+
public function toString()
43+
{
44+
return 'Locale field has correct visibility.';
45+
}
46+
}

dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfigEdit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<block name="form" class="Magento\Backend\Test\Block\System\Config\Form" locator="#config-edit-form" strategy="css selector"/>
1212
<block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector"/>
1313
<block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/>
14+
<block name="tabs" class="Magento\Backend\Test\Block\System\Config\Tabs" locator="#system_config_tabs" strategy="css selector"/>
1415
</page>
1516
</config>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Test\TestCase;
7+
8+
use Magento\Mtf\TestCase\Injectable;
9+
use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
10+
11+
/**
12+
* Verify visibility of Locale field and Developer section on Configuration page.
13+
*
14+
* @ZephyrId MAGETWO-63625, MAGETWO-63624
15+
*/
16+
class ConfigPageVisibilityTest extends Injectable
17+
{
18+
/* tags */
19+
const TEST_TYPE = 'acceptance_test';
20+
/* end tags */
21+
22+
/**
23+
* "Configuration" page in Admin panel.
24+
*
25+
* @var SystemConfigEdit
26+
*/
27+
protected $configurationAdminPage;
28+
29+
/**
30+
* Prepare data for further test execution.
31+
*
32+
* @param SystemConfigEdit $configurationAdminPage
33+
* @return void
34+
*/
35+
public function __inject(SystemConfigEdit $configurationAdminPage)
36+
{
37+
$this->configurationAdminPage = $configurationAdminPage;
38+
}
39+
40+
/**
41+
* Test execution.
42+
*
43+
* @return void
44+
*/
45+
public function test()
46+
{
47+
$this->configurationAdminPage->open();
48+
}
49+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2013-2017 Magento, Inc. 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\VisibilityLocaleCodeTest" summary="Check Developer section and Locale field">
10+
<variation name="first" summary="Check Developer section and Locale field" ticketId="MAGETWO-63625, MAGETWO-63624">
11+
<constraint name="Magento\Backend\Test\Constraint\AssertLocaleCodeVisibility" />
12+
<constraint name="Magento\Backend\Test\Constraint\AssertDeveloperSectionVisibility" />
13+
</variation>
14+
</testCase>
15+
</config>

0 commit comments

Comments
 (0)