@@ -259,5 +259,31 @@ public function testCache() {
259259 $ r2 = $ this ->assertNotFalse ($ cache ->fetch ('mykey_shortest_role_right```role ' ));
260260 $ this ->assertTrue ($ r1 === $ r2 );
261261 }
262+
263+ /**
264+ * @expectedException \Mouf\Database\SchemaAnalyzer\ShortestPathAmbiguityException
265+ */
266+ public function testAmbiguityException () {
267+ $ schema = $ this ->getBaseSchema ();
268+
269+ $ role_right = $ schema ->createTable ("role_right " );
270+ $ role_right ->addColumn ("role_id " , "integer " , array ("unsigned " => true ));
271+ $ role_right ->addColumn ("right_id " , "integer " , array ("unsigned " => true ));
272+ $ role_right ->addForeignKeyConstraint ($ schema ->getTable ('role ' ), array ("role_id " ), array ("id " ), array ("onUpdate " => "CASCADE " ));
273+ $ role_right ->addForeignKeyConstraint ($ schema ->getTable ('right ' ), array ("right_id " ), array ("id " ), array ("onUpdate " => "CASCADE " ));
274+ $ role_right ->setPrimaryKey (["role_id " , "right_id " ]);
275+
276+ $ role_right2 = $ schema ->createTable ("role_right2 " );
277+ $ role_right2 ->addColumn ("role_id " , "integer " , array ("unsigned " => true ));
278+ $ role_right2 ->addColumn ("right_id " , "integer " , array ("unsigned " => true ));
279+ $ role_right2 ->addForeignKeyConstraint ($ schema ->getTable ('role ' ), array ("role_id " ), array ("id " ), array ("onUpdate " => "CASCADE " ));
280+ $ role_right2 ->addForeignKeyConstraint ($ schema ->getTable ('right ' ), array ("right_id " ), array ("id " ), array ("onUpdate " => "CASCADE " ));
281+ $ role_right2 ->setPrimaryKey (["role_id " , "right_id " ]);
282+
283+ $ schemaAnalyzer = new SchemaAnalyzer ($ schema );
284+
285+ $ schemaAnalyzer ->getShortestPath ("role " , "right " );
286+ }
287+
262288}
263289
0 commit comments