mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
[API][Admin] Add PUT endpoint for taxon image resource
This commit is contained in:
parent
aa5f2e829f
commit
a90efb8db3
5 changed files with 54 additions and 0 deletions
|
|
@ -66,6 +66,17 @@
|
|||
</attribute>
|
||||
</itemOperation>
|
||||
|
||||
<itemOperation name="admin_put">
|
||||
<attribute name="method">PUT</attribute>
|
||||
<attribute name="path">/admin/taxon-images/{id}</attribute>
|
||||
<attribute name="denormalization_context">
|
||||
<attribute name="groups">admin:taxon_image:update</attribute>
|
||||
</attribute>
|
||||
<attribute name="normalization_context">
|
||||
<attribute name="groups">admin:taxon_image:read</attribute>
|
||||
</attribute>
|
||||
</itemOperation>
|
||||
|
||||
<itemOperation name="admin_delete">
|
||||
<attribute name="method">DELETE</attribute>
|
||||
<attribute name="path">/admin/taxon-images/{id}</attribute>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
<attribute name="type">
|
||||
<group>admin:taxon_image:read</group>
|
||||
<group>admin:taxon:read</group>
|
||||
<group>admin:taxon_image:update</group>
|
||||
</attribute>
|
||||
</class>
|
||||
</serializer>
|
||||
|
|
|
|||
|
|
@ -131,6 +131,36 @@ final class TaxonImagesTest extends JsonApiTestCase
|
|||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_updates_only_the_type_of_the_existing_taxon_image(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'taxon_image.yaml']);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var TaxonImageInterface $taxonImage */
|
||||
$taxonImage = $fixtures['taxon_thumbnail'];
|
||||
|
||||
/** @var TaxonInterface $taxon */
|
||||
$taxon = $fixtures['taxon_mug'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'PUT',
|
||||
uri: sprintf('/api/v2/admin/taxon-images/%s', $taxonImage->getId()),
|
||||
server: $header,
|
||||
content: json_encode([
|
||||
'type' => 'logo',
|
||||
'owner' => sprintf('/api/v2/admin/taxons/%s', $taxon->getCode()),
|
||||
'path' => 'logo.jpg',
|
||||
], JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/taxon_image/put_taxon_image_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_deletes_a_taxon_image(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ Sylius\Component\Core\Model\Taxon:
|
|||
code: 'CATEGORY'
|
||||
currentLocale: 'en_US'
|
||||
images: ['@taxon_thumbnail', '@taxon_banner']
|
||||
taxon_mug:
|
||||
code: 'MUG'
|
||||
currentLocale: 'en_US'
|
||||
|
||||
Sylius\Component\Core\Model\TaxonImage:
|
||||
taxon_thumbnail:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"@context": "\/api\/v2\/contexts\/TaxonImage",
|
||||
"@id": "\/api\/v2\/admin\/taxon-images\/@integer@",
|
||||
"@type": "TaxonImage",
|
||||
"id": "@integer@",
|
||||
"owner": "\/api\/v2\/admin\/taxons\/CATEGORY",
|
||||
"type": "logo",
|
||||
"path": "uo\/thumbnail.jpg"
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue