Skip to content

Commit 49b1202

Browse files
authored
Merge pull request #10 from magento-tango/MAGETWO-54934-1
Magetwo 54934 1
2 parents 5bd2fdb + c95d851 commit 49b1202

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/internal/Magento/Framework/App/StaticResource.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Framework\App\Filesystem\DirectoryList;
99
use Magento\Framework\ObjectManager\ConfigLoaderInterface;
1010
use Magento\Framework\Filesystem;
11+
use Psr\Log\LoggerInterface;
1112

1213
/**
1314
* Entry point for retrieving static resources like JS, CSS, images by requested public path
@@ -43,6 +44,9 @@ class StaticResource implements \Magento\Framework\AppInterface
4344
/** @var Filesystem */
4445
private $filesystem;
4546

47+
/** @var LoggerInterface */
48+
private $logger;
49+
4650
/**
4751
* @param State $state
4852
* @param Response\FileInterface $response
@@ -105,6 +109,7 @@ public function launch()
105109
*/
106110
public function catchException(Bootstrap $bootstrap, \Exception $exception)
107111
{
112+
$this->getLogger()->critical($exception->getMessage());
108113
if ($bootstrap->isDeveloperMode()) {
109114
$this->response->setHttpResponseCode(404);
110115
$this->response->setHeader('Content-Type', 'text/plain');
@@ -161,4 +166,19 @@ private function getFilesystem()
161166
}
162167
return $this->filesystem;
163168
}
169+
170+
/**
171+
* Retrieves LoggerInterface instance
172+
*
173+
* @return LoggerInterface
174+
* @deprecated
175+
*/
176+
private function getLogger()
177+
{
178+
if (!$this->logger) {
179+
$this->logger = $this->objectManager->get(LoggerInterface::class);
180+
}
181+
182+
return $this->logger;
183+
}
164184
}

lib/internal/Magento/Framework/App/Test/Unit/StaticResourceTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ class StaticResourceTest extends \PHPUnit_Framework_TestCase
5858
*/
5959
private $object;
6060

61+
/**
62+
* @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
63+
*/
64+
private $logger;
65+
6166
protected function setUp()
6267
{
6368
$this->state = $this->getMock('Magento\Framework\App\State', [], [], '', false);
@@ -67,6 +72,7 @@ protected function setUp()
6772
$this->assetRepo = $this->getMock('Magento\Framework\View\Asset\Repository', [], [], '', false);
6873
$this->moduleList = $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false);
6974
$this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface');
75+
$this->logger = $this->getMockForAbstractClass('Psr\Log\LoggerInterface');
7076
$this->configLoader = $this->getMock(
7177
'Magento\Framework\App\ObjectManager\ConfigLoader', [], [], '', false
7278
);
@@ -193,6 +199,12 @@ public function testLaunchWrongPath()
193199

194200
public function testCatchExceptionDeveloperMode()
195201
{
202+
$this->objectManager->expects($this->once())
203+
->method('get')
204+
->with('Psr\Log\LoggerInterface')
205+
->willReturn($this->logger);
206+
$this->logger->expects($this->once())
207+
->method('critical');
196208
$bootstrap = $this->getMockBuilder(Bootstrap::class)->disableOriginalConstructor()->getMock();
197209
$bootstrap->expects($this->once())->method('isDeveloperMode')->willReturn(true);
198210
$exception = new \Exception('Error: nothing works');

0 commit comments

Comments
 (0)