Skip to content

Commit 7745875

Browse files
committed
MC-31618: Move static config to files - PLUGIN_LIST
- Fix static tests;;
1 parent 1505a25 commit 7745875

File tree

5 files changed

+79
-29
lines changed

5 files changed

+79
-29
lines changed

dev/tests/integration/framework/Magento/TestFramework/Application.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ protected function getCustomDirs()
714714
DirectoryList::TMP => [$path => "{$var}/tmp"],
715715
DirectoryList::UPLOAD => [$path => "{$var}/upload"],
716716
DirectoryList::PUB => [$path => "{$this->installDir}/pub"],
717-
DirectoryList::GENERATED_METADATA => [$path => "{$generated}/metadata"]
718717
];
719718
return $customDirs;
720719
}

dev/tests/integration/testsuite/Magento/Framework/Interception/PluginListGeneratorTest.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,34 @@ protected function setUp(): void
4545
{
4646
$this->application = Bootstrap::getInstance()->getBootstrap()->getApplication();
4747
$this->directoryList = new DirectoryList(BP, $this->getCustomDirs());
48-
$this->file = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
49-
DriverInterface::class
48+
$this->file = Bootstrap::getObjectManager()->create(DriverInterface::class);
49+
$reader = Bootstrap::getObjectManager()->create(
50+
\Magento\Framework\ObjectManager\Config\Reader\Dom\Proxy::class
5051
);
51-
$this->model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
52-
PluginListGenerator::class
52+
$scopeConfig = Bootstrap::getObjectManager()->create(\Magento\Framework\Config\Scope::class);
53+
$omConfig = Bootstrap::getObjectManager()->create(
54+
\Magento\Framework\Interception\ObjectManager\Config\Developer::class
55+
);
56+
$relations = Bootstrap::getObjectManager()->create(
57+
\Magento\Framework\ObjectManager\Relations\Runtime::class
58+
);
59+
$definitions = Bootstrap::getObjectManager()->create(
60+
\Magento\Framework\Interception\Definition\Runtime::class
61+
);
62+
$classDefinitions = Bootstrap::getObjectManager()->create(
63+
\Magento\Framework\ObjectManager\Definition\Runtime::class
64+
);
65+
$logger = Bootstrap::getObjectManager()->create(\Psr\Log\LoggerInterface\Proxy::class);
66+
$this->model = new PluginListGenerator(
67+
$reader,
68+
$scopeConfig,
69+
$omConfig,
70+
$relations,
71+
$definitions,
72+
$classDefinitions,
73+
$logger,
74+
$this->directoryList,
75+
['primary', 'global']
5376
);
5477
}
5578

@@ -71,7 +94,7 @@ public function testPluginListConfigGeneration()
7194
2 => 'response-http-page-cache'
7295
]
7396
];
74-
// Here in test I assume that this class below has 3 plugins. But the amount of plugins and class itself
97+
// Here in test is assumed that this class below has 3 plugins. But the amount of plugins and class itself
7598
// may vary. If it is changed, please update these assertions.
7699
$this->assertArrayHasKey(
77100
'Magento\\Framework\\App\\Response\\Http_sendResponse___self',

setup/src/Magento/Setup/Console/Command/DiCompileCommand.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
*/
66
namespace Magento\Setup\Console\Command;
77

8-
use Magento\Framework\ObjectManagerInterface;
8+
use Magento\Framework\App\ObjectManager;
99
use Magento\Framework\Filesystem\DriverInterface;
10+
use Magento\Framework\Filesystem\Io\File;
1011
use Symfony\Component\Console\Input\InputInterface;
1112
use Symfony\Component\Console\Output\OutputInterface;
1213
use Magento\Framework\Filesystem;
@@ -72,6 +73,11 @@ class DiCompileCommand extends Command
7273
*/
7374
private $componentRegistrar;
7475

76+
/**
77+
* @var File
78+
*/
79+
private $file;
80+
7581
/**
7682
* Constructor
7783
*
@@ -82,6 +88,8 @@ class DiCompileCommand extends Command
8288
* @param Filesystem $filesystem
8389
* @param DriverInterface $fileDriver
8490
* @param \Magento\Framework\Component\ComponentRegistrar $componentRegistrar
91+
* @param File|null $file
92+
* @throws \Magento\Setup\Exception
8593
*/
8694
public function __construct(
8795
DeploymentConfig $deploymentConfig,
@@ -90,7 +98,8 @@ public function __construct(
9098
ObjectManagerProvider $objectManagerProvider,
9199
Filesystem $filesystem,
92100
DriverInterface $fileDriver,
93-
ComponentRegistrar $componentRegistrar
101+
ComponentRegistrar $componentRegistrar,
102+
File $file = null
94103
) {
95104
$this->deploymentConfig = $deploymentConfig;
96105
$this->directoryList = $directoryList;
@@ -99,6 +108,7 @@ public function __construct(
99108
$this->filesystem = $filesystem;
100109
$this->fileDriver = $fileDriver;
101110
$this->componentRegistrar = $componentRegistrar;
111+
$this->file = $file ?: ObjectManager::getInstance()->get(File::class);
102112
parent::__construct();
103113
}
104114

@@ -227,10 +237,10 @@ private function getExcludedModulePaths(array $modulePaths)
227237
{
228238
$modulesByBasePath = [];
229239
foreach ($modulePaths as $modulePath) {
230-
$moduleDir = basename($modulePath);
231-
$vendorPath = dirname($modulePath);
232-
$vendorDir = basename($vendorPath);
233-
$basePath = dirname($vendorPath);
240+
$moduleDir = $this->file->getPathInfo($modulePath)['basename'];
241+
$vendorPath = $this->fileDriver->getParentDirectory($modulePath);
242+
$vendorDir = $this->file->getPathInfo($vendorPath)['basename'];
243+
$basePath = $this->fileDriver->getParentDirectory($vendorPath);
234244
$modulesByBasePath[$basePath][$vendorDir][] = $moduleDir;
235245
}
236246

@@ -360,12 +370,9 @@ private function configureObjectManager(OutputInterface $output)
360370
private function getOperationsConfiguration(
361371
array $compiledPathsList
362372
) {
363-
$excludePatterns = [];
364-
foreach ($this->excludedPathsList as $excludedPaths) {
365-
$excludePatterns = array_merge($excludedPaths, $excludePatterns);
366-
}
373+
$excludePatterns = array_merge([], ...array_values($this->excludedPathsList));
367374

368-
$operations = [
375+
return [
369376
OperationFactory::PROXY_GENERATOR => [],
370377
OperationFactory::REPOSITORY_GENERATOR => [
371378
'paths' => $compiledPathsList['application'],
@@ -402,7 +409,5 @@ private function getOperationsConfiguration(
402409
OperationFactory::APPLICATION_ACTION_LIST_GENERATOR => [],
403410
OperationFactory::PLUGIN_LIST_GENERATOR => [],
404411
];
405-
406-
return $operations;
407412
}
408413
}

setup/src/Magento/Setup/Module/Di/App/Task/OperationFactory.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,47 @@ class OperationFactory
1919
private $objectManager;
2020

2121
/**
22-
* Area
22+
* Area config generator operation definition
2323
*/
2424
const AREA_CONFIG_GENERATOR = 'area';
2525

2626
/**
27-
* Interception
27+
* Interception operation definition
2828
*/
2929
const INTERCEPTION = 'interception';
3030

3131
/**
32-
* Interception cache
32+
* Interception cache operation definition
3333
*/
3434
const INTERCEPTION_CACHE = 'interception_cache';
3535

3636
/**
37-
* Repository generator
37+
* Repository generator operation definition
3838
*/
3939
const REPOSITORY_GENERATOR = 'repository_generator';
4040

4141
/**
42-
* Proxy generator
42+
* Proxy generator operation definition
4343
*/
4444
const PROXY_GENERATOR = 'proxy_generator';
4545

4646
/**
47-
* Service data attributes generator
47+
* Service data attributes generator operation definition
4848
*/
4949
const DATA_ATTRIBUTES_GENERATOR = 'extension_attributes_generator';
5050

5151
/**
52-
* Application code generator
52+
* Application code generator operation definition
5353
*/
5454
const APPLICATION_CODE_GENERATOR = 'application_code_generator';
5555

5656
/**
57-
* Application action list generator
57+
* Application action list generator operation definition
5858
*/
5959
const APPLICATION_ACTION_LIST_GENERATOR = 'application_action_list_generator';
6060

6161
/**
62-
* Plugin list generator
62+
* Plugin list generator operation definition
6363
*/
6464
const PLUGIN_LIST_GENERATOR = 'plugin_list_generator';
6565

setup/src/Magento/Setup/Test/Unit/Console/Command/DiCompileCommandTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class DiCompileCommandTest extends TestCase
6565
/** @var OutputFormatterInterface|MockObject */
6666
private $outputFormatterMock;
6767

68+
/** @var Filesystem\Io\File|MockObject */
69+
private $fileMock;
70+
6871
protected function setUp(): void
6972
{
7073
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
@@ -96,6 +99,14 @@ protected function setUp(): void
9699
$this->fileDriverMock = $this->getMockBuilder(File::class)
97100
->disableOriginalConstructor()
98101
->getMock();
102+
$this->fileDriverMock->method('getParentDirectory')->willReturnMap(
103+
[
104+
['/path/to/module/one', '/path/to/module'],
105+
['/path/to/module', '/path/to'],
106+
['/path (1)/to/module/two', '/path (1)/to/module'],
107+
['/path (1)/to/module', '/path (1)/to'],
108+
]
109+
);
99110
$this->componentRegistrarMock = $this->createMock(ComponentRegistrar::class);
100111
$this->componentRegistrarMock->expects($this->any())->method('getPaths')->willReturnMap([
101112
[ComponentRegistrar::MODULE, ['/path/to/module/one', '/path (1)/to/module/two']],
@@ -108,6 +119,17 @@ protected function setUp(): void
108119
$this->outputMock = $this->getMockForAbstractClass(OutputInterface::class);
109120
$this->outputMock->method('getFormatter')
110121
->willReturn($this->outputFormatterMock);
122+
$this->fileMock = $this->getMockBuilder(Filesystem\Io\File::class)
123+
->disableOriginalConstructor()
124+
->getMock();
125+
$this->fileMock->method('getPathInfo')->willReturnMap(
126+
[
127+
['/path/to/module/one', ['basename' => 'one']],
128+
['/path/to/module', ['basename' => 'module']],
129+
['/path (1)/to/module/two', ['basename' => 'two']],
130+
['/path (1)/to/module', ['basename' => 'module']],
131+
]
132+
);
111133

112134
$this->command = new DiCompileCommand(
113135
$this->deploymentConfigMock,
@@ -116,7 +138,8 @@ protected function setUp(): void
116138
$objectManagerProviderMock,
117139
$this->filesystemMock,
118140
$this->fileDriverMock,
119-
$this->componentRegistrarMock
141+
$this->componentRegistrarMock,
142+
$this->fileMock
120143
);
121144
}
122145

0 commit comments

Comments
 (0)