1414use 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 */
1919class 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