File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
dev/tests/static/testsuite/Magento/Test/Integrity/DBSchema Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public function testMissingPrimaryKey()
36
36
$ errorMessage = '' ;
37
37
$ failedTableCtr = 0 ;
38
38
foreach ($ tablesSchemaDeclaration as $ tableName => $ tableSchemaDeclaration ) {
39
- if (!isset ($ tableSchemaDeclaration[ ' constraint ' ][ ' PRIMARY ' ] )) {
39
+ if (!$ this -> hasPrimaryKey ($ tableSchemaDeclaration )) {
40
40
$ message = '' ;
41
41
if (!empty ($ tableSchemaDeclaration ['modules ' ])) {
42
42
$ message = "It is declared in the following modules: \n" . implode (
@@ -54,6 +54,24 @@ public function testMissingPrimaryKey()
54
54
}
55
55
}
56
56
57
+ /**
58
+ * Check table schema and verify if the table has primary key defined.
59
+ *
60
+ * @param array $tableSchemaDeclaration
61
+ * @return bool
62
+ */
63
+ private function hasPrimaryKey (array $ tableSchemaDeclaration ): bool
64
+ {
65
+ if (isset ($ tableSchemaDeclaration ['constraint ' ])) {
66
+ foreach ($ tableSchemaDeclaration ['constraint ' ] as $ constraint ) {
67
+ if ($ constraint ['type ' ] == 'primary ' ) {
68
+ return true ;
69
+ }
70
+ }
71
+ }
72
+ return false ;
73
+ }
74
+
57
75
/**
58
76
* Get database schema declaration from file.
59
77
*
You can’t perform that action at this time.
0 commit comments