Skip to content

Commit

Permalink
Dispatcher should check for valid callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Dec 19, 2013
1 parent 3fde368 commit 6696c0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flight/core/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public static function execute($callback, array &$params = array()) {
self::invokeMethod($callback, $params) :
self::callFunction($callback, $params);
}
return null;
else {
throw new \Exception('Invalid callback specified.');
}
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ function testBeforeAndAfter() {

$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'));
}
}

0 comments on commit 6696c0d

Please sign in to comment.