@@ -64,7 +64,7 @@ public function testJointureTableDetectionWith3Columns() {
6464 $ schema = $ this ->getBaseSchema ();
6565
6666 $ role_right = $ schema ->createTable ("role_right " );
67- $ role_right ->addColumn ("id " , "integer " , array ("unsigned " => true ));
67+ $ role_right ->addColumn ("id " , "integer " , array ("unsigned " => true , " autoincrement " => true ));
6868 $ role_right ->addColumn ("role_id " , "integer " , array ("unsigned " => true ));
6969 $ role_right ->addColumn ("right_id " , "integer " , array ("unsigned " => true ));
7070
@@ -82,11 +82,29 @@ public function testJointureTableDetectionWith3Columns() {
8282 }
8383 }
8484
85+ public function testJointureTableDetectionWith3ColumnsNoAutoincrement () {
86+ $ schema = $ this ->getBaseSchema ();
87+
88+ $ role_right = $ schema ->createTable ("role_right " );
89+ $ role_right ->addColumn ("id " , "integer " , array ("unsigned " => true , "autoincrement " => false ));
90+ $ role_right ->addColumn ("role_id " , "integer " , array ("unsigned " => true ));
91+ $ role_right ->addColumn ("right_id " , "integer " , array ("unsigned " => true ));
92+
93+ $ role_right ->addForeignKeyConstraint ($ schema ->getTable ('role ' ), array ("role_id " ), array ("id " ), array ("onUpdate " => "CASCADE " ));
94+ $ role_right ->addForeignKeyConstraint ($ schema ->getTable ('right ' ), array ("right_id " ), array ("id " ), array ("onUpdate " => "CASCADE " ));
95+ $ role_right ->setPrimaryKey (["id " ]);
96+
97+ $ schemaAnalyzer = new SchemaAnalyzer ($ schema );
98+ $ junctionTables = $ schemaAnalyzer ->detectJunctionTables ();
99+
100+ $ this ->assertCount (0 , $ junctionTables );
101+ }
102+
85103 public function testJointureTableDetectionWith4Columns () {
86104 $ schema = $ this ->getBaseSchema ();
87105
88106 $ role_right = $ schema ->createTable ("role_right " );
89- $ role_right ->addColumn ("id " , "integer " , array ("unsigned " => true ));
107+ $ role_right ->addColumn ("id " , "integer " , array ("unsigned " => true , " autoincrement " => true ));
90108 $ role_right ->addColumn ("role_id " , "integer " , array ("unsigned " => true ));
91109 $ role_right ->addColumn ("right_id " , "integer " , array ("unsigned " => true ));
92110 $ role_right ->addColumn ("label " , "string " , array ("length " => 32 ));
@@ -140,7 +158,7 @@ public function testJointureTableDetectionWith3ColumnsWithPkIsFk() {
140158 $ schema = $ this ->getBaseSchema ();
141159
142160 $ role_right = $ schema ->createTable ("role_right " );
143- $ role_right ->addColumn ("id " , "integer " , array ("unsigned " => true ));
161+ $ role_right ->addColumn ("id " , "integer " , array ("unsigned " => true , " autoincrement " => true ));
144162 $ role_right ->addColumn ("role_id " , "integer " , array ("unsigned " => true ));
145163 $ role_right ->addColumn ("right_id " , "integer " , array ("unsigned " => true ));
146164
0 commit comments