Working state

This commit is contained in:
julien
2026-03-16 13:40:18 +01:00
parent dec76fa2c7
commit 557360dfde
57 changed files with 1044 additions and 1668 deletions

View File

@@ -3,26 +3,27 @@ declare(strict_types=1);
namespace Tests\Media;
use App\Media\MediaService;
use App\Media\MediaRepositoryInterface;
use App\Media\Exception\FileTooLargeException;
use App\Media\Exception\StorageException;
use App\Media\MediaRepositoryInterface;
use App\Media\MediaService;
use App\Post\PostRepositoryInterface;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
final class MediaServiceEdgeCasesTest extends TestCase
{
public function testRejectsWhenSizeUnknown(): void
{
$repo = $this->createMock(MediaRepositoryInterface::class);
$postRepo = $this->createMock(PostRepositoryInterface::class);
$file = $this->createMock(UploadedFileInterface::class);
$file->method('getSize')->willReturn(null);
$service = new MediaService($repo, '/tmp', '/media', 1000);
$service = new MediaService($repo, $postRepo, '/tmp', '/media', 1000);
$this->expectException(StorageException::class);
$service->store($file, 1);
@@ -31,6 +32,7 @@ final class MediaServiceEdgeCasesTest extends TestCase
public function testRejectsWhenFileTooLarge(): void
{
$repo = $this->createMock(MediaRepositoryInterface::class);
$postRepo = $this->createMock(PostRepositoryInterface::class);
$stream = $this->createMock(StreamInterface::class);
$stream->method('getMetadata')->willReturn('/tmp/file');
@@ -39,7 +41,7 @@ final class MediaServiceEdgeCasesTest extends TestCase
$file->method('getSize')->willReturn(999999);
$file->method('getStream')->willReturn($stream);
$service = new MediaService($repo, '/tmp', '/media', 100);
$service = new MediaService($repo, $postRepo, '/tmp', '/media', 100);
$this->expectException(FileTooLargeException::class);
$service->store($file, 1);