22
33namespace BeyondCode \ErdGenerator \Tests ;
44
5- use BeyondCode \ErdGenerator \GraphBuilder ;
65use BeyondCode \ErdGenerator \ModelRelation ;
76use BeyondCode \ErdGenerator \RelationFinder ;
87use BeyondCode \ErdGenerator \Tests \Models \Post ;
98use BeyondCode \ErdGenerator \Tests \Models \User ;
109use BeyondCode \ErdGenerator \Tests \Models \Avatar ;
11- use BeyondCode \ErdGenerator \GenerateDiagramCommand ;
10+ use BeyondCode \ErdGenerator \Tests \ Models \ Comment ;
1211
1312class GetModelRelationsTest extends TestCase
1413{
@@ -20,6 +19,8 @@ public function it_can_find_model_relations()
2019
2120 $ relations = $ finder ->getModelRelations (User::class);
2221
22+ $ this ->assertCount (3 , $ relations );
23+
2324 $ posts = $ relations ['posts ' ];
2425
2526 $ this ->assertInstanceOf (ModelRelation::class, $ posts );
@@ -37,5 +38,14 @@ public function it_can_find_model_relations()
3738 $ this ->assertSame (Avatar::class, $ avatar ->getModel ());
3839 $ this ->assertSame ('id ' , $ avatar ->getLocalKey ());
3940 $ this ->assertSame ('user_id ' , $ avatar ->getForeignKey ());
41+
42+ $ avatar = $ relations ['comments ' ];
43+
44+ $ this ->assertInstanceOf (ModelRelation::class, $ avatar );
45+ $ this ->assertSame ('comments ' , $ avatar ->getName ());
46+ $ this ->assertSame ('BelongsToMany ' , $ avatar ->getType ());
47+ $ this ->assertSame (Comment::class, $ avatar ->getModel ());
48+ $ this ->assertSame (null , $ avatar ->getLocalKey ());
49+ $ this ->assertSame (null , $ avatar ->getForeignKey ());
4050 }
4151}
0 commit comments