protected function RestfulSubResourcesCreateEntityTestCase::assertInvalidRequest in RESTful 7.2
Same name and namespace in other branches
- 7 tests/RestfulSubResourcesCreateEntityTestCase.test \RestfulSubResourcesCreateEntityTestCase::assertInvalidRequest()
Assert an invalid request fails.
Parameters
string $method: The method name.
string $path: The path.
array $request: The request array.
1 call to RestfulSubResourcesCreateEntityTestCase::assertInvalidRequest()
- RestfulSubResourcesCreateEntityTestCase::processRequests in tests/
RestfulSubResourcesCreateEntityTestCase.test - Assert valid and invalid requests.
File
- tests/
RestfulSubResourcesCreateEntityTestCase.test, line 276 - Contains RestfulSubResourcesCreateEntityTestCase.
Class
Code
protected function assertInvalidRequest($method = 'post', $path = '', array $request = array()) {
$method = strtoupper($method);
$query = $parsed_body = array();
if (Request::isWriteMethod($method)) {
$query = $request;
}
else {
$parsed_body = $request;
}
try {
$this->handler
->setRequest(Request::create($path, $query, $method, NULL, FALSE, NULL, array(), array(), array(), $parsed_body));
$this->handler
->setPath($path);
$this->handler
->process();
$this
->fail('No exception thrown on validation fail on the parent.');
} catch (BadRequestException $e) {
$this
->pass('Correct exception thrown on validation fail on the parent.');
} catch (\Exception $e) {
$this
->fail('Wrong exception thrown on validation fail on the parent.');
}
}