API endpoint for Timesheet entries (#332)

This commit is contained in:
Kevin Papst
2018-11-18 19:43:58 +01:00
committed by GitHub
parent 8cb52e22b1
commit b1c06eed7b
35 changed files with 1073 additions and 118 deletions

View File

@@ -139,11 +139,14 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
* @param string $url
* @param string $method
* @param array $parameters
* @param string $content
* @return Crawler
*/
protected function request(Client $client, string $url, $method = 'GET', array $parameters = [])
protected function request(Client $client, string $url, $method = 'GET', array $parameters = [], string $content = null)
{
return $client->request($method, $this->createUrl($url), $parameters, [], ['HTTP_CONTENT_TYPE' => 'application/json']);
$server = ['HTTP_CONTENT_TYPE' => 'application/json', 'CONTENT_TYPE' => 'application/json'];
return $client->request($method, $this->createUrl($url), $parameters, [], $server, $content);
}
/**
@@ -167,4 +170,23 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
json_decode($client->getResponse()->getContent(), true)
);
}
/**
* @param Response $response
* @param string[] $failedFields
*/
protected function assertApiCallValidationError(Response $response, array $failedFields)
{
$this->assertFalse($response->isSuccessful());
$result = json_decode($response->getContent(), true);
$this->assertArrayHasKey('errors', $result);
$this->assertArrayHasKey('children', $result['errors']);
$data = $result['errors']['children'];
foreach ($failedFields as $fieldName) {
$this->assertArrayHasKey($fieldName, $data);
$this->assertArrayHasKey('errors', $data[$fieldName]);
}
}
}