Confirms that the expected exception is thrown.
public function testRequestFound() {
$chain = new ChainMatcher();
$method_not_allowed = new MockMatcher(function (Request $request) {
throw new MethodNotAllowedException(array(
'POST',
));
});
$resource_not_found = new MockMatcher(function (Request $request) {
throw new ResourceNotFoundException();
});
$found_data = new MockMatcher(function (Request $request) {
return array(
'_controller' => 'foo',
);
});
try {
$chain
->add($method_not_allowed);
$chain
->add($resource_not_found);
$chain
->add($found_data);
$request = Request::create('my/path');
$attributes = $chain
->matchRequest($request);
$this
->assertEqual($attributes['_controller'], 'foo', 'Correct attributes returned.');
} catch (Exception $e) {
$this
->fail('Exception thrown when a match should have been successful: ' . get_class($e));
}
}