@@ -43,6 +43,46 @@ public function test_with_an_invalid_array_as_controller_it_should_fail()
4343 $ router ->get ('/ ' , ['invalid ' , 'array ' , 'controller ' ]);
4444
4545 $ this ->expectException (InvalidCallableException::class);
46+ $ this ->expectExceptionMessage ('Invalid callable: invalid,array,controller ' );
47+ $ router ->dispatch ();
48+ }
49+
50+ /**
51+ * @throws Throwable
52+ */
53+ public function test_with_an_invalid_class_as_controller_it_should_fail ()
54+ {
55+ $ router = $ this ->router ();
56+ $ router ->get ('/ ' , ['InvalidController ' , 'show ' ]);
57+
58+ $ this ->expectException (InvalidCallableException::class);
59+ $ this ->expectExceptionMessage ('Class `InvalidController` not found. ' );
60+ $ router ->dispatch ();
61+ }
62+
63+ /**
64+ * @throws Throwable
65+ */
66+ public function test_with_an_int_as_controller_it_should_fail ()
67+ {
68+ $ router = $ this ->router ();
69+ $ router ->get ('/ ' , 666 );
70+
71+ $ this ->expectException (InvalidCallableException::class);
72+ $ this ->expectExceptionMessage ('Invalid callable. ' );
73+ $ router ->dispatch ();
74+ }
75+
76+ /**
77+ * @throws Throwable
78+ */
79+ public function test_with_an_handle_less_class_as_controller_it_should_fail ()
80+ {
81+ $ router = $ this ->router ();
82+ $ router ->get ('/ ' , SampleController::class);
83+
84+ $ this ->expectException (InvalidCallableException::class);
85+ $ this ->expectExceptionMessage ('Method `handle` is not declared. ' );
4686 $ router ->dispatch ();
4787 }
4888
@@ -55,6 +95,7 @@ public function test_with_an_invalid_method_as_controller_it_should_fail()
5595 $ router ->get ('/ ' , [SampleController::class, 'invalid ' ]);
5696
5797 $ this ->expectException (InvalidCallableException::class);
98+ $ this ->expectExceptionMessage ('Method ` ' . SampleController::class . '::invalid` is not declared. ' );
5899 $ router ->dispatch ();
59100 }
60101
0 commit comments