diff --git a/flight/core/Dispatcher.php b/flight/core/Dispatcher.php index 73fda85..6af0d66 100644 --- a/flight/core/Dispatcher.php +++ b/flight/core/Dispatcher.php @@ -71,7 +71,6 @@ class Dispatcher /** * @param array &$params - * @param mixed &$output * * @return void|mixed * @throws Exception @@ -116,10 +115,6 @@ class Dispatcher */ public function set(string $name, callable $callback): self { - if ($this->get($name) !== null) { - trigger_error("Event '$name' has been overriden!", E_USER_NOTICE); - } - $this->events[$name] = $callback; return $this; diff --git a/tests/DocExamplesTest.php b/tests/DocExamplesTest.php new file mode 100644 index 0000000..76bbb21 --- /dev/null +++ b/tests/DocExamplesTest.php @@ -0,0 +1,58 @@ +url = '/not-found'; + + Flight::route('/', function () { + echo 'hello world!'; + }); + + Flight::start(); + ob_get_clean(); + $this->assertEquals(404, Flight::response()->status()); + $this->assertEquals('[]', Flight::response()->getBody()); + } + + public function testMapErrorMethod() + { + Flight::map('error', function (Throwable $error) { + // Handle error + echo 'Custom: ' . $error->getMessage(); + }); + + Flight::app()->handleException(new Exception('Error')); + $this->expectOutputString('Custom: Error'); + } +}