Added API endpoints to fetch invoices (#5070)

* added serializer attributes for API usage
* new setters to fill invoice data from fixture
* re-usable fixture helper methods
* added API endpoints to fetch invoices
* adjust tests
This commit is contained in:
Kevin Papst
2024-09-22 16:17:45 +02:00
committed by GitHub
parent 1965c35b43
commit 8de54e1fa7
20 changed files with 532 additions and 155 deletions

View File

@@ -107,10 +107,10 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
return $client->request($method, $this->createUrl($url), $parameters, [], $server, $content);
}
protected function assertEntityNotFound(string $role, string $url, string $method = 'GET', ?string $message = null): void
protected function assertEntityNotFound(string $role, string $url): void
{
$client = $this->getClientForAuthenticatedUser($role);
$this->request($client, $url, $method);
$this->request($client, $url);
$this->assertApiException($client->getResponse(), [
'code' => Response::HTTP_NOT_FOUND,
'message' => 'Not Found'
@@ -272,6 +272,25 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
protected static function getExpectedResponseStructure(string $type): array
{
switch ($type) {
case 'Invoice':
case 'InvoiceCollection':
return [
'id' => 'int',
'comment' => '@string',
'createdAt' => 'datetime',
'currency' => 'string',
'customer' => ['result' => 'object', 'type' => '@Customer'],
'user' => ['result' => 'object', 'type' => '@User'],
'dueDays' => 'int',
'invoiceNumber' => 'string',
'metaFields' => 'array',
'paymentDate' => '@datetime',
'status' => 'string',
'tax' => 'float',
'total' => 'float',
'vat' => 'float',
];
case 'PageActionItem':
return [
'id' => 'string',