Skip to content

Commit cbbcc1e

Browse files
committed
11882: It's not possible to enable "log to file" (debugging) in production mode. Psr logger debug method does not work by the default in developer mode.
1 parent 313a527 commit cbbcc1e

File tree

2 files changed

+75
-18
lines changed

2 files changed

+75
-18
lines changed

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

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,7 @@ class Form extends Block
6060
*/
6161
public function getGroup($tabName, $groupName)
6262
{
63-
$this->baseUrl = $this->getBrowserUrl();
64-
if (substr($this->baseUrl, -1) !== '/') {
65-
$this->baseUrl = $this->baseUrl . '/';
66-
}
67-
68-
$tabUrl = $this->getTabUrl($tabName);
69-
70-
if ($this->getBrowserUrl() !== $tabUrl) {
71-
$this->browser->open($tabUrl);
72-
}
73-
$this->waitForElementNotVisible($this->tabReadiness);
63+
$this->openTab($tabName);
7464

7565
$groupElement = $this->_rootElement->find(
7666
sprintf($this->groupBlock, $tabName, $groupName),
@@ -95,6 +85,24 @@ public function getGroup($tabName, $groupName)
9585
return $blockFactory->getMagentoBackendSystemConfigFormGroup($groupElement);
9686
}
9787

88+
/**
89+
* Check whether specified group presented on page.
90+
*
91+
* @param string $tabName
92+
* @param string $groupName
93+
*
94+
* @return bool
95+
*/
96+
public function isGroupVisible(string $tabName, string $groupName)
97+
{
98+
$this->openTab($tabName);
99+
100+
return $this->_rootElement->find(
101+
sprintf($this->groupBlockLink, $tabName, $groupName),
102+
Locator::SELECTOR_CSS
103+
)->isVisible();
104+
}
105+
98106
/**
99107
* Retrieve url associated with the form.
100108
*/
@@ -137,4 +145,24 @@ private function getTabUrl($tabName)
137145

138146
return $tabUrl;
139147
}
148+
149+
/**
150+
* Open specified tab.
151+
*
152+
* @param string $tabName
153+
* @return void
154+
*/
155+
private function openTab(string $tabName)
156+
{
157+
$this->baseUrl = $this->getBrowserUrl();
158+
if (substr($this->baseUrl, -1) !== '/') {
159+
$this->baseUrl = $this->baseUrl . '/';
160+
}
161+
$tabUrl = $this->getTabUrl($tabName);
162+
163+
if ($this->getBrowserUrl() !== $tabUrl) {
164+
$this->browser->open($tabUrl);
165+
}
166+
$this->waitForElementNotVisible($this->tabReadiness);
167+
}
140168
}

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

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,56 @@
99
use Magento\Backend\Test\Page\Adminhtml\SystemConfigEdit;
1010

1111
/**
12-
* Assert that Developer section is not present in production mode.
12+
* Assert that all groups in Developer section is not present in production mode except debug group "Log to File" field.
1313
*/
1414
class AssertDeveloperSectionVisibility extends AbstractConstraint
1515
{
1616
/**
17-
* Assert Developer section is not present in production mode.
17+
* List of groups not visible in production mode.
18+
*
19+
* @var array
20+
*/
21+
private $groups = [
22+
'front_end_development_workflow',
23+
'restrict',
24+
'template',
25+
'translate_inline',
26+
'js',
27+
'css',
28+
'image',
29+
'static',
30+
'grid',
31+
];
32+
33+
/**
34+
* Assert all groups in Developer section is not present in production mode except debug group "Log to File" field.
1835
*
1936
* @param SystemConfigEdit $configEdit
2037
* @return void
2138
*/
2239
public function processAssert(SystemConfigEdit $configEdit)
2340
{
2441
if ($_ENV['mage_mode'] === 'production') {
25-
\PHPUnit_Framework_Assert::assertFalse(
26-
in_array('Developer', $configEdit->getTabs()->getSubTabsNames('Advanced')),
27-
'Developer section should be hidden in production mode.'
42+
foreach ($this->groups as $group) {
43+
\PHPUnit_Framework_Assert::assertFalse(
44+
$configEdit->getForm()->isGroupVisible('dev', $group),
45+
sprintf('%s group should be hidden in production mode.', $group)
46+
);
47+
}
48+
\PHPUnit_Framework_Assert::assertTrue(
49+
$configEdit->getForm()->getGroup('dev', 'debug')->isFieldVisible('dev', 'debug_debug', 'logging'),
50+
'"Log to File" should be presented in production mode.'
2851
);
2952
} else {
53+
foreach ($this->groups as $group) {
54+
\PHPUnit_Framework_Assert::assertTrue(
55+
$configEdit->getForm()->isGroupVisible('dev', $group),
56+
sprintf('%s group should be visible in developer mode.', $group)
57+
);
58+
}
3059
\PHPUnit_Framework_Assert::assertTrue(
31-
in_array('Developer', $configEdit->getTabs()->getSubTabsNames('Advanced')),
32-
'Developer section should be not hidden in developer or default mode.'
60+
$configEdit->getForm()->isGroupVisible('dev', 'debug'),
61+
'Debug group should be visible in developer mode.'
3362
);
3463
}
3564
}

0 commit comments

Comments
 (0)