test filesystem abstraction
This commit is contained in:
parent
bc7937d2b3
commit
be2c51bfb7
10 changed files with 66 additions and 78 deletions
|
|
@ -25,8 +25,7 @@ use App\Set\Set as DomainSet;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Tests\Fakes\FakeElementRepository;
|
||||
use Tests\Fakes\FakeFileUploader;
|
||||
use Tests\Fakes\FakeStoredFileReader;
|
||||
use Tests\Fakes\FakeFilesystem;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ElementControllerTest extends TestCase
|
||||
|
|
@ -35,46 +34,43 @@ class ElementControllerTest extends TestCase
|
|||
|
||||
private FakeElementRepository $elementRepo;
|
||||
|
||||
private FakeFileUploader $fileUploader;
|
||||
|
||||
private FakeStoredFileReader $storedFileReader;
|
||||
private FakeFilesystem $filesystem;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->elementRepo = new FakeElementRepository();
|
||||
$this->fileUploader = new FakeFileUploader();
|
||||
$this->storedFileReader = new FakeStoredFileReader();
|
||||
$this->filesystem = new FakeFilesystem();
|
||||
$getElement = new GetElement($this->elementRepo);
|
||||
$updateElement = new UpdateElement(
|
||||
new UpdateTitle($this->elementRepo),
|
||||
new UpdateDescription($this->elementRepo),
|
||||
new UpdateIconImageUrl($this->elementRepo, $this->fileUploader),
|
||||
new UpdateIconImageUrl($this->elementRepo, $this->filesystem),
|
||||
new UpdateRichText($this->elementRepo),
|
||||
new UpdateShortPdfPath($this->elementRepo, $this->fileUploader),
|
||||
new UpdateLongPdfPath($this->elementRepo, $this->fileUploader),
|
||||
new UpdateShortPdfPath($this->elementRepo, $this->filesystem),
|
||||
new UpdateLongPdfPath($this->elementRepo, $this->filesystem),
|
||||
new UpdateYoutubeUrl($this->elementRepo),
|
||||
new UpdateIconImage(
|
||||
$this->elementRepo,
|
||||
$this->fileUploader,
|
||||
$this->filesystem,
|
||||
),
|
||||
new UpdateShortPdf(
|
||||
$this->elementRepo,
|
||||
$this->fileUploader,
|
||||
$this->filesystem,
|
||||
),
|
||||
new UpdateLongPdf(
|
||||
$this->elementRepo,
|
||||
$this->fileUploader,
|
||||
$this->filesystem,
|
||||
),
|
||||
$this->elementRepo,
|
||||
);
|
||||
$this->controller = new ElementController(
|
||||
$getElement,
|
||||
new CreateChildElement($this->elementRepo),
|
||||
new DeleteChildElement($this->elementRepo, $this->fileUploader),
|
||||
new DeleteChildElement($this->elementRepo, $this->filesystem),
|
||||
new ReorderChildElements($this->elementRepo),
|
||||
$updateElement,
|
||||
new GetElementPdf($this->storedFileReader),
|
||||
$this->fileUploader,
|
||||
new GetElementPdf($this->filesystem),
|
||||
$this->filesystem,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -252,7 +248,7 @@ class ElementControllerTest extends TestCase
|
|||
|
||||
public function testShowPdfReturnsPdfResponse(): void
|
||||
{
|
||||
$this->storedFileReader->put(
|
||||
$this->filesystem->put(
|
||||
'element-pdfs/short/baderech.pdf',
|
||||
'pdf-bytes',
|
||||
);
|
||||
|
|
@ -311,7 +307,7 @@ class ElementControllerTest extends TestCase
|
|||
);
|
||||
$this->assertSame(
|
||||
'element-icons',
|
||||
$this->fileUploader->uploads[0]['folder'],
|
||||
$this->filesystem->uploads[0]['folder'],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +341,7 @@ class ElementControllerTest extends TestCase
|
|||
$this->assertArrayNotHasKey('pdfPath', $body['element']);
|
||||
$this->assertSame(
|
||||
'element-pdfs/short',
|
||||
$this->fileUploader->uploads[0]['folder'],
|
||||
$this->filesystem->uploads[0]['folder'],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -378,7 +374,7 @@ class ElementControllerTest extends TestCase
|
|||
);
|
||||
$this->assertSame(
|
||||
'element-pdfs/long',
|
||||
$this->fileUploader->uploads[0]['folder'],
|
||||
$this->filesystem->uploads[0]['folder'],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue