File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77use BeyondCode \ErdGenerator \Tests \Models \Avatar ;
88use BeyondCode \ErdGenerator \Tests \Models \Comment ;
99use BeyondCode \ErdGenerator \Tests \Models \Post ;
10+ use BeyondCode \ErdGenerator \Tests \Fixtures \ModelWithThrowingMethod ;
1011use BeyondCode \ErdGenerator \Tests \Models \User ;
1112use Illuminate \Support \Arr ;
13+ use Illuminate \Support \Facades \Log ;
1214use PHPUnit \Framework \Attributes \Test ;
1315
14-
1516class GetModelRelationsTest extends TestCase
1617{
17-
1818 #[Test]
1919 public function it_can_find_model_relations ()
2020 {
@@ -69,4 +69,24 @@ public function it_will_ignore_a_relation_if_it_is_excluded_on_config()
6969 $ this ->assertNull (Arr::get ($ relations , 'posts ' ));
7070 }
7171
72+ #[Test]
73+ public function it_logs_debug_when_method_throws_exception ()
74+ {
75+ Log::spy ();
76+
77+ $ finder = new RelationFinder ();
78+
79+ $ relations = $ finder ->getModelRelations (ModelWithThrowingMethod::class);
80+
81+ $ this ->assertCount (0 , $ relations );
82+
83+ Log::shouldHaveReceived ('debug ' )
84+ ->withArgs (function (string $ message ) {
85+ return str_contains ($ message , 'Could not analyze method ' )
86+ && str_contains ($ message , 'throwingMethod ' )
87+ && str_contains ($ message , 'Something went wrong ' );
88+ })
89+ ->once ();
90+ }
91+
7292}
You can’t perform that action at this time.
0 commit comments