@@ -65,8 +65,11 @@ public function it_can_parse_to_debuggable_array(): void
6565 'title ' => HttpApiProblem::getTitleForStatusCode (500 ),
6666 'detail ' => 'message ' ,
6767 'exception ' => [
68+ 'type ' => Exception::class,
6869 'message ' => 'message ' ,
6970 'code ' => 500 ,
71+ 'line ' => $ exception ->getLine (),
72+ 'file ' => $ exception ->getFile (),
7073 'trace ' => $ exception ->getTraceAsString (),
7174 'previous ' => [],
7275 ],
@@ -86,22 +89,44 @@ public function it_contains_flattened_previous_exceptions_in_debuggable_output()
8689 'title ' => HttpApiProblem::getTitleForStatusCode (500 ),
8790 'detail ' => 'message ' ,
8891 'exception ' => [
92+ 'type ' => Exception::class,
8993 'message ' => 'message ' ,
9094 'code ' => 0 ,
95+ 'line ' => $ exception ->getLine (),
96+ 'file ' => $ exception ->getFile (),
9197 'trace ' => $ exception ->getTraceAsString (),
9298 'previous ' => [
9399 [
100+ 'type ' => Exception::class,
94101 'message ' => 'previous ' ,
95102 'code ' => 2 ,
103+ 'line ' => $ previous ->getLine (),
104+ 'file ' => $ previous ->getFile (),
96105 'trace ' => $ previous ->getTraceAsString (),
97106 ],
98107 [
108+ 'type ' => Exception::class,
99109 'message ' => 'first ' ,
100110 'code ' => 1 ,
111+ 'line ' => $ first ->getLine (),
112+ 'file ' => $ first ->getFile (),
101113 'trace ' => $ first ->getTraceAsString (),
102114 ],
103115 ],
104116 ],
105117 ]);
106118 }
119+
120+ public function it_uses_the_class_of_the_exception_when_no_message_exists (): void
121+ {
122+ $ exception = new Exception ();
123+ $ this ->beConstructedWith ($ exception );
124+
125+ $ this ->toArray ()->shouldBe ([
126+ 'status ' => 500 ,
127+ 'type ' => HttpApiProblem::TYPE_HTTP_RFC ,
128+ 'title ' => HttpApiProblem::getTitleForStatusCode (500 ),
129+ 'detail ' => Exception::class,
130+ ]);
131+ }
107132}
0 commit comments