$mediaSearchResult->
method('get'
)->
willReturn($currentMedia);
$mediaSearchResult->
method('getEntities'
)->
willReturn($mediaWithRelatedFileName);
$this->mediaRepository->
method('search'
)->
willReturn($mediaSearchResult);
$mediaFile =
new MediaFile('foo', 'image/png', 'png', 0
);
$context = Context::
createDefaultContext(new AdminApiSource(Uuid::
randomHex()));
static::
expectException(MediaException::
class);
static::
expectExceptionMessage('A file with the name "foo.png" already exists.'
);
$this->fileSaver->
persistFileToMedia($mediaFile, 'foo', Uuid::
randomHex(),
$context);
} public static function duplicateFileNameProvider(): \Generator
{ yield 'new private file exists as private in database / different filesystems' =>
[ true,
];
yield 'new public file exists as public in database / different filesystems' =>
[ false,
];
}