@@ -68,11 +68,28 @@ class FinancialAttachmentServiceTest extends CIUnitTestCase
|
||||
|
||||
$file->expects($this->once())
|
||||
->method('move')
|
||||
->with($this->stringContains('writable/uploads/payments'), 'proof.pdf');
|
||||
->with($this->stringContains('writable/uploads/_tmp/payments'), $this->stringContains('proof.pdf'))
|
||||
->willReturnCallback(static function (string $dir, string $name): bool {
|
||||
file_put_contents($dir . DIRECTORY_SEPARATOR . $name, 'pdf');
|
||||
return true;
|
||||
});
|
||||
|
||||
$this->assertSame('proof.pdf', $this->service->saveUploadedFile($file, 'payments'));
|
||||
}
|
||||
|
||||
public function testDiscardStagedFileDeletesTemporaryUpload(): void
|
||||
{
|
||||
$tmpDir = $this->service->ensureSubdir('_tmp/checks');
|
||||
$tmpPath = $tmpDir . DIRECTORY_SEPARATOR . 'pending-test.pdf';
|
||||
file_put_contents($tmpPath, 'pdf');
|
||||
|
||||
$this->service->discardStagedFile([
|
||||
'temporary_path' => $tmpPath,
|
||||
]);
|
||||
|
||||
$this->assertFileDoesNotExist($tmpPath);
|
||||
}
|
||||
|
||||
public function testResolvePathUsesBasenameAndReturnsNullForMissingFiles(): void
|
||||
{
|
||||
$dir = $this->service->ensureSubdir('receipts');
|
||||
|
||||
Reference in New Issue
Block a user