diff --git a/flight/core/Dispatcher.php b/flight/core/Dispatcher.php index 10aa004..c5aab29 100644 --- a/flight/core/Dispatcher.php +++ b/flight/core/Dispatcher.php @@ -141,7 +141,9 @@ class Dispatcher { self::invokeMethod($callback, $params) : self::callFunction($callback, $params); } - return null; + else { + throw new \Exception('Invalid callback specified.'); + } } /** diff --git a/tests/DispatcherTest.php b/tests/DispatcherTest.php index 3222a96..56e9acf 100644 --- a/tests/DispatcherTest.php +++ b/tests/DispatcherTest.php @@ -82,4 +82,11 @@ class DispatcherTest extends PHPUnit_Framework_TestCase $this->assertEquals('Hello, Fred! Have a nice day!', $result); } + + // Test an invalid callback + function testInvalidCallback() { + $this->setExpectedException('Exception', 'Invalid callback specified.'); + + $this->dispatcher->execute(array('NonExistentClass', 'nonExistentMethod')); + } }