Skip to content

Commit 7953e54

Browse files
committed
Copyright format adjust, clean code and fix cyclomatic complexity in unit test
1 parent 7acdc6d commit 7953e54

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2025 Adobe
3+
* Copyright 2015 Adobe
44
* All Rights Reserved.
55
*/
66

@@ -166,16 +166,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
166166

167167
$modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE);
168168
$moduleStatuses = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_MODULES);
169+
169170
if (!$moduleStatuses || !is_array($moduleStatuses)) {
171+
$output->writeln('<error>Deployment config not available.</error>');
170172
return Cli::RETURN_FAILURE;
171173
}
172-
$enabledModuleStatuses = array_filter($moduleStatuses, function ($enabled) {
173-
return $enabled === 1;
174-
});
175-
$enabledModules = array_keys($enabledModuleStatuses);
176174

177-
$modulePathsEnabled = array_filter($modulePaths, function ($path, $module) use ($enabledModules) {
178-
return in_array($module, $enabledModules, true);
175+
$modulePathsEnabled = array_filter($modulePaths, function ($path, $module) use ($moduleStatuses) {
176+
return ($moduleStatuses[$module] ?? 0) === 1;
179177
}, ARRAY_FILTER_USE_BOTH);
180178

181179
$libraryPaths = $this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY);

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright 2025 Adobe
3+
* Copyright 2015 Adobe
44
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
@@ -188,25 +188,21 @@ public function testExecute()
188188
->with(ProgressBar::class)
189189
->willReturn($progressBar);
190190

191+
$operations = [
192+
OperationFactory::REPOSITORY_GENERATOR,
193+
OperationFactory::DATA_ATTRIBUTES_GENERATOR,
194+
OperationFactory::APPLICATION_CODE_GENERATOR,
195+
OperationFactory::INTERCEPTION,
196+
OperationFactory::AREA_CONFIG_GENERATOR,
197+
OperationFactory::INTERCEPTION_CACHE,
198+
OperationFactory::APPLICATION_ACTION_LIST_GENERATOR,
199+
OperationFactory::PLUGIN_LIST_GENERATOR,
200+
];
191201
$this->managerMock->expects($this->exactly(9))->method('addOperation')
192-
->willReturnCallback(function ($arg1, $arg2) {
202+
->willReturnCallback(function ($arg1, $arg2) use ($operations) {
193203
if ($arg1 == OperationFactory::PROXY_GENERATOR && empty($arg2)) {
194204
return null;
195-
} elseif ($arg1 == OperationFactory::REPOSITORY_GENERATOR) {
196-
return null;
197-
} elseif ($arg1 == OperationFactory::DATA_ATTRIBUTES_GENERATOR) {
198-
return null;
199-
} elseif ($arg1 == OperationFactory::APPLICATION_CODE_GENERATOR) {
200-
return null;
201-
} elseif ($arg1 == OperationFactory::INTERCEPTION) {
202-
return null;
203-
} elseif ($arg1 == OperationFactory::AREA_CONFIG_GENERATOR) {
204-
return null;
205-
} elseif ($arg1 == OperationFactory::INTERCEPTION_CACHE) {
206-
return null;
207-
} elseif ($arg1 == OperationFactory::APPLICATION_ACTION_LIST_GENERATOR) {
208-
return null;
209-
} elseif ($arg1 == OperationFactory::PLUGIN_LIST_GENERATOR) {
205+
} elseif (in_array($arg1, $operations)) {
210206
return null;
211207
}
212208
});

0 commit comments

Comments
 (0)