feat(documents) : accept type on upload + expose in query controller + PATCH tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,58 @@ class DocumentTest extends AbstractApiTestCase
|
||||
$this->assertJsonContains(['totalItems' => 1]);
|
||||
}
|
||||
|
||||
public function testPatchType(): void
|
||||
{
|
||||
$doc = $this->createDocumentInDb();
|
||||
|
||||
$client = $this->createGestionnaireClient();
|
||||
$client->request('PATCH', self::iri('documents', $doc->getId()), [
|
||||
'headers' => ['Content-Type' => 'application/merge-patch+json'],
|
||||
'json' => ['type' => 'devis'],
|
||||
]);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertJsonContains(['type' => 'devis']);
|
||||
}
|
||||
|
||||
public function testPatchNameAndType(): void
|
||||
{
|
||||
$doc = $this->createDocumentInDb();
|
||||
|
||||
$client = $this->createGestionnaireClient();
|
||||
$client->request('PATCH', self::iri('documents', $doc->getId()), [
|
||||
'headers' => ['Content-Type' => 'application/merge-patch+json'],
|
||||
'json' => ['name' => 'new-name', 'type' => 'facture'],
|
||||
]);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertJsonContains(['name' => 'new-name', 'type' => 'facture']);
|
||||
}
|
||||
|
||||
public function testGetItemIncludesType(): void
|
||||
{
|
||||
$doc = $this->createDocumentInDb();
|
||||
|
||||
$client = $this->createViewerClient();
|
||||
$client->request('GET', self::iri('documents', $doc->getId()));
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertJsonContains(['type' => 'documentation']);
|
||||
}
|
||||
|
||||
public function testViewerCannotPatch(): void
|
||||
{
|
||||
$doc = $this->createDocumentInDb();
|
||||
|
||||
$client = $this->createViewerClient();
|
||||
$client->request('PATCH', self::iri('documents', $doc->getId()), [
|
||||
'headers' => ['Content-Type' => 'application/merge-patch+json'],
|
||||
'json' => ['type' => 'devis'],
|
||||
]);
|
||||
|
||||
$this->assertResponseStatusCodeSame(403);
|
||||
}
|
||||
|
||||
private function createDocumentInDb(?string $machineId = null, ?string $siteId = null): Document
|
||||
{
|
||||
$doc = new Document();
|
||||
|
||||
Reference in New Issue
Block a user