[Api][Zone] Minor improvements

This commit is contained in:
Wojdylak 2024-07-25 11:28:33 +02:00
parent 28819a6c0a
commit cef262a4b4
No known key found for this signature in database
GPG key ID: 7509E560A6821ABE
2 changed files with 13 additions and 3 deletions

View file

@ -39,7 +39,6 @@ final class ZoneDenormalizerSpec extends ObjectBehavior
ZoneInterface $zone
): void {
$sectionProvider->getSection()->willReturn(new AdminApiSection());
$this
->supportsDenormalization([], ZoneInterface::class, null, [AbstractNormalizer::OBJECT_TO_POPULATE => $zone])
->shouldReturn(true)

View file

@ -67,7 +67,7 @@ final class ZonesTest extends JsonApiTestCase
$this->client->request(
method: 'POST',
uri: '/api/v2/admin/zones',
server: $this->headerBuilder()->withJsonLdContentType()->withJsonLdAccept()->withAdminUserAuthorization('api@example.com')->build(),
server: $this->buildHeaders(),
content: json_encode([
'code' => 'US',
'name' => 'UnitedStates',
@ -101,7 +101,7 @@ final class ZonesTest extends JsonApiTestCase
$this->client->request(
method: 'PUT',
uri: sprintf('/api/v2/admin/zones/%s', $zone->getCode()),
server: $this->headerBuilder()->withJsonLdContentType()->withJsonLdAccept()->withAdminUserAuthorization('api@example.com')->build(),
server: $this->buildHeaders(),
content: json_encode([
'name' => 'EuropeanUnion',
'members' => [
@ -134,4 +134,15 @@ final class ZonesTest extends JsonApiTestCase
$this->assertResponseCode($this->client->getResponse(), Response::HTTP_NO_CONTENT);
}
/** @return array<string, string> */
private function buildHeaders(): array
{
return $this
->headerBuilder()
->withJsonLdContentType()
->withJsonLdAccept()
->withAdminUserAuthorization('api@example.com')
->build();
}
}