added internal rates (#1591)
This commit is contained in:
@@ -149,6 +149,22 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
);
|
||||
}
|
||||
|
||||
protected function assertNotFoundForDelete(HttpKernelBrowser $client, string $url)
|
||||
{
|
||||
return $this->assertExceptionForMethod($client, $url, 'DELETE', [], [
|
||||
'code' => 404,
|
||||
'message' => 'Not found'
|
||||
]);
|
||||
}
|
||||
|
||||
protected function assertEntityNotFoundForDelete(string $role, string $url)
|
||||
{
|
||||
return $this->assertExceptionForDeleteAction($role, $url, [], [
|
||||
'code' => 404,
|
||||
'message' => 'Not found'
|
||||
]);
|
||||
}
|
||||
|
||||
protected function assertEntityNotFoundForPatch(string $role, string $url, array $data)
|
||||
{
|
||||
return $this->assertExceptionForPatchAction($role, $url, $data, [
|
||||
@@ -157,11 +173,32 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
]);
|
||||
}
|
||||
|
||||
protected function assertEntityNotFoundForPost(string $role, string $url, array $data, ?string $message = null)
|
||||
{
|
||||
return $this->assertExceptionForPostAction($role, $url, $data, [
|
||||
'code' => 404,
|
||||
'message' => $message ?? 'Not found'
|
||||
]);
|
||||
}
|
||||
|
||||
protected function assertExceptionForDeleteAction(string $role, string $url, array $data, array $expectedErrors)
|
||||
{
|
||||
$this->assertExceptionForRole($role, $url, 'DELETE', $data, $expectedErrors);
|
||||
}
|
||||
|
||||
protected function assertExceptionForPatchAction(string $role, string $url, array $data, array $expectedErrors)
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser($role);
|
||||
$this->assertExceptionForRole($role, $url, 'PATCH', $data, $expectedErrors);
|
||||
}
|
||||
|
||||
$this->request($client, $url, 'PATCH', [], json_encode($data));
|
||||
protected function assertExceptionForPostAction(string $role, string $url, array $data, array $expectedErrors)
|
||||
{
|
||||
$this->assertExceptionForRole($role, $url, 'POST', $data, $expectedErrors);
|
||||
}
|
||||
|
||||
protected function assertExceptionForMethod(HttpKernelBrowser $client, string $url, string $method, array $data, array $expectedErrors)
|
||||
{
|
||||
$this->request($client, $url, $method, [], json_encode($data));
|
||||
$response = $client->getResponse();
|
||||
self::assertFalse($response->isSuccessful());
|
||||
|
||||
@@ -173,25 +210,10 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
|
||||
);
|
||||
}
|
||||
|
||||
protected function assertEntityNotFoundForDelete(string $role, string $url, array $data)
|
||||
protected function assertExceptionForRole(string $role, string $url, string $method, array $data, array $expectedErrors)
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser($role);
|
||||
|
||||
$this->request($client, $url, 'DELETE', [], json_encode($data));
|
||||
$response = $client->getResponse();
|
||||
self::assertFalse($response->isSuccessful());
|
||||
|
||||
$expected = [
|
||||
'code' => 404,
|
||||
'message' => 'Not found'
|
||||
];
|
||||
|
||||
self::assertEquals(404, $client->getResponse()->getStatusCode());
|
||||
|
||||
self::assertEquals(
|
||||
$expected,
|
||||
json_decode($client->getResponse()->getContent(), true)
|
||||
);
|
||||
$this->assertExceptionForMethod($client, $url, $method, $data, $expectedErrors);
|
||||
}
|
||||
|
||||
protected function assertApiException(Response $response, string $message)
|
||||
|
||||
Reference in New Issue
Block a user