Skip to content

Commit 409997b

Browse files
author
Karpenko, Oleksandr
committed
MAGETWO-70571: There is no possibility to activate DEBUG logging in production mode
1 parent 953b4eb commit 409997b

File tree

1 file changed

+38
-8
lines changed
  • dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler

1 file changed

+38
-8
lines changed

dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Developer\Model\Logger\Handler;
77

88
use Magento\Config\Console\Command\ConfigSetCommand;
9+
use Magento\Framework\App\Config;
910
use Magento\Framework\App\Config\ScopeConfigInterface;
1011
use Magento\Framework\App\Filesystem\DirectoryList;
1112
use Magento\Framework\Filesystem;
@@ -16,6 +17,23 @@
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Output\OutputInterface;
1819

20+
/**
21+
* Preconditions
22+
* - Developer mode enabled
23+
* - Log file isn't exists
24+
* - 'Log to file' setting are enabled
25+
*
26+
* Test steps
27+
* - Enable production mode without compilation
28+
* - Try to log message into log file
29+
* - Assert that log file isn't exists
30+
* - Assert that 'Log to file' setting are disabled
31+
*
32+
* - Enable 'Log to file' setting
33+
* - Try to log message into debug file
34+
* - Assert that log file is exists
35+
* - Assert that log file contain logged message
36+
*/
1937
class DebugTest extends \PHPUnit_Framework_TestCase
2038
{
2139
/**
@@ -48,6 +66,11 @@ class DebugTest extends \PHPUnit_Framework_TestCase
4866
*/
4967
private $etcDirectory;
5068

69+
/**
70+
* @var Config
71+
*/
72+
private $appConfig;
73+
5174
public function setUp()
5275
{
5376
/** @var Filesystem $filesystem */
@@ -68,9 +91,11 @@ public function setUp()
6891
]
6992
);
7093
$this->configSetCommand = Bootstrap::getObjectManager()->create(ConfigSetCommand::class);
94+
$this->appConfig = Bootstrap::getObjectManager()->create(Config::class);
7195

7296
// Preconditions
7397
$this->mode->enableDeveloperMode();
98+
$this->enableDebugging();
7499
if (file_exists($this->getDebuggerLogPath())) {
75100
unlink($this->getDebuggerLogPath());
76101
}
@@ -82,15 +107,8 @@ public function tearDown()
82107
$this->etcDirectory->renameFile('env.base.php', 'env.php');
83108
}
84109

85-
public function testDebugInProductionMode()
110+
private function enableDebugging()
86111
{
87-
$message = 'test message';
88-
89-
$this->mode->enableProductionModeMinimal();
90-
91-
$this->logger->debug($message);
92-
$this->assertFileNotExists($this->getDebuggerLogPath());
93-
94112
$this->inputMock = $this->getMockBuilder(InputInterface::class)
95113
->getMockForAbstractClass();
96114
$this->outputMock = $this->getMockBuilder(OutputInterface::class)
@@ -115,6 +133,18 @@ public function testDebugInProductionMode()
115133
->method('writeln')
116134
->with('<info>Value was saved and locked.</info>');
117135
$this->assertFalse((bool)$this->configSetCommand->run($this->inputMock, $this->outputMock));
136+
}
137+
138+
public function testDebugInProductionMode()
139+
{
140+
$message = 'test message';
141+
142+
$this->mode->enableProductionModeMinimal();
143+
$this->logger->debug($message);
144+
$this->assertFileNotExists($this->getDebuggerLogPath());
145+
$this->assertFalse((bool)$this->appConfig->getValue('dev/debug/debug_logging'));
146+
147+
$this->enableDebugging();
118148
$this->logger->debug($message);
119149

120150
$this->assertFileExists($this->getDebuggerLogPath());

0 commit comments

Comments
 (0)