mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-28 22:31:31 +00:00
parent
0da5befd7b
commit
2e223f4ee4
2 changed files with 34 additions and 4 deletions
|
|
@ -70,7 +70,7 @@ final class PartEndpointTest extends CrudEndpointTestCase
|
|||
$this->_testDeleteItem(1);
|
||||
}
|
||||
|
||||
public function testAttachmentPatchWithIRI(): void
|
||||
public function testMasterPictureAttachmentPatchWithIRI(): void
|
||||
{
|
||||
$client = static::createAuthenticatedClient();
|
||||
|
||||
|
|
@ -93,4 +93,28 @@ final class PartEndpointTest extends CrudEndpointTestCase
|
|||
self::assertResponseIsSuccessful();
|
||||
self::assertJsonContains(['master_picture_attachment' => ['@id' => $attachmentIri]]);
|
||||
}
|
||||
|
||||
public function testMasterPictureAttachmentPatchWithArray(): void
|
||||
{
|
||||
$client = static::createAuthenticatedClient();
|
||||
|
||||
// Create a new attachment with a picture URL for Part 1
|
||||
$response = $client->request('POST', '/api/attachments', ['json' => [
|
||||
'name' => 'Test Picture',
|
||||
'url' => 'http://example.com/test.jpg',
|
||||
'_type' => 'Part',
|
||||
'element' => '/api/parts/1',
|
||||
'attachment_type' => '/api/attachment_types/1',
|
||||
]]);
|
||||
self::assertResponseIsSuccessful();
|
||||
$attachmentIri = $response->toArray()['@id'];
|
||||
|
||||
// Now PATCH Part 1 to set master_picture_attachment
|
||||
$client->request('PATCH', '/api/parts/1', [
|
||||
'json' => ['master_picture_attachment' => ['@id' => $attachmentIri, '_type' => 'Part']],
|
||||
'headers' => ['Content-Type' => 'application/merge-patch+json'],
|
||||
]);
|
||||
self::assertResponseIsSuccessful();
|
||||
self::assertJsonContains(['master_picture_attachment' => ['@id' => $attachmentIri]]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue