diff --git a/eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage.php b/eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage.php index 9acf51116a..928cb70988 100644 --- a/eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage.php +++ b/eZ/Publish/Core/FieldType/BinaryBase/BinaryBaseStorage.php @@ -6,6 +6,8 @@ */ namespace eZ\Publish\Core\FieldType\BinaryBase; +use eZ\Publish\Core\Base\Exceptions\ContentFieldValidationException; +use eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator; use eZ\Publish\Core\IO\IOServiceInterface; use eZ\Publish\SPI\FieldType\BinaryBase\PathGenerator; use eZ\Publish\SPI\FieldType\BinaryBase\RouteAwarePathGenerator; @@ -39,24 +41,21 @@ class BinaryBaseStorage extends GatewayBasedStorage /** @var \eZ\Publish\Core\FieldType\BinaryBase\BinaryBaseStorage\Gateway */ protected $gateway; - /** - * Construct from gateways. - * - * @param \eZ\Publish\SPI\FieldType\StorageGateway $gateway - * @param \eZ\Publish\Core\IO\IOServiceInterface $ioService - * @param \eZ\Publish\SPI\FieldType\BinaryBase\PathGenerator $pathGenerator - * @param \eZ\Publish\SPI\IO\MimeTypeDetector $mimeTypeDetector - */ + /** @var \eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator */ + protected $fileExtensionBlackListValidator; + public function __construct( StorageGateway $gateway, IOServiceInterface $ioService, PathGenerator $pathGenerator, - MimeTypeDetector $mimeTypeDetector + MimeTypeDetector $mimeTypeDetector, + FileExtensionBlackListValidator $fileExtensionBlackListValidator ) { parent::__construct($gateway); $this->ioService = $ioService; $this->pathGenerator = $pathGenerator; $this->mimeTypeDetector = $mimeTypeDetector; + $this->fileExtensionBlackListValidator = $fileExtensionBlackListValidator; } /** @@ -67,6 +66,10 @@ public function setDownloadUrlGenerator(PathGenerator $downloadUrlGenerator) $this->downloadUrlGenerator = $downloadUrlGenerator; } + /** + * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException + * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException + */ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context) { if ($field->value->externalData === null) { @@ -76,6 +79,17 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $co } if (isset($field->value->externalData['inputUri'])) { + $this->fileExtensionBlackListValidator->validateFileExtension($field->value->externalData['fileName']); + if (!empty($errors = $this->fileExtensionBlackListValidator->getErrors())) { + $preparedErrors = []; + $preparedErrors[$field->fieldDefinitionId][$field->languageCode] = $errors; + + throw ContentFieldValidationException::createNewWithMultiline( + $preparedErrors, + $versionInfo->contentInfo->name + ); + } + $field->value->externalData['mimeType'] = $this->mimeTypeDetector->getFromPath($field->value->externalData['inputUri']); $createStruct = $this->ioService->newBinaryCreateStructFromLocalFile($field->value->externalData['inputUri']); $createStruct->id = $this->pathGenerator->getStoragePathForField($field, $versionInfo); diff --git a/eZ/Publish/Core/FieldType/Image/ImageStorage.php b/eZ/Publish/Core/FieldType/Image/ImageStorage.php index ded5e0ce1d..92b0dc7981 100644 --- a/eZ/Publish/Core/FieldType/Image/ImageStorage.php +++ b/eZ/Publish/Core/FieldType/Image/ImageStorage.php @@ -6,8 +6,10 @@ */ namespace eZ\Publish\Core\FieldType\Image; +use eZ\Publish\Core\Base\Exceptions\ContentFieldValidationException; use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException; use eZ\Publish\Core\Base\Utils\DeprecationWarnerInterface as DeprecationWarner; +use eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator; use eZ\Publish\Core\IO\FilePathNormalizerInterface; use eZ\Publish\Core\IO\IOServiceInterface; use eZ\Publish\Core\IO\MetadataHandler; @@ -42,6 +44,9 @@ class ImageStorage extends GatewayBasedStorage /** @var \eZ\Publish\Core\IO\FilePathNormalizerInterface */ protected $filePathNormalizer; + /** @var \eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator */ + protected $fileExtensionBlackListValidator; + public function __construct( StorageGateway $gateway, IOServiceInterface $ioService, @@ -49,7 +54,8 @@ public function __construct( MetadataHandler $imageSizeMetadataHandler, DeprecationWarner $deprecationWarner, AliasCleanerInterface $aliasCleaner, - FilePathNormalizerInterface $filePathNormalizer + FilePathNormalizerInterface $filePathNormalizer, + FileExtensionBlackListValidator $fileExtensionBlackListValidator ) { parent::__construct($gateway); $this->ioService = $ioService; @@ -58,8 +64,15 @@ public function __construct( $this->deprecationWarner = $deprecationWarner; $this->aliasCleaner = $aliasCleaner; $this->filePathNormalizer = $filePathNormalizer; + $this->fileExtensionBlackListValidator = $fileExtensionBlackListValidator; } + /** + * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException + * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue + * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException + * @throws \eZ\Publish\Core\Base\Exceptions\ContentFieldValidationException + */ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context) { $contentMetaData = [ @@ -70,6 +83,17 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field, array $co // new image if (isset($field->value->externalData)) { + $this->fileExtensionBlackListValidator->validateFileExtension($field->value->externalData['fileName']); + if (!empty($errors = $this->fileExtensionBlackListValidator->getErrors())) { + $preparedErrors = []; + $preparedErrors[$field->fieldDefinitionId][$field->languageCode] = $errors; + + throw ContentFieldValidationException::createNewWithMultiline( + $preparedErrors, + $versionInfo->contentInfo->name + ); + } + $targetPath = sprintf( '%s/%s', $this->pathGenerator->getStoragePathForField( diff --git a/eZ/Publish/Core/FieldType/Tests/BinaryFileTest.php b/eZ/Publish/Core/FieldType/Tests/BinaryFileTest.php index 07cd1989fb..a88283f8a1 100644 --- a/eZ/Publish/Core/FieldType/Tests/BinaryFileTest.php +++ b/eZ/Publish/Core/FieldType/Tests/BinaryFileTest.php @@ -595,7 +595,7 @@ public function provideInvalidDataForValidate() ), [ new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, ['%extensionsBlackList%' => implode(', ', $this->blackListedExtensions)], 'fileExtensionBlackList' @@ -623,7 +623,7 @@ public function provideInvalidDataForValidate() ), [ new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, ['%extensionsBlackList%' => implode(', ', $this->blackListedExtensions)], 'fileExtensionBlackList' diff --git a/eZ/Publish/Core/FieldType/Tests/ImageTest.php b/eZ/Publish/Core/FieldType/Tests/ImageTest.php index 53a94dbaf8..0556ac2df5 100644 --- a/eZ/Publish/Core/FieldType/Tests/ImageTest.php +++ b/eZ/Publish/Core/FieldType/Tests/ImageTest.php @@ -711,7 +711,7 @@ public function provideInvalidDataForValidate() ), [ new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, ['%extensionsBlackList%' => implode(', ', $this->blackListedExtensions)], 'fileExtensionBlackList' @@ -743,7 +743,7 @@ public function provideInvalidDataForValidate() ), [ new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, ['%extensionsBlackList%' => implode(', ', $this->blackListedExtensions)], 'fileExtensionBlackList' @@ -778,7 +778,7 @@ public function provideInvalidDataForValidate() ), [ new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, ['%extensionsBlackList%' => implode(', ', $this->blackListedExtensions)], 'fileExtensionBlackList' @@ -810,7 +810,7 @@ public function provideInvalidDataForValidate() ), [ new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, ['%extensionsBlackList%' => implode(', ', $this->blackListedExtensions)], 'fileExtensionBlackList' diff --git a/eZ/Publish/Core/FieldType/Tests/Integration/BinaryBase/BinaryBaseStorage/BinaryBaseStorageTest.php b/eZ/Publish/Core/FieldType/Tests/Integration/BinaryBase/BinaryBaseStorage/BinaryBaseStorageTest.php index 5ddb5e20fe..6e3eff2af2 100644 --- a/eZ/Publish/Core/FieldType/Tests/Integration/BinaryBase/BinaryBaseStorage/BinaryBaseStorageTest.php +++ b/eZ/Publish/Core/FieldType/Tests/Integration/BinaryBase/BinaryBaseStorage/BinaryBaseStorageTest.php @@ -13,6 +13,7 @@ use eZ\Publish\Core\FieldType\BinaryBase\BinaryBaseStorage\Gateway; use eZ\Publish\Core\FieldType\BinaryFile\BinaryFileStorage\Gateway\DoctrineStorage; use eZ\Publish\Core\FieldType\Tests\Integration\BaseCoreFieldTypeIntegrationTest; +use eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator; use eZ\Publish\Core\IO\IOServiceInterface; use eZ\Publish\Core\IO\Values\BinaryFile; use eZ\Publish\Core\IO\Values\BinaryFileCreateStruct; @@ -36,6 +37,9 @@ class BinaryBaseStorageTest extends BaseCoreFieldTypeIntegrationTest /** @var \eZ\Publish\Core\FieldType\BinaryBase\BinaryBaseStorage|\PHPUnit\Framework\MockObject\MockObject */ protected $storage; + /** @var \eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator&\PHPUnit\Framework\MockObject\MockObject */ + protected $fileExtensionBlackListValidatorMock; + protected function setUp(): void { parent::setUp(); @@ -43,6 +47,9 @@ protected function setUp(): void $this->gateway = $this->getStorageGateway(); $this->pathGeneratorMock = $this->createMock(PathGenerator::class); $this->ioServiceMock = $this->createMock(IOServiceInterface::class); + $this->fileExtensionBlackListValidatorMock = $this->createMock( + FileExtensionBlackListValidator::class + ); $this->storage = $this->getMockBuilder(BinaryBaseStorage::class) ->onlyMethods([]) ->setConstructorArgs( @@ -51,6 +58,7 @@ protected function setUp(): void $this->ioServiceMock, $this->pathGeneratorMock, $this->createMock(MimeTypeDetector::class), + $this->fileExtensionBlackListValidatorMock, ] ) ->getMock(); diff --git a/eZ/Publish/Core/FieldType/Tests/MediaTest.php b/eZ/Publish/Core/FieldType/Tests/MediaTest.php index 44fb200878..4c61674bbf 100644 --- a/eZ/Publish/Core/FieldType/Tests/MediaTest.php +++ b/eZ/Publish/Core/FieldType/Tests/MediaTest.php @@ -761,7 +761,7 @@ public function provideInvalidDataForValidate() ), [ new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, ['%extensionsBlackList%' => implode(', ', $this->blackListedExtensions)], 'fileExtensionBlackList' diff --git a/eZ/Publish/Core/FieldType/Validator/FileExtensionBlackListValidator.php b/eZ/Publish/Core/FieldType/Validator/FileExtensionBlackListValidator.php index 101053c0c7..f2dc6e7348 100644 --- a/eZ/Publish/Core/FieldType/Validator/FileExtensionBlackListValidator.php +++ b/eZ/Publish/Core/FieldType/Validator/FileExtensionBlackListValidator.php @@ -46,23 +46,40 @@ public function validateConstraints($constraints) * {@inheritdoc} */ public function validate(BaseValue $value) + { + $this->errors = []; + + $this->validateFileExtension($value->fileName); + + return empty($this->errors); + } + + public function validateFileExtension(string $fileName): void { if ( - pathinfo($value->fileName, PATHINFO_BASENAME) !== $value->fileName || - in_array(strtolower(pathinfo($value->fileName, PATHINFO_EXTENSION)), $this->constraints['extensionsBlackList'], true) + pathinfo($fileName, PATHINFO_BASENAME) !== $fileName + || in_array( + strtolower(pathinfo($fileName, PATHINFO_EXTENSION)), + $this->constraints['extensionsBlackList'], + true + ) ) { $this->errors[] = new ValidationError( - 'A valid file is required. Following file extensions are on the blacklist: %extensionsBlackList%', + 'A valid file is required. The following file extensions are not allowed: %extensionsBlackList%', null, [ '%extensionsBlackList%' => implode(', ', $this->constraints['extensionsBlackList']), ], 'fileExtensionBlackList' ); - - return false; } + } - return true; + /** + * @return array<\eZ\Publish\SPI\FieldType\ValidationError> + */ + public function getErrors(): array + { + return $this->errors; } } diff --git a/eZ/Publish/Core/settings/fieldtype_external_storages.yml b/eZ/Publish/Core/settings/fieldtype_external_storages.yml index deba26b9a2..862a160adf 100644 --- a/eZ/Publish/Core/settings/fieldtype_external_storages.yml +++ b/eZ/Publish/Core/settings/fieldtype_external_storages.yml @@ -2,10 +2,11 @@ services: ezpublish.fieldType.ezbinaryfile.externalStorage: class: eZ\Publish\Core\FieldType\BinaryFile\BinaryFileStorage arguments: - - "@ezpublish.fieldType.ezbinaryfile.storage_gateway" - - "@ezpublish.fieldType.ezbinaryfile.io_service" - - "@ezpublish.fieldType.ezbinaryfile.pathGenerator" - - "@ezpublish.core.io.mimeTypeDetector" + $gateway: '@ezpublish.fieldType.ezbinaryfile.storage_gateway' + $ioService: '@ezpublish.fieldType.ezbinaryfile.io_service' + $pathGenerator: '@ezpublish.fieldType.ezbinaryfile.pathGenerator' + $mimeTypeDetector: '@ezpublish.core.io.mimeTypeDetector' + $fileExtensionBlackListValidator: '@ezpublish.fieldType.validator.black_list' tags: - {name: ezplatform.field_type.external_storage_handler, alias: ezbinaryfile} @@ -19,6 +20,7 @@ services: $deprecationWarner: '@ezpublish.utils.deprecation_warner' $aliasCleaner: '@eZ\Publish\Core\FieldType\Image\AliasCleanerInterface' $filePathNormalizer: '@eZ\Publish\Core\IO\FilePathNormalizerInterface' + $fileExtensionBlackListValidator: '@ezpublish.fieldType.validator.black_list' tags: - {name: ezplatform.field_type.external_storage_handler, alias: ezimage} @@ -31,10 +33,11 @@ services: ezpublish.fieldType.ezmedia.externalStorage: class: eZ\Publish\Core\FieldType\Media\MediaStorage arguments: - - "@ezpublish.fieldType.ezmedia.storage_gateway" - - "@ezpublish.fieldType.ezbinaryfile.io_service" - - "@ezpublish.fieldType.ezbinaryfile.pathGenerator" - - "@ezpublish.core.io.mimeTypeDetector" + $gateway: '@ezpublish.fieldType.ezmedia.storage_gateway' + $ioService: '@ezpublish.fieldType.ezbinaryfile.io_service' + $pathGenerator: '@ezpublish.fieldType.ezbinaryfile.pathGenerator' + $mimeTypeDetector: '@ezpublish.core.io.mimeTypeDetector' + $fileExtensionBlackListValidator: '@ezpublish.fieldType.validator.black_list' tags: - {name: ezplatform.field_type.external_storage_handler, alias: ezmedia} diff --git a/eZ/Publish/SPI/Tests/FieldType/BinaryFileIntegrationTest.php b/eZ/Publish/SPI/Tests/FieldType/BinaryFileIntegrationTest.php index 522e0cf54b..c49d9ba54d 100644 --- a/eZ/Publish/SPI/Tests/FieldType/BinaryFileIntegrationTest.php +++ b/eZ/Publish/SPI/Tests/FieldType/BinaryFileIntegrationTest.php @@ -7,6 +7,7 @@ namespace eZ\Publish\SPI\Tests\FieldType; use eZ\Publish\Core\FieldType; +use eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator; use eZ\Publish\Core\IO\MimeTypeDetector\FileInfo; use eZ\Publish\Core\Persistence\Legacy; use eZ\Publish\SPI\Persistence\Content; @@ -38,6 +39,9 @@ */ class BinaryFileIntegrationTest extends FileBaseIntegrationTest { + /** @var \eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator&\PHPUnit\Framework\MockObject\MockObject */ + private $fileExtensionBlackListValidator; + /** * Returns the storage identifier prefix used by the file service. * @@ -71,6 +75,7 @@ public function getCustomHandler() $fieldType->setTransformationProcessor($this->getTransformationProcessor()); $this->ioService = self::$container->get('ezpublish.fieldType.ezbinaryfile.io_service'); + $this->fileExtensionBlackListValidator = $this->createMock(FileExtensionBlackListValidator::class); return $this->getHandler( 'ezbinaryfile', @@ -80,7 +85,8 @@ public function getCustomHandler() new FieldType\BinaryFile\BinaryFileStorage\Gateway\DoctrineStorage($this->getDatabaseConnection()), $this->ioService, new FieldType\BinaryBase\PathGenerator\LegacyPathGenerator(), - new FileInfo() + new FileInfo(), + $this->fileExtensionBlackListValidator ) ); } diff --git a/eZ/Publish/SPI/Tests/FieldType/ImageIntegrationTest.php b/eZ/Publish/SPI/Tests/FieldType/ImageIntegrationTest.php index 57a73de8ef..d8c2438263 100644 --- a/eZ/Publish/SPI/Tests/FieldType/ImageIntegrationTest.php +++ b/eZ/Publish/SPI/Tests/FieldType/ImageIntegrationTest.php @@ -9,6 +9,7 @@ use eZ\Publish\Core\Base\Utils\DeprecationWarnerInterface; use eZ\Publish\Core\FieldType; use eZ\Publish\Core\FieldType\Image\AliasCleanerInterface; +use eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator; use eZ\Publish\Core\IO; use eZ\Publish\Core\Persistence\Legacy; use eZ\Publish\SPI\Persistence\Content; @@ -48,6 +49,9 @@ class ImageIntegrationTest extends FileBaseIntegrationTest /** @var \eZ\Publish\Core\IO\FilePathNormalizer\Flysystem */ private $filePathNormalizer; + /** @var \eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator&\PHPUnit\Framework\MockObject\MockObject */ + private $fileExtensionBlackListValidator; + /** * Returns the storage identifier prefix used by the file service. * @@ -99,7 +103,8 @@ public function getCustomHandler() new IO\MetadataHandler\ImageSize(), $this->getDeprecationWarnerMock(), $this->getAliasCleanerMock(), - $this->getFilePathNormalizerMock() + $this->getFilePathNormalizerMock(), + $this->getFileExtensionBlackListValidatorMock() ) ); } @@ -138,6 +143,16 @@ private function getFilePathNormalizerMock(): IO\FilePathNormalizerInterface return $this->filePathNormalizer; } + private function getFileExtensionBlackListValidatorMock(): FileExtensionBlackListValidator + { + if (!isset($this->fileExtensionBlackListValidator)) { + $this->fileExtensionBlackListValidator = $this->createMock(FileExtensionBlackListValidator::class); + $this->fileExtensionBlackListValidator->expects(self::any())->method('validateFileExtension'); + } + + return $this->fileExtensionBlackListValidator; + } + /** * Returns the FieldTypeConstraints to be used to create a field definition * of the FieldType under test. diff --git a/eZ/Publish/SPI/Tests/FieldType/MediaIntegrationTest.php b/eZ/Publish/SPI/Tests/FieldType/MediaIntegrationTest.php index bde0fe2cac..cbcb268d7a 100644 --- a/eZ/Publish/SPI/Tests/FieldType/MediaIntegrationTest.php +++ b/eZ/Publish/SPI/Tests/FieldType/MediaIntegrationTest.php @@ -7,6 +7,7 @@ namespace eZ\Publish\SPI\Tests\FieldType; use eZ\Publish\Core\FieldType; +use eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator; use eZ\Publish\Core\IO\MimeTypeDetector\FileInfo; use eZ\Publish\Core\Persistence\Legacy; use eZ\Publish\SPI\Persistence\Content; @@ -38,6 +39,9 @@ */ class MediaIntegrationTest extends FileBaseIntegrationTest { + /** @var \eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator&\PHPUnit\Framework\MockObject\MockObject */ + private $fileExtensionBlackListValidator; + /** * Returns the storage identifier prefix used by the file service. * @@ -70,6 +74,8 @@ public function getCustomHandler() ]); $fieldType->setTransformationProcessor($this->getTransformationProcessor()); + $this->fileExtensionBlackListValidator = $this->createMock(FileExtensionBlackListValidator::class); + return $this->getHandler( 'ezmedia', $fieldType, @@ -78,7 +84,8 @@ public function getCustomHandler() new FieldType\Media\MediaStorage\Gateway\DoctrineStorage($this->getDatabaseConnection()), $this->ioService = self::$container->get('ezpublish.fieldType.ezbinaryfile.io_service'), $legacyPathGenerator = new FieldType\BinaryBase\PathGenerator\LegacyPathGenerator(), - new FileInfo() + new FileInfo(), + $this->fileExtensionBlackListValidator ) ); } diff --git a/tests/integration/Core/Image/ImageStorage/ImageStorageTest.php b/tests/integration/Core/Image/ImageStorage/ImageStorageTest.php index 6faed1b918..bf57bfcae1 100644 --- a/tests/integration/Core/Image/ImageStorage/ImageStorageTest.php +++ b/tests/integration/Core/Image/ImageStorage/ImageStorageTest.php @@ -15,6 +15,7 @@ use eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway\DoctrineStorage; use eZ\Publish\Core\FieldType\Image\PathGenerator; use eZ\Publish\Core\FieldType\Tests\Integration\BaseCoreFieldTypeIntegrationTest; +use eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator; use eZ\Publish\Core\IO\FilePathNormalizerInterface; use eZ\Publish\Core\IO\IOServiceInterface; use eZ\Publish\Core\IO\MetadataHandler; @@ -54,6 +55,9 @@ final class ImageStorageTest extends BaseCoreFieldTypeIntegrationTest /** @var \eZ\Publish\Core\FieldType\Image\ImageStorage */ private $storage; + /** @var \eZ\Publish\Core\FieldType\Validator\FileExtensionBlackListValidator&\PHPUnit\Framework\MockObject\MockObject */ + private $fileExtensionBlackListValidator; + protected function setUp(): void { parent::setUp(); @@ -66,6 +70,7 @@ protected function setUp(): void $this->aliasCleaner = $this->createMock(AliasCleanerInterface::class); $this->filePathNormalizer = $this->createMock(FilePathNormalizerInterface::class); $this->ioService = $this->createMock(IOServiceInterface::class); + $this->fileExtensionBlackListValidator = $this->createMock(FileExtensionBlackListValidator::class); $this->storage = new ImageStorage( $this->gateway, $this->ioService, @@ -74,6 +79,7 @@ protected function setUp(): void $this->deprecationWarner, $this->aliasCleaner, $this->filePathNormalizer, + $this->fileExtensionBlackListValidator ); }