test pdf uploads

This commit is contained in:
Yisroel Baum 2026-06-02 10:21:28 +03:00
parent 97ecbebb9e
commit 1fbe198d8c
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
3 changed files with 312 additions and 0 deletions

View file

@ -9,6 +9,7 @@ use App\Element\UseCases\GetElement\GetElement;
use App\Element\UseCases\UpdateElement\UpdateDescription;
use App\Element\UseCases\UpdateElement\UpdateElement;
use App\Element\UseCases\UpdateElement\UpdateElementIconImage;
use App\Element\UseCases\UpdateElement\UpdateElementPdf;
use App\Element\UseCases\UpdateElement\UpdateIconImageUrl;
use App\Element\UseCases\UpdateElement\UpdatePdfPath;
use App\Element\UseCases\UpdateElement\UpdateRichText;
@ -50,6 +51,10 @@ class ElementControllerTest extends TestCase
$this->elementRepo,
$this->fileUploader,
),
new UpdateElementPdf(
$this->elementRepo,
$this->fileUploader,
),
$this->fileUploader,
);
}
@ -194,6 +199,50 @@ class ElementControllerTest extends TestCase
);
}
public function testUploadPdfReturnsElementPayload(): void
{
$set = $this->createSet(1, 'Baderech');
$element = $this->createElement(
$set,
'Baderech HaAvodah',
'A structured path for growth',
null,
'<p>A structured path for growth</p>',
null,
null,
null,
);
$fixturePath = __DIR__
. '/../../../../frontend/rabbi_gerzi/public/assets/pdfs/'
. 'baderech.pdf';
$request = new Request([], [], [], [], [
'pdf' => new UploadedFile(
$fixturePath,
'baderech.pdf',
'application/pdf',
null,
true,
),
]);
$response = $this->controller->uploadPdf(
$element->getId(),
$request,
);
$this->assertEquals(200, $response->getStatusCode());
$body = json_decode($response->getContent(), true);
$this->assertSame($element->getId(), $body['element']['id']);
$this->assertSame(
'https://test.local/storage/element-pdfs/fake-baderech.pdf',
$body['element']['pdfPath'],
);
$this->assertSame(
'element-pdfs',
$this->fileUploader->uploads[0]['folder'],
);
}
private function createSet(int $id, string $name): DomainSet
{
return new DomainSet(