Skip to content

Commit f04a5a9

Browse files
committed
#18075: Static test fix.
1 parent 309e906 commit f04a5a9

File tree

6 files changed

+57
-43
lines changed

6 files changed

+57
-43
lines changed

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@
2828
use Magento\Framework\Setup\InstallSchemaInterface;
2929
use Magento\Framework\Setup\LoggerInterface;
3030
use Magento\Framework\Setup\ModuleDataSetupInterface;
31-
use Magento\Framework\Setup\PatchApplierInterface;
31+
use Magento\Framework\Setup\Patch\PatchApplier;
32+
use Magento\Framework\Setup\Patch\PatchApplierFactory;
3233
use Magento\Framework\Setup\SchemaPersistor;
3334
use Magento\Framework\Setup\SchemaSetupInterface;
3435
use Magento\Framework\Setup\UpgradeDataInterface;
3536
use Magento\Framework\Setup\UpgradeSchemaInterface;
3637
use Magento\Setup\Console\Command\InstallCommand;
3738
use Magento\Setup\Controller\ResponseTypeInterface;
3839
use Magento\Setup\Model\ConfigModel as SetupConfigModel;
39-
use Magento\Framework\Setup\Patch\PatchApplier;
40-
use Magento\Framework\Setup\Patch\PatchApplierFactory;
4140
use Magento\Setup\Module\ConnectionFactory;
4241
use Magento\Setup\Module\DataSetupFactory;
4342
use Magento\Setup\Module\SetupFactory;
@@ -516,6 +515,7 @@ public function checkExtensions()
516515
) {
517516
$errorMsg = "Missing following extensions: '"
518517
. implode("' '", $phpExtensionsCheckResult['data']['missing']) . "'";
518+
// phpcs:ignore Magento2.Exceptions.DirectThrow
519519
throw new \Exception($errorMsg);
520520
}
521521
}
@@ -900,6 +900,7 @@ private function throwExceptionForNotWritablePaths(array $paths)
900900
{
901901
if ($paths) {
902902
$errorMsg = "Missing write permissions to the following paths:" . PHP_EOL . implode(PHP_EOL, $paths);
903+
// phpcs:ignore Magento2.Exceptions.DirectThrow
903904
throw new \Exception($errorMsg);
904905
}
905906
}
@@ -941,10 +942,12 @@ private function handleDBSchemaData($setup, $type, array $request)
941942
if ($type === 'schema') {
942943
$patchApplier = $this->patchApplierFactory->create(['schemaSetup' => $setup]);
943944
} elseif ($type === 'data') {
944-
$patchApplier = $this->patchApplierFactory->create([
945-
'moduleDataSetup' => $setup,
946-
'objectManager' => $this->objectManagerProvider->get()
947-
]);
945+
$patchApplier = $this->patchApplierFactory->create(
946+
[
947+
'moduleDataSetup' => $setup,
948+
'objectManager' => $this->objectManagerProvider->get()
949+
]
950+
);
948951
}
949952

950953
foreach ($moduleNames as $moduleName) {
@@ -1311,7 +1314,9 @@ public function cleanupDb()
13111314
//If for different shards one database was specified - no need to clean it few times
13121315
if (!in_array($dbName, $cleanedUpDatabases)) {
13131316
$this->log->log("Cleaning up database {$dbName}");
1317+
// phpcs:ignore Magento2.SQL.RawQuery
13141318
$connection->query("DROP DATABASE IF EXISTS {$dbName}");
1319+
// phpcs:ignore Magento2.SQL.RawQuery
13151320
$connection->query("CREATE DATABASE IF NOT EXISTS {$dbName}");
13161321
$cleanedUpDatabases[] = $dbName;
13171322
}
@@ -1511,18 +1516,22 @@ private function cleanupGeneratedFiles()
15111516
*/
15121517
private function isAdminDataSet($request)
15131518
{
1514-
$adminData = array_filter($request, function ($value, $key) {
1515-
return in_array(
1516-
$key,
1517-
[
1518-
AdminAccount::KEY_EMAIL,
1519-
AdminAccount::KEY_FIRST_NAME,
1520-
AdminAccount::KEY_LAST_NAME,
1521-
AdminAccount::KEY_USER,
1522-
AdminAccount::KEY_PASSWORD,
1523-
]
1524-
) && $value !== null;
1525-
}, ARRAY_FILTER_USE_BOTH);
1519+
$adminData = array_filter(
1520+
$request,
1521+
function ($value, $key) {
1522+
return in_array(
1523+
$key,
1524+
[
1525+
AdminAccount::KEY_EMAIL,
1526+
AdminAccount::KEY_FIRST_NAME,
1527+
AdminAccount::KEY_LAST_NAME,
1528+
AdminAccount::KEY_USER,
1529+
AdminAccount::KEY_PASSWORD,
1530+
]
1531+
) && $value !== null;
1532+
},
1533+
ARRAY_FILTER_USE_BOTH
1534+
);
15261535

15271536
return !empty($adminData);
15281537
}

setup/src/Magento/Setup/Test/Unit/Model/ConfigGeneratorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use Magento\Setup\Model\ConfigGenerator;
1414
use Magento\Setup\Model\ConfigOptionsList\DriverOptions;
1515

16+
/**
17+
* Test for Magento\Setup\Model\ConfigGenerator class.
18+
*/
1619
class ConfigGeneratorTest extends \PHPUnit\Framework\TestCase
1720
{
1821
/**

setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use PHPUnit\Framework\TestCase;
1818
use Magento\Setup\Model\ConfigOptionsList\DriverOptions;
1919

20+
/**
21+
* Test for Magento\Setup\Model\ConfigGenerator class.
22+
*/
2023
class ConfigGeneratorTest extends TestCase
2124
{
2225
/**
@@ -71,6 +74,7 @@ public function testCreateCryptConfigWithoutInput()
7174
{
7275
$returnValue = $this->configGeneratorObject->createCryptConfig([]);
7376
$this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey());
77+
// phpcs:ignore Magento2.Security.InsecureFunction
7478
$this->assertEquals(['crypt' => ['key' => md5('key')]], $returnValue->getData());
7579
}
7680

setup/src/Magento/Setup/Validator/AdminCredentialsValidator.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,16 @@ public function validate(array $data)
6666
{
6767
$driverOptions = $this->driverOptions->getDriverOptions($data);
6868

69-
$dbConnection = $this->connectionFactory->create([
70-
ConfigOption::KEY_NAME => $data[ConfigOption::INPUT_KEY_DB_NAME],
71-
ConfigOption::KEY_HOST => $data[ConfigOption::INPUT_KEY_DB_HOST],
72-
ConfigOption::KEY_USER => $data[ConfigOption::INPUT_KEY_DB_USER],
73-
ConfigOption::KEY_PASSWORD => $data[ConfigOption::INPUT_KEY_DB_PASSWORD],
74-
ConfigOption::KEY_PREFIX => $data[ConfigOption::INPUT_KEY_DB_PREFIX],
75-
ConfigOption::KEY_DRIVER_OPTIONS => $driverOptions
76-
]);
69+
$dbConnection = $this->connectionFactory->create(
70+
[
71+
ConfigOption::KEY_NAME => $data[ConfigOption::INPUT_KEY_DB_NAME],
72+
ConfigOption::KEY_HOST => $data[ConfigOption::INPUT_KEY_DB_HOST],
73+
ConfigOption::KEY_USER => $data[ConfigOption::INPUT_KEY_DB_USER],
74+
ConfigOption::KEY_PASSWORD => $data[ConfigOption::INPUT_KEY_DB_PASSWORD],
75+
ConfigOption::KEY_PREFIX => $data[ConfigOption::INPUT_KEY_DB_PREFIX],
76+
ConfigOption::KEY_DRIVER_OPTIONS => $driverOptions
77+
]
78+
);
7779

7880
$adminAccount = $this->adminAccountFactory->create(
7981
$dbConnection,

setup/src/Magento/Setup/Validator/DbValidator.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,16 @@ public function checkDatabaseConnectionWithDriverOptions(
100100
$driverOptions = []
101101
) {
102102
// establish connection to information_schema view to retrieve information about user and table privileges
103-
$connection = $this->connectionFactory->create([
104-
ConfigOptionsListConstants::KEY_NAME => 'information_schema',
105-
ConfigOptionsListConstants::KEY_HOST => $dbHost,
106-
ConfigOptionsListConstants::KEY_USER => $dbUser,
107-
ConfigOptionsListConstants::KEY_PASSWORD => $dbPass,
108-
ConfigOptionsListConstants::KEY_ACTIVE => true,
109-
ConfigOptionsListConstants::KEY_DRIVER_OPTIONS => $driverOptions,
110-
]);
103+
$connection = $this->connectionFactory->create(
104+
[
105+
ConfigOptionsListConstants::KEY_NAME => 'information_schema',
106+
ConfigOptionsListConstants::KEY_HOST => $dbHost,
107+
ConfigOptionsListConstants::KEY_USER => $dbUser,
108+
ConfigOptionsListConstants::KEY_PASSWORD => $dbPass,
109+
ConfigOptionsListConstants::KEY_ACTIVE => true,
110+
ConfigOptionsListConstants::KEY_DRIVER_OPTIONS => $driverOptions,
111+
]
112+
);
111113

112114
if (!$connection) {
113115
throw new \Magento\Setup\Exception('Database connection failure.');
@@ -182,6 +184,7 @@ private function checkDatabasePrivileges(\Magento\Framework\DB\Adapter\AdapterIn
182184
];
183185

184186
// check global privileges
187+
// phpcs:ignore Magento2.SQL.RawQuery
185188
$userPrivilegesQuery = "SELECT PRIVILEGE_TYPE FROM USER_PRIVILEGES "
186189
. "WHERE REPLACE(GRANTEE, '\'', '') = current_user()";
187190
$grantInfo = $connection->query($userPrivilegesQuery)->fetchAll(\PDO::FETCH_NUM);
@@ -190,6 +193,7 @@ private function checkDatabasePrivileges(\Magento\Framework\DB\Adapter\AdapterIn
190193
}
191194

192195
// check database privileges
196+
// phpcs:ignore Magento2.SQL.RawQuery
193197
$schemaPrivilegesQuery = "SELECT PRIVILEGE_TYPE FROM SCHEMA_PRIVILEGES " .
194198
"WHERE '$dbName' LIKE TABLE_SCHEMA AND REPLACE(GRANTEE, '\'', '') = current_user()";
195199
$grantInfo = $connection->query($schemaPrivilegesQuery)->fetchAll(\PDO::FETCH_NUM);

vendor/.htaccess

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)