Skip to content

Commit dc633c9

Browse files
committed
MC-5926: Conflict of simultaneous write in Redis cache
- fix test to run integration test bin/magento with any shell command for dependent commands without mocking
1 parent 93a381b commit dc633c9

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

dev/tests/integration/etc/di/preferences/ce.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@
2727
\Magento\Framework\App\Config\ScopeConfigInterface::class => \Magento\TestFramework\App\Config::class,
2828
\Magento\Framework\Lock\Backend\Cache::class =>
2929
\Magento\TestFramework\Lock\Backend\DummyLocker::class,
30+
\Magento\Framework\ShellInterface::class => \Magento\TestFramework\App\Shell::class,
31+
\Magento\Framework\App\Shell::class => \Magento\TestFramework\App\Shell::class,
3032
];
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\TestFramework\App;
7+
/**
8+
* Shell command line wrapper encapsulates command execution and arguments escaping
9+
*/
10+
class Shell extends \Magento\Framework\App\Shell
11+
{
12+
/**
13+
* @inheritdoc
14+
*/
15+
public function execute($command, array $arguments = [])
16+
{
17+
if (strpos($command, BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento ') !== false) {
18+
$command = str_replace(
19+
BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento ',
20+
BP . DIRECTORY_SEPARATOR . 'dev' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'integration'
21+
. DIRECTORY_SEPARATOR. 'bin' . DIRECTORY_SEPARATOR . 'magento ',
22+
$command
23+
);
24+
}
25+
26+
$params = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppInitParams();
27+
28+
$params['MAGE_DIRS']['base']['path'] = BP;
29+
$params = 'INTEGRATION_TEST_PARAMS="' . urldecode(http_build_query($params)) . '"';
30+
$integrationTestCommand = $params . ' ' . $command;
31+
$output = parent::execute($integrationTestCommand, $arguments);
32+
return $output;
33+
}
34+
}

dev/tests/integration/testsuite/Magento/Deploy/Console/Command/SetModeCommandTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
*
2424
* {@inheritdoc}
2525
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26-
26+
* @magentoDbIsolation enabled
27+
* @magentoAppIsolation enabled
2728
*/
2829
class SetModeCommandTest extends \PHPUnit\Framework\TestCase
2930
{
@@ -147,10 +148,6 @@ private function enableAndAssertProductionMode()
147148

148149
$this->assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode());
149150

150-
$this->assertContains('Deploy using quick strategy', $commandOutput);
151-
$this->assertContains('frontend/Magento/blank/en_US', $commandOutput);
152-
$this->assertContains('adminhtml/Magento/backend', $commandOutput);
153-
$this->assertContains('Execution time:', $commandOutput);
154151
$this->assertContains('Deployment of static content complete', $commandOutput);
155152
$this->assertContains('Enabled production mode', $commandOutput);
156153
}

setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function doOperation()
7474
$this->directoryScanner->scan($path, $this->data['filePatterns'], $this->data['excludePatterns'])
7575
);
7676
}
77-
$entities = $this->phpScanner->collectEntities($files['php']);
77+
$entities = isset($files['php']) ? $this->phpScanner->collectEntities($files['php']) : [];
7878
foreach ($entities as $entityName) {
7979
class_exists($entityName);
8080
}

0 commit comments

Comments
 (0)