2
2
3
3
namespace BeyondCode \ErdGenerator \Tests ;
4
4
5
- use BeyondCode \ErdGenerator \GraphBuilder ;
6
5
use BeyondCode \ErdGenerator \ModelRelation ;
7
6
use BeyondCode \ErdGenerator \RelationFinder ;
8
7
use BeyondCode \ErdGenerator \Tests \Models \Post ;
9
8
use BeyondCode \ErdGenerator \Tests \Models \User ;
10
9
use BeyondCode \ErdGenerator \Tests \Models \Avatar ;
11
- use BeyondCode \ErdGenerator \GenerateDiagramCommand ;
10
+ use BeyondCode \ErdGenerator \Tests \ Models \ Comment ;
12
11
13
12
class GetModelRelationsTest extends TestCase
14
13
{
@@ -20,6 +19,8 @@ public function it_can_find_model_relations()
20
19
21
20
$ relations = $ finder ->getModelRelations (User::class);
22
21
22
+ $ this ->assertCount (3 , $ relations );
23
+
23
24
$ posts = $ relations ['posts ' ];
24
25
25
26
$ this ->assertInstanceOf (ModelRelation::class, $ posts );
@@ -37,5 +38,14 @@ public function it_can_find_model_relations()
37
38
$ this ->assertSame (Avatar::class, $ avatar ->getModel ());
38
39
$ this ->assertSame ('id ' , $ avatar ->getLocalKey ());
39
40
$ 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 ());
40
50
}
41
51
}
0 commit comments