Skip to content

Commit 17ba28a

Browse files
committed
B2B-1671: Detect Missing Primary Key in Table Schema Test
1 parent 0626112 commit 17ba28a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

dev/tests/static/testsuite/Magento/Test/Integrity/DBSchema/PrimaryKeyTest.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,19 @@
1414
use PHPUnit\Framework\TestCase;
1515

1616
/**
17-
* Test for existance of primary key in database tables
17+
* Test for finding database tables missing primary key
1818
*/
1919
class PrimaryKeyTest extends TestCase
2020
{
21-
private $blockWhitelist;
22-
2321
/**
24-
* Check existance of database tables' primary key
22+
* Check missing database tables' primary key
2523
*
2624
* @throws LocalizedException
2725
*/
2826
public function testMissingPrimaryKey()
2927
{
30-
$exemptionList = $this->getExemptionlist();
31-
$tablesSchemaDeclaration = $this->getDbSchemaDeclaration()['table'];
28+
$exemptionList = $this->getExemptionList();
29+
$tablesSchemaDeclaration = $this->getDbSchemaDeclarations()['table'];
3230
$exemptionList = array_intersect(array_keys($tablesSchemaDeclaration), $exemptionList);
3331
foreach ($exemptionList as $exemptionTableName) {
3432
unset($tablesSchemaDeclaration[$exemptionTableName]);
@@ -91,9 +89,9 @@ private function getDbSchemaDeclarationByFile(string $filePath): array
9189
* @return array
9290
* @throws LocalizedException
9391
*/
94-
private function getDbSchemaDeclaration(): array
92+
private function getDbSchemaDeclarations(): array
9593
{
96-
$declaration = [];
94+
$declarations = [];
9795
foreach (Files::init()->getDbSchemaFiles() as $filePath) {
9896
$filePath = reset($filePath);
9997
preg_match('#app/code/(\w+/\w+)#', $filePath, $result);
@@ -107,23 +105,24 @@ private function getDbSchemaDeclaration(): array
107105
array_push($tableDeclaration['modules'], $moduleName);
108106
$moduleDeclaration = array_replace_recursive(
109107
$moduleDeclaration,
110-
['table' => [
111-
$tableName => $tableDeclaration,
112-
]
108+
[
109+
'table' => [
110+
$tableName => $tableDeclaration,
111+
]
113112
]
114113
);
115114
}
116-
$declaration = array_merge_recursive($declaration, $moduleDeclaration);
115+
$declarations = array_merge_recursive($declarations, $moduleDeclaration);
117116
}
118-
return $declaration;
117+
return $declarations;
119118
}
120119

121120
/**
122121
* Return primary key exemption tables list
123122
*
124123
* @return string[]
125124
*/
126-
private function getExemptionlist(): array
125+
private function getExemptionList(): array
127126
{
128127
$exemptionListFiles = str_replace(
129128
'\\',

0 commit comments

Comments
 (0)