22
33namespace SMartins \Exceptions \Tests \Unit ;
44
5+ use InvalidArgumentException ;
6+ use SMartins \Exceptions \JsonApi \Error ;
57use SMartins \Exceptions \Tests \TestCase ;
68use SMartins \Exceptions \Handlers \Handler ;
9+ use SMartins \Exceptions \JsonApi \ErrorCollection ;
710
811class AbstractHandlerTest extends TestCase
912{
@@ -13,4 +16,39 @@ public function testShouldReturnsTheHandlerClassOnGetExceptionHandler()
1316
1417 $ this ->assertInstanceOf (Handler::class, $ handler ->getExceptionHandler ());
1518 }
19+
20+ public function testGetDefaultHandler ()
21+ {
22+ $ handler = new Handler (new \Exception );
23+
24+ $ this ->assertInstanceOf (Handler::class, $ handler ->defaultHandler ());
25+ }
26+
27+ public function testValidateHandledExceptionWithArrayOfErrors ()
28+ {
29+ $ errors = [new Error ];
30+
31+ $ handler = new Handler (new \Exception );
32+ $ validated = $ handler ->validatedHandledException ($ errors );
33+
34+ $ this ->assertInstanceOf (ErrorCollection::class, $ validated );
35+ }
36+
37+ public function testValidateHandledExceptionWithCollectionOfErrors ()
38+ {
39+ $ errors = collect ([new Error ]);
40+
41+ $ handler = new Handler (new \Exception );
42+ $ validated = $ handler ->validatedHandledException ($ errors );
43+
44+ $ this ->assertInstanceOf (ErrorCollection::class, $ validated );
45+ }
46+
47+ public function testValidateHandledExceptionWithInvalidArgument ()
48+ {
49+ $ this ->expectException (InvalidArgumentException::class);
50+
51+ $ handler = new Handler (new \Exception );
52+ $ handler ->validatedHandledException ('invalid ' );
53+ }
1654}
0 commit comments