22
33namespace BeyondCode \ErdGenerator \Tests ;
44
5+ use BeyondCode \ErdGenerator \Tests \Models \Avatar ;
6+ use BeyondCode \ErdGenerator \Tests \Models \User ;
57use Spatie \Snapshots \MatchesSnapshots ;
68use Illuminate \Support \Facades \Artisan ;
9+ use PHPUnit \Framework \Attributes \Test ;
710
811class GenerationTest extends TestCase
912{
1013 use MatchesSnapshots;
1114
12- /** @test */
15+ #[Test]
1316 public function it_generated_graphviz_for_test_models ()
1417 {
1518 $ this ->app ['config ' ]->set ('erd-generator.use_db_schema ' , false );
@@ -22,7 +25,7 @@ public function it_generated_graphviz_for_test_models()
2225 $ this ->assertMatchesSnapshot (Artisan::output ());
2326 }
2427
25- /** @test */
28+ #[Test]
2629 public function it_generated_graphviz_for_test_models_with_db_columns_and_types ()
2730 {
2831 $ this ->app ['config ' ]->set ('erd-generator.directories ' , [__DIR__ . '/Models ' ]);
@@ -34,7 +37,7 @@ public function it_generated_graphviz_for_test_models_with_db_columns_and_types(
3437 $ this ->assertMatchesSnapshot (Artisan::output ());
3538 }
3639
37- /** @test */
40+ #[Test]
3841 public function it_generated_graphviz_for_test_models_with_db_columns ()
3942 {
4043 $ this ->app ['config ' ]->set ('erd-generator.use_column_types ' , false );
@@ -47,7 +50,7 @@ public function it_generated_graphviz_for_test_models_with_db_columns()
4750 $ this ->assertMatchesSnapshot (Artisan::output ());
4851 }
4952
50- /** @test */
53+ #[Test]
5154 public function it_generated_graphviz_for_test_models_with_db_columns_with_some_excluded_on_config ()
5255 {
5356 $ this ->app ['config ' ]->set ('erd-generator.use_column_types ' , false );
@@ -64,7 +67,31 @@ public function it_generated_graphviz_for_test_models_with_db_columns_with_some_
6467 $ this ->assertMatchesSnapshot (Artisan::output ());
6568 }
6669
67- /** @test */
70+ #[Test]
71+ public function it_generated_graphviz_for_test_models_with_aliases ()
72+ {
73+ $ this ->app ['config ' ]->set ('erd-generator.directories ' , [__DIR__ . '/Models ' ]);
74+ $ this ->app ['config ' ]->set ('erd-generator.aliases ' , [
75+ Avatar::class => 123 ,
76+ User::class => 'CustomUser '
77+ ]);
78+
79+ Artisan::call ('generate:erd ' , [
80+ '--format ' => 'text '
81+ ]);
82+
83+ $ output = Artisan::output ();
84+
85+ $ this ->assertStringContainsString ('>CustomUser< ' , $ output );
86+
87+ // Avatar class must not be renamed, as the alias was not a string
88+ $ this ->assertStringContainsString ('>Avatar< ' , $ output );
89+
90+ // Comment class must not be renamed, as it was not included in the aliases array
91+ $ this ->assertStringContainsString ('>Comment< ' , $ output );
92+ }
93+
94+ #[Test]
6895 public function it_generated_graphviz_in_jpeg_format ()
6996 {
7097 $ this ->app ['config ' ]->set ('erd-generator.directories ' , [__DIR__ . '/Models ' ]);
@@ -76,7 +103,7 @@ public function it_generated_graphviz_in_jpeg_format()
76103 $ this ->assertStringContainsString ('Wrote diagram to graph.jpeg ' , Artisan::output ());
77104 }
78105
79- /** @test */
106+ #[Test]
80107 public function it_generates_text_output_file_with_text_output_option ()
81108 {
82109 $ this ->app ['config ' ]->set ('erd-generator.directories ' , [__DIR__ . '/Models ' ]);
@@ -106,7 +133,7 @@ public function it_generates_text_output_file_with_text_output_option()
106133 }
107134 }
108135
109- /** @test */
136+ #[Test]
110137 public function it_generates_structured_text_output_for_txt_extension ()
111138 {
112139 $ this ->app ['config ' ]->set ('erd-generator.directories ' , [__DIR__ . '/Models ' ]);
@@ -137,7 +164,7 @@ public function it_generates_structured_text_output_for_txt_extension()
137164 }
138165 }
139166
140- /** @test */
167+ #[Test]
141168 public function it_generates_structured_text_output_with_correct_content ()
142169 {
143170 $ this ->app ['config ' ]->set ('erd-generator.directories ' , [__DIR__ . '/Models ' ]);
0 commit comments