-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from magento-tango/MAGETWO-54731
[Tango] P2 Bug fixes
- Loading branch information
Showing
27 changed files
with
761 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Developer\Model\Logger\Handler; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\App\State; | ||
use Magento\Framework\Filesystem\DriverInterface; | ||
use Magento\Store\Model\ScopeInterface; | ||
|
||
/** | ||
* Class Debug | ||
*/ | ||
class Debug extends \Magento\Framework\Logger\Handler\Debug | ||
{ | ||
/** | ||
* @var State | ||
*/ | ||
private $state; | ||
|
||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
private $scopeConfig; | ||
|
||
/** | ||
* @param DriverInterface $filesystem | ||
* @param State $state | ||
* @param ScopeConfigInterface $scopeConfig | ||
* @param string $filePath | ||
*/ | ||
public function __construct( | ||
DriverInterface $filesystem, | ||
State $state, | ||
ScopeConfigInterface $scopeConfig, | ||
$filePath = null | ||
) { | ||
parent::__construct($filesystem, $filePath); | ||
|
||
$this->state = $state; | ||
$this->scopeConfig = $scopeConfig; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function isHandling(array $record) | ||
{ | ||
return | ||
parent::isHandling($record) | ||
&& $this->state->getMode() !== State::MODE_PRODUCTION | ||
&& $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE); | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
app/code/Magento/Developer/Test/Unit/Model/Logger/Handler/DebugTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Developer\Test\Unit\Model\Logger\Handler; | ||
|
||
use Magento\Developer\Model\Logger\Handler\Debug; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\App\State; | ||
use Magento\Framework\Filesystem\DriverInterface; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Store\Model\ScopeInterface; | ||
use Monolog\Formatter\FormatterInterface; | ||
use Monolog\Logger; | ||
|
||
/** | ||
* Class DebugTest | ||
*/ | ||
class DebugTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Debug | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @var DriverInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $filesystemMock; | ||
|
||
/** | ||
* @var State|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $stateMock; | ||
|
||
/** | ||
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $scopeConfigMock; | ||
|
||
/** | ||
* @var FormatterInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $formatterMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->filesystemMock = $this->getMockBuilder(DriverInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->stateMock = $this->getMockBuilder(State::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class) | ||
->getMockForAbstractClass(); | ||
$this->formatterMock = $this->getMockBuilder(FormatterInterface::class) | ||
->getMockForAbstractClass(); | ||
|
||
$this->formatterMock->expects($this->any()) | ||
->method('format') | ||
->willReturn(null); | ||
|
||
$this->model = (new ObjectManager($this))->getObject(Debug::class, [ | ||
'filesystem' => $this->filesystemMock, | ||
'state' => $this->stateMock, | ||
'scopeConfig' => $this->scopeConfigMock, | ||
]); | ||
$this->model->setFormatter($this->formatterMock); | ||
} | ||
|
||
public function testHandle() | ||
{ | ||
$this->stateMock->expects($this->once()) | ||
->method('getMode') | ||
->willReturn(State::MODE_DEVELOPER); | ||
$this->scopeConfigMock->expects($this->once()) | ||
->method('getValue') | ||
->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null) | ||
->willReturn(true); | ||
|
||
$this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]); | ||
} | ||
|
||
public function testHandleDisabledByProduction() | ||
{ | ||
$this->stateMock->expects($this->once()) | ||
->method('getMode') | ||
->willReturn(State::MODE_PRODUCTION); | ||
$this->scopeConfigMock->expects($this->never()) | ||
->method('getValue'); | ||
|
||
$this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]); | ||
} | ||
|
||
public function testHandleDisabledByConfig() | ||
{ | ||
$this->stateMock->expects($this->once()) | ||
->method('getMode') | ||
->willReturn(State::MODE_DEVELOPER); | ||
$this->scopeConfigMock->expects($this->once()) | ||
->method('getValue') | ||
->with('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE, null) | ||
->willReturn(false); | ||
|
||
$this->model->handle(['formatted' => false, 'level' => Logger::DEBUG]); | ||
} | ||
|
||
public function testHandleDisabledByLevel() | ||
{ | ||
$this->stateMock->expects($this->never()) | ||
->method('getMode'); | ||
$this->scopeConfigMock->expects($this->never()) | ||
->method('getValue'); | ||
|
||
$this->model->handle(['formatted' => false, 'level' => Logger::API]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.