Fix TranslatableDenormalizer for IRI strings and shop customer 404 for guests

This commit is contained in:
Mateusz 2026-03-16 13:02:58 +01:00
parent a18b3e4517
commit 0bb7199014
3 changed files with 13 additions and 1 deletions

View file

@ -50,6 +50,7 @@ final class TranslatableDenormalizer implements DenormalizerInterface, Denormali
public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool
{
return
is_array($data) &&
Request::METHOD_POST === ($context[ContextKeys::HTTP_REQUEST_METHOD_TYPE] ?? null) &&
!isset($context[self::getAlreadyCalledKey($type)]) &&
is_a($type, TranslatableInterface::class, true)

View file

@ -40,6 +40,17 @@ final class TranslatableDenormalizerTest extends TestCase
public function testOnlySupportsTranslatableResource(): void
{
self::assertFalse(
$this->translatableDenormalizer->supportsDenormalization(
'iri-string',
TranslatableInterface::class,
null,
[
ContextKeys::HTTP_REQUEST_METHOD_TYPE => 'POST',
],
),
);
self::assertFalse(
$this->translatableDenormalizer->supportsDenormalization(
[],

View file

@ -86,7 +86,7 @@ final class CustomersTest extends JsonApiTestCase
$this->requestGet('/api/v2/shop/customers/' . $customer->getId());
$this->assertResponseCode($this->client->getResponse(), Response::HTTP_NOT_FOUND);
$this->assertResponseCode($this->client->getResponse(), Response::HTTP_UNAUTHORIZED);
}
#[Test]