filesystem = new FakeFilesystem(); $this->useCase = new GetElementPdf($this->filesystem); } public function testReturnsShortPdfFile(): void { $this->filesystem->put( 'element-pdfs/short/baderech.pdf', 'short-pdf-bytes', ); $result = $this->useCase->execute(new GetElementPdfRequest( folder: 'short', fileName: 'baderech.pdf', )); $this->assertSame('short-pdf-bytes', $result->getContents()); $this->assertSame('baderech.pdf', $result->getFileName()); $this->assertSame('application/pdf', $result->getMimeType()); $this->assertSame( ['element-pdfs/short/baderech.pdf'], $this->filesystem->readPaths, ); } public function testReturnsLongPdfFile(): void { $this->filesystem->put( 'element-pdfs/long/baderech-long.pdf', 'long-pdf-bytes', ); $result = $this->useCase->execute(new GetElementPdfRequest( folder: 'long', fileName: 'baderech-long.pdf', )); $this->assertSame('long-pdf-bytes', $result->getContents()); $this->assertSame('baderech-long.pdf', $result->getFileName()); $this->assertSame('application/pdf', $result->getMimeType()); $this->assertSame( ['element-pdfs/long/baderech-long.pdf'], $this->filesystem->readPaths, ); } public function testInvalidFolderThrowsNotFound(): void { $this->expectException(NotFoundException::class); $this->expectExceptionMessage('PDF not found'); $this->useCase->execute(new GetElementPdfRequest( folder: 'archive', fileName: 'baderech.pdf', )); } public function testInvalidFileNameThrowsNotFound(): void { $this->expectException(NotFoundException::class); $this->expectExceptionMessage('PDF not found'); $this->useCase->execute(new GetElementPdfRequest( folder: 'short', fileName: '../baderech.pdf', )); } public function testMissingStorageFileThrowsNotFound(): void { $this->expectException(NotFoundException::class); $this->expectExceptionMessage('PDF not found'); $this->useCase->execute(new GetElementPdfRequest( folder: 'short', fileName: 'missing.pdf', )); } }