40 lines
1.5 KiB
PHP
40 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Media;
|
|
|
|
use Netig\Netslim\Media\Application\MediaApplicationService;
|
|
use Netig\Netslim\Media\Application\UseCase\DeleteMedia;
|
|
use Netig\Netslim\Media\Application\UseCase\StoreMedia;
|
|
use Netig\Netslim\Media\Contracts\MediaUsageReaderInterface;
|
|
use Netig\Netslim\Media\Domain\Exception\StorageException;
|
|
use Netig\Netslim\Media\Domain\Repository\MediaRepositoryInterface;
|
|
use Netig\Netslim\Media\Domain\Service\UploadedMediaInterface;
|
|
use Netig\Netslim\Media\Infrastructure\LocalMediaStorage;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
|
|
|
final class MediaServiceInvalidTempPathTest extends TestCase
|
|
{
|
|
public function testRejectsWhenTemporaryPathIsMissing(): void
|
|
{
|
|
$repository = $this->createMock(MediaRepositoryInterface::class);
|
|
|
|
$file = $this->createMock(UploadedMediaInterface::class);
|
|
$file->method('getSize')->willReturn(128);
|
|
$file->method('getTemporaryPath')->willReturn(null);
|
|
|
|
$mediaUsageReader = $this->createMock(MediaUsageReaderInterface::class);
|
|
|
|
$storage = new LocalMediaStorage(sys_get_temp_dir());
|
|
$service = new MediaApplicationService($repository, $mediaUsageReader, new StoreMedia($repository, $storage, '/media', 500000), new DeleteMedia($repository, $storage));
|
|
|
|
$this->expectException(StorageException::class);
|
|
$this->expectExceptionMessage('Impossible de localiser le fichier temporaire uploadé');
|
|
|
|
$service->store($file, 1);
|
|
}
|
|
}
|