diff --git a/backend/tests/Unit/Controllers/ElementControllerTest.php b/backend/tests/Unit/Controllers/ElementControllerTest.php index 67023d0..ee3203f 100644 --- a/backend/tests/Unit/Controllers/ElementControllerTest.php +++ b/backend/tests/Unit/Controllers/ElementControllerTest.php @@ -278,6 +278,17 @@ class ElementControllerTest extends TestCase ); } + public function testShowPdfReturns400WhenFolderIsInvalid(): void + { + $response = $this->controller->showPdf('archive', 'baderech.pdf'); + + $this->assertEquals(400, $response->getStatusCode()); + $this->assertSame( + ['error' => 'folder is invalid'], + json_decode($response->getContent(), true), + ); + } + public function testShowPdfReturns400WhenFolderIsMissing(): void { $response = $this->controller->showPdf(null, 'baderech.pdf'); @@ -289,6 +300,17 @@ class ElementControllerTest extends TestCase ); } + public function testShowPdfReturns400WhenFileNameIsInvalid(): void + { + $response = $this->controller->showPdf('short', '../baderech.pdf'); + + $this->assertEquals(400, $response->getStatusCode()); + $this->assertSame( + ['error' => 'fileName is invalid'], + json_decode($response->getContent(), true), + ); + } + public function testShowPdfReturns400WhenFileNameIsMissing(): void { $response = $this->controller->showPdf('short', null); diff --git a/backend/tests/Unit/Element/UseCases/GetElementPdfTest.php b/backend/tests/Unit/Element/UseCases/GetElementPdfTest.php index 3a88163..7a21def 100644 --- a/backend/tests/Unit/Element/UseCases/GetElementPdfTest.php +++ b/backend/tests/Unit/Element/UseCases/GetElementPdfTest.php @@ -63,10 +63,10 @@ class GetElementPdfTest extends TestCase ); } - public function testInvalidFolderThrowsNotFound(): void + public function testInvalidFolderThrowsBadRequest(): void { - $this->expectException(NotFoundException::class); - $this->expectExceptionMessage('PDF not found'); + $this->expectException(BadRequestException::class); + $this->expectExceptionMessage('folder is invalid'); $this->useCase->execute(new GetElementPdfRequest( folder: 'archive', @@ -96,10 +96,10 @@ class GetElementPdfTest extends TestCase )); } - public function testInvalidFileNameThrowsNotFound(): void + public function testInvalidFileNameThrowsBadRequest(): void { - $this->expectException(NotFoundException::class); - $this->expectExceptionMessage('PDF not found'); + $this->expectException(BadRequestException::class); + $this->expectExceptionMessage('fileName is invalid'); $this->useCase->execute(new GetElementPdfRequest( folder: 'short',