Skip to content

Commit 9993a56

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents 9c76393 + f092e4a commit 9993a56

File tree

12 files changed

+963
-414
lines changed

12 files changed

+963
-414
lines changed

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<preference for="Magento\Framework\App\RequestSafetyInterface" type="Magento\Framework\App\Request\Http" />
4848
<preference for="\Magento\Framework\Setup\SchemaSetupInterface" type="\Magento\Setup\Module\Setup" />
4949
<preference for="\Magento\Framework\Setup\ModuleDataSetupInterface" type="\Magento\Setup\Module\DataSetup" />
50+
<preference for="Magento\Framework\App\ExceptionHandlerInterface" type="Magento\Framework\App\ExceptionHandler" />
5051
<type name="Magento\Store\Model\Store">
5152
<arguments>
5253
<argument name="currencyInstalled" xsi:type="string">system/currency/installed</argument>

dev/tests/integration/testsuite/Magento/Framework/Error/ProcessorTest.php

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,136 @@
55
*/
66
namespace Magento\Framework\Error;
77

8+
use Magento\TestFramework\Helper\Bootstrap;
9+
810
require_once __DIR__ . '/../../../../../../../pub/errors/processor.php';
911

1012
class ProcessorTest extends \PHPUnit\Framework\TestCase
1113
{
12-
/** @var \Magento\Framework\Error\Processor */
14+
/**
15+
* @var Processor
16+
*/
1317
private $processor;
1418

15-
public function setUp()
19+
/**
20+
* @inheritdoc
21+
*/
22+
protected function setUp()
1623
{
1724
$this->processor = $this->createProcessor();
1825
}
1926

20-
public function tearDown()
27+
/**
28+
* {@inheritdoc}
29+
* @throws \Exception
30+
*/
31+
protected function tearDown()
2132
{
22-
if ($this->processor->reportId) {
23-
unlink($this->processor->_reportDir . '/' . $this->processor->reportId);
24-
}
33+
$reportDir = $this->processor->_reportDir;
34+
$this->removeDirRecursively($reportDir);
2535
}
2636

27-
public function testSaveAndLoadReport()
28-
{
37+
/**
38+
* @param int $logReportDirNestingLevel
39+
* @param int $logReportDirNestingLevelChanged
40+
* @param string $exceptionMessage
41+
* @dataProvider dataProviderSaveAndLoadReport
42+
*/
43+
public function testSaveAndLoadReport(
44+
int $logReportDirNestingLevel,
45+
int $logReportDirNestingLevelChanged,
46+
string $exceptionMessage
47+
) {
48+
$_ENV['MAGE_ERROR_REPORT_DIR_NESTING_LEVEL'] = $logReportDirNestingLevel;
2949
$reportData = [
30-
0 => 'exceptionMessage',
50+
0 => $exceptionMessage,
3151
1 => 'exceptionTrace',
3252
'script_name' => 'processor.php'
3353
];
54+
$reportData['report_id'] = hash('sha256', implode('', $reportData));
3455
$expectedReportData = array_merge($reportData, ['url' => '']);
35-
$this->processor = $this->createProcessor();
36-
$this->processor->saveReport($reportData);
37-
if (!$this->processor->reportId) {
56+
$processor = $this->createProcessor();
57+
$processor->saveReport($reportData);
58+
$reportId = $processor->reportId;
59+
if (!$reportId) {
3860
$this->fail("Failed to generate report id");
3961
}
40-
$this->assertFileExists($this->processor->_reportDir . '/' . $this->processor->reportId);
41-
$this->assertEquals($expectedReportData, $this->processor->reportData);
62+
$this->assertEquals($expectedReportData, $processor->reportData);
63+
$_ENV['MAGE_ERROR_REPORT_DIR_NESTING_LEVEL'] = $logReportDirNestingLevelChanged;
64+
$processor = $this->createProcessor();
65+
$processor->loadReport($reportId);
66+
$this->assertEquals($expectedReportData, $processor->reportData, "File contents of report don't match");
67+
}
68+
69+
/**
70+
* Data Provider for testSaveAndLoadReport
71+
*
72+
* @return array
73+
*/
74+
public function dataProviderSaveAndLoadReport(): array
75+
{
76+
return [
77+
[
78+
'logReportDirNestingLevel' => 0,
79+
'logReportDirNestingLevelChanged' => 0,
80+
'exceptionMessage' => '$exceptionMessage 0',
81+
],
82+
[
83+
'logReportDirNestingLevel' => 1,
84+
'logReportDirNestingLevelChanged' => 1,
85+
'exceptionMessage' => '$exceptionMessage 1',
86+
],
87+
[
88+
'logReportDirNestingLevel' => 2,
89+
'logReportDirNestingLevelChanged' => 2,
90+
'exceptionMessage' => '$exceptionMessage 2',
91+
],
92+
[
93+
'logReportDirNestingLevel' => 3,
94+
'logReportDirNestingLevelChanged' => 23,
95+
'exceptionMessage' => '$exceptionMessage 2',
96+
],
97+
[
98+
'logReportDirNestingLevel' => 32,
99+
'logReportDirNestingLevelChanged' => 32,
100+
'exceptionMessage' => '$exceptionMessage 3',
101+
],
102+
[
103+
'logReportDirNestingLevel' => 100,
104+
'logReportDirNestingLevelChanged' => 100,
105+
'exceptionMessage' => '$exceptionMessage 100',
106+
],
107+
];
108+
}
42109

43-
$loadProcessor = $this->createProcessor();
44-
$loadProcessor->loadReport($this->processor->reportId);
45-
$this->assertEquals($expectedReportData, $loadProcessor->reportData, "File contents of report don't match");
110+
/**
111+
* @return Processor
112+
*/
113+
private function createProcessor(): Processor
114+
{
115+
return Bootstrap::getObjectManager()->create(Processor::class);
46116
}
47117

48118
/**
49-
* @return \Magento\Framework\Error\Processor
119+
* Remove dir recursively
120+
*
121+
* @param string $dir
122+
* @param int $i
123+
* @return bool
124+
* @throws \Exception
50125
*/
51-
private function createProcessor()
126+
private function removeDirRecursively(string $dir, int $i = 0): bool
52127
{
53-
return \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
54-
->create(\Magento\Framework\Error\Processor::class);
128+
if ($i >= 100) {
129+
throw new \Exception('Emergency exit from recursion');
130+
}
131+
$files = array_diff(scandir($dir), ['.', '..']);
132+
foreach ($files as $file) {
133+
$i++;
134+
(is_dir("$dir/$file"))
135+
? $this->removeDirRecursively("$dir/$file", $i)
136+
: unlink("$dir/$file");
137+
}
138+
return rmdir($dir);
55139
}
56140
}

dev/tests/static/framework/Magento/CodeMessDetector/Rule/Design/AllPurposeAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function apply(AbstractNode $node)
3838
return;
3939
}
4040

41-
if (in_array(ActionInterface::class, $impl, true)) {
41+
if (is_array($impl) && in_array(ActionInterface::class, $impl, true)) {
4242
$methodsDefined = false;
4343
foreach ($impl as $i) {
4444
if (preg_match('/\\\Http[a-z]+ActionInterface$/i', $i)) {

0 commit comments

Comments
 (0)