Dispatcher should check for valid callback.

pull/57/merge
Mike Cao 11 years ago
parent 3fde3685c5
commit 6696c0d267

@ -141,7 +141,9 @@ class Dispatcher {
self::invokeMethod($callback, $params) : self::invokeMethod($callback, $params) :
self::callFunction($callback, $params); self::callFunction($callback, $params);
} }
return null; else {
throw new \Exception('Invalid callback specified.');
}
} }
/** /**

@ -82,4 +82,11 @@ class DispatcherTest extends PHPUnit_Framework_TestCase
$this->assertEquals('Hello, Fred! Have a nice day!', $result); $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'));
}
} }

Loading…
Cancel
Save