diff --git a/typo3/sysext/form/Classes/Mvc/Property/PropertyMappingConfiguration.php b/typo3/sysext/form/Classes/Mvc/Property/PropertyMappingConfiguration.php index 9e5188b53407..bc4fc0da14b9 100644 --- a/typo3/sysext/form/Classes/Mvc/Property/PropertyMappingConfiguration.php +++ b/typo3/sysext/form/Classes/Mvc/Property/PropertyMappingConfiguration.php @@ -56,7 +56,7 @@ public function afterBuildingFinished(RenderableInterface $renderable) $allowedMimeTypes = []; $validators = []; - if (is_array($renderable->getProperties()['allowedMimeTypes'])) { + if (isset($renderable->getProperties()['allowedMimeTypes']) && \is_array($renderable->getProperties()['allowedMimeTypes'])) { $allowedMimeTypes = array_filter($renderable->getProperties()['allowedMimeTypes']); } if (!empty($allowedMimeTypes)) { diff --git a/typo3/sysext/form/Tests/Unit/Mvc/Configuration/InheritancesResolverServiceTest.php b/typo3/sysext/form/Tests/Unit/Mvc/Configuration/InheritancesResolverServiceTest.php index 9717db4b21e6..4a7de0b257dd 100644 --- a/typo3/sysext/form/Tests/Unit/Mvc/Configuration/InheritancesResolverServiceTest.php +++ b/typo3/sysext/form/Tests/Unit/Mvc/Configuration/InheritancesResolverServiceTest.php @@ -1,4 +1,5 @@ [ @@ -80,7 +77,7 @@ public function getDocExampleInheritance() /** * @test */ - public function getMergedConfigurationSimpleInheritance() + public function getMergedConfigurationSimpleInheritance(): void { $input = [ 'Form' => [ @@ -121,7 +118,7 @@ public function getMergedConfigurationSimpleInheritance() /** * @test */ - public function getMergedConfigurationSimpleInheritanceOverrideValue() + public function getMergedConfigurationSimpleInheritanceOverrideValue(): void { $input = [ 'Form' => [ @@ -154,7 +151,7 @@ public function getMergedConfigurationSimpleInheritanceOverrideValue() /** * @test */ - public function getMergedConfigurationSimpleInheritanceRemoveValue() + public function getMergedConfigurationSimpleInheritanceRemoveValue(): void { $input = [ 'Form' => [ @@ -219,7 +216,7 @@ public function getMergedConfigurationSimpleInheritanceRemoveValue() /** * @test */ - public function getMergedConfigurationSimpleMixin() + public function getMergedConfigurationSimpleMixin(): void { $input = [ 'Form' => [ @@ -263,7 +260,7 @@ public function getMergedConfigurationSimpleMixin() /** * @test */ - public function getMergedConfigurationAdvancedMixin() + public function getMergedConfigurationAdvancedMixin(): void { $input = [ 'Form' => [ @@ -356,7 +353,7 @@ public function getMergedConfigurationAdvancedMixin() /** * @test */ - public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLevelIsFound() + public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLevelIsFound(): void { $input = [ 'TYPO3' => [ @@ -386,7 +383,7 @@ public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLev /** * @test */ - public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLevelWithGapIsFound() + public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLevelWithGapIsFound(): void { $input = [ 'TYPO3' => [ @@ -426,7 +423,7 @@ public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLev /** * @test */ - public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnHigherLevelIsFound() + public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnHigherLevelIsFound(): void { $input = [ 'TYPO3' => [ diff --git a/typo3/sysext/form/Tests/Unit/Mvc/Persistence/FormPersistenceManagerTest.php b/typo3/sysext/form/Tests/Unit/Mvc/Persistence/FormPersistenceManagerTest.php index d26ab5276499..dacb67224f30 100644 --- a/typo3/sysext/form/Tests/Unit/Mvc/Persistence/FormPersistenceManagerTest.php +++ b/typo3/sysext/form/Tests/Unit/Mvc/Persistence/FormPersistenceManagerTest.php @@ -1,4 +1,5 @@ expectException(PersistenceManagerException::class); $this->expectExceptionCode(1477679819); @@ -50,7 +47,7 @@ public function loadThrowsExceptionIfPersistenceIdentifierHasNoYamlExtension() /** * @test */ - public function loadThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationWhichIsNotAllowed() + public function loadThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationWhichIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1484071985); @@ -72,7 +69,7 @@ public function loadThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationWh /** * @test */ - public function saveThrowsExceptionIfPersistenceIdentifierHasNoYamlExtension() + public function saveThrowsExceptionIfPersistenceIdentifierHasNoYamlExtension(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1477679820); @@ -88,7 +85,7 @@ public function saveThrowsExceptionIfPersistenceIdentifierHasNoYamlExtension() /** * @test */ - public function saveThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationAndSaveToExtensionLocationIsNotAllowed() + public function saveThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationAndSaveToExtensionLocationIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1477680881); @@ -110,7 +107,7 @@ public function saveThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationAn /** * @test */ - public function saveThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationWhichIsNotAllowed() + public function saveThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationWhichIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1484073571); @@ -133,7 +130,7 @@ public function saveThrowsExceptionIfPersistenceIdentifierIsAExtensionLocationWh /** * @test */ - public function deleteThrowsExceptionIfPersistenceIdentifierHasNoYamlExtension() + public function deleteThrowsExceptionIfPersistenceIdentifierHasNoYamlExtension(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1472239534); @@ -149,7 +146,7 @@ public function deleteThrowsExceptionIfPersistenceIdentifierHasNoYamlExtension() /** * @test */ - public function deleteThrowsExceptionIfPersistenceIdentifierFileDoesNotExists() + public function deleteThrowsExceptionIfPersistenceIdentifierFileDoesNotExists(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1472239535); @@ -170,7 +167,7 @@ public function deleteThrowsExceptionIfPersistenceIdentifierFileDoesNotExists() /** * @test */ - public function deleteThrowsExceptionIfPersistenceIdentifierIsExtensionLocationAndDeleteFromExtensionLocationsIsNotAllowed() + public function deleteThrowsExceptionIfPersistenceIdentifierIsExtensionLocationAndDeleteFromExtensionLocationsIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1472239536); @@ -197,7 +194,7 @@ public function deleteThrowsExceptionIfPersistenceIdentifierIsExtensionLocationA /** * @test */ - public function deleteThrowsExceptionIfPersistenceIdentifierIsExtensionLocationWhichIsNotAllowed() + public function deleteThrowsExceptionIfPersistenceIdentifierIsExtensionLocationWhichIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1484073878); @@ -225,7 +222,7 @@ public function deleteThrowsExceptionIfPersistenceIdentifierIsExtensionLocationW /** * @test */ - public function deleteThrowsExceptionIfPersistenceIdentifierIsStorageLocationAndDeleteFromStorageIsNotAllowed() + public function deleteThrowsExceptionIfPersistenceIdentifierIsStorageLocationAndDeleteFromStorageIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1472239516); @@ -244,7 +241,7 @@ public function deleteThrowsExceptionIfPersistenceIdentifierIsStorageLocationAnd ->method('checkFileActionPermission') ->willReturn(false); - $file = new File(['identifier' => '', 'mime_type' => ''], $mockStorage); + $file = new File(['name' => 'foo', 'identifier' => '', 'mime_type' => ''], $mockStorage); $mockStorage ->expects($this->any()) ->method('getFile') @@ -267,7 +264,7 @@ public function deleteThrowsExceptionIfPersistenceIdentifierIsStorageLocationAnd /** * @test */ - public function existsReturnsTrueIfPersistenceIdentifierIsExtensionLocationAndFileExistsAndFileHasYamlExtension() + public function existsReturnsTrueIfPersistenceIdentifierIsExtensionLocationAndFileExistsAndFileHasYamlExtension(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'dummy' @@ -288,7 +285,7 @@ public function existsReturnsTrueIfPersistenceIdentifierIsExtensionLocationAndFi /** * @test */ - public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndFileExistsAndFileHasNoYamlExtension() + public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndFileExistsAndFileHasNoYamlExtension(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'dummy' @@ -301,7 +298,7 @@ public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndF /** * @test */ - public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndFileExistsAndExtensionLocationIsNotAllowed() + public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndFileExistsAndExtensionLocationIsNotAllowed(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'dummy' @@ -320,7 +317,7 @@ public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndF /** * @test */ - public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndFileNotExistsAndFileHasYamlExtension() + public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndFileNotExistsAndFileHasYamlExtension(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'dummy' @@ -333,7 +330,7 @@ public function existsReturnsFalseIfPersistenceIdentifierIsExtensionLocationAndF /** * @test */ - public function existsReturnsTrueIfPersistenceIdentifierIsStorageLocationAndFileExistsAndFileHasYamlExtension() + public function existsReturnsTrueIfPersistenceIdentifierIsStorageLocationAndFileExistsAndFileHasYamlExtension(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'getStorageByUid' @@ -359,7 +356,7 @@ public function existsReturnsTrueIfPersistenceIdentifierIsStorageLocationAndFile /** * @test */ - public function existsReturnsFalseIfPersistenceIdentifierIsStorageLocationAndFileExistsAndFileNoYamlExtension() + public function existsReturnsFalseIfPersistenceIdentifierIsStorageLocationAndFileExistsAndFileNoYamlExtension(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'getStorageByUid' @@ -385,7 +382,7 @@ public function existsReturnsFalseIfPersistenceIdentifierIsStorageLocationAndFil /** * @test */ - public function existsReturnsFalseIfPersistenceIdentifierIsStorageLocationAndFileNotExistsAndFileHasYamlExtension() + public function existsReturnsFalseIfPersistenceIdentifierIsStorageLocationAndFileNotExistsAndFileHasYamlExtension(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'getStorageByUid' @@ -411,7 +408,7 @@ public function existsReturnsFalseIfPersistenceIdentifierIsStorageLocationAndFil /** * @test */ - public function getUniquePersistenceIdentifierAppendNumberIfPersistenceIdentifierExists() + public function getUniquePersistenceIdentifierAppendNumberIfPersistenceIdentifierExists(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'exists' @@ -440,7 +437,7 @@ public function getUniquePersistenceIdentifierAppendNumberIfPersistenceIdentifie /** * @test */ - public function getUniquePersistenceIdentifierAppendTimestampIfPersistenceIdentifierExists() + public function getUniquePersistenceIdentifierAppendTimestampIfPersistenceIdentifierExists(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'exists' @@ -468,7 +465,7 @@ public function getUniquePersistenceIdentifierAppendTimestampIfPersistenceIdenti /** * @test */ - public function getUniqueIdentifierThrowsExceptionIfIdentifierExists() + public function getUniqueIdentifierThrowsExceptionIfIdentifierExists(): void { $this->expectException(NoUniqueIdentifierException::class); $this->expectExceptionCode(1477688567); @@ -489,7 +486,7 @@ public function getUniqueIdentifierThrowsExceptionIfIdentifierExists() /** * @test */ - public function getUniqueIdentifierAppendTimestampIfIdentifierExists() + public function getUniqueIdentifierAppendTimestampIfIdentifierExists(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'checkForDuplicateIdentifier' @@ -517,14 +514,14 @@ public function getUniqueIdentifierAppendTimestampIfIdentifierExists() /** * @test */ - public function checkForDuplicateIdentifierReturnsTrueIfIdentifierIsUsed() + public function checkForDuplicateIdentifierReturnsTrueIfIdentifierIsUsed(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'listForms' ], [], '', false); $mockFormPersistenceManager - ->expects($this->at($attempts)) + ->expects($this->at(null)) ->method('listForms') ->willReturn([ 0 => [ @@ -539,14 +536,14 @@ public function checkForDuplicateIdentifierReturnsTrueIfIdentifierIsUsed() /** * @test */ - public function checkForDuplicateIdentifierReturnsFalseIfIdentifierIsUsed() + public function checkForDuplicateIdentifierReturnsFalseIfIdentifierIsUsed(): void { $mockFormPersistenceManager = $this->getAccessibleMock(FormPersistenceManager::class, [ 'listForms' ], [], '', false); $mockFormPersistenceManager - ->expects($this->at($attempts)) + ->expects($this->at(null)) ->method('listForms') ->willReturn([ 0 => [ @@ -561,7 +558,7 @@ public function checkForDuplicateIdentifierReturnsFalseIfIdentifierIsUsed() /** * @test */ - public function getFileByIdentifierThrowsExceptionIfReadFromStorageIsNotAllowed() + public function getFileByIdentifierThrowsExceptionIfReadFromStorageIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1471630578); @@ -579,7 +576,7 @@ public function getFileByIdentifierThrowsExceptionIfReadFromStorageIsNotAllowed( ->method('checkFileActionPermission') ->willReturn(false); - $file = new File(['identifier' => '', 'mime_type' => ''], $mockStorage); + $file = new File(['name' => 'foo', 'identifier' => '', 'mime_type' => ''], $mockStorage); $mockStorage ->expects($this->any()) ->method('getFile') @@ -597,7 +594,7 @@ public function getFileByIdentifierThrowsExceptionIfReadFromStorageIsNotAllowed( /** * @test */ - public function getOrCreateFileThrowsExceptionIfFolderNotExistsInStorage() + public function getOrCreateFileThrowsExceptionIfFolderNotExistsInStorage(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1471630579); @@ -627,7 +624,7 @@ public function getOrCreateFileThrowsExceptionIfFolderNotExistsInStorage() /** * @test */ - public function getOrCreateFileThrowsExceptionIfWriteToStorageIsNotAllowed() + public function getOrCreateFileThrowsExceptionIfWriteToStorageIsNotAllowed(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1471630580); @@ -650,7 +647,7 @@ public function getOrCreateFileThrowsExceptionIfWriteToStorageIsNotAllowed() ->method('checkFileActionPermission') ->willReturn(false); - $file = new File(['identifier' => '', 'mime_type' => ''], $mockStorage); + $file = new File(['name' => 'foo', 'identifier' => '', 'mime_type' => ''], $mockStorage); $mockStorage ->expects($this->any()) ->method('getFile') @@ -668,7 +665,7 @@ public function getOrCreateFileThrowsExceptionIfWriteToStorageIsNotAllowed() /** * @test */ - public function getStorageByUidThrowsExceptionIfStorageNotExists() + public function getStorageByUidThrowsExceptionIfStorageNotExists(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1471630581); @@ -693,7 +690,7 @@ public function getStorageByUidThrowsExceptionIfStorageNotExists() /** * @test */ - public function getStorageByUidThrowsExceptionIfStorageIsNotBrowsable() + public function getStorageByUidThrowsExceptionIfStorageIsNotBrowsable(): void { $this->expectException(PersistenceManagerException::class); $this->expectExceptionCode(1471630581); diff --git a/typo3/sysext/form/Tests/Unit/Mvc/Property/PropertyMappingConfigurationTest.php b/typo3/sysext/form/Tests/Unit/Mvc/Property/PropertyMappingConfigurationTest.php index 4f4c93c118bf..525d108576be 100644 --- a/typo3/sysext/form/Tests/Unit/Mvc/Property/PropertyMappingConfigurationTest.php +++ b/typo3/sysext/form/Tests/Unit/Mvc/Property/PropertyMappingConfigurationTest.php @@ -2,6 +2,19 @@ declare(strict_types = 1); namespace TYPO3\CMS\Form\Mvc\Property; +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Object\ObjectManager; @@ -15,13 +28,11 @@ use TYPO3\CMS\Form\Mvc\Validation\MimeTypeValidator; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; +/** + * Test case + */ class PropertyMappingConfigurationTest extends UnitTestCase { - /** - * Subject is not notice free, disable E_NOTICES - */ - protected static $suppressNotices = true; - /** @var PropertyMappingConfiguration */ protected $propertyMappingConfiguration; @@ -91,7 +102,7 @@ public function setUp() $this->propertyMappingConfiguration = new PropertyMappingConfiguration(); } - public function tearDown() + public function tearDown(): void { // Remove all singleton instances GeneralUtility::resetSingletonInstances($this->singletons); @@ -102,7 +113,7 @@ public function tearDown() * A bare minimum test that checks if the function maybe potentially works. * @test */ - public function afterBuildingFinishedAddsFileReferenceConverter() + public function afterBuildingFinishedAddsFileReferenceConverter(): void { // Mime Type Validator /** @var \PHPUnit_Framework_MockObject_MockObject|MimeTypeValidator $mimeTypeValidator */ @@ -153,7 +164,7 @@ public function afterBuildingFinishedAddsFileReferenceConverter() /** * @test */ - public function afterBuildingFinishedAddsMimeTypeConverter() + public function afterBuildingFinishedAddsMimeTypeConverter(): void { $mimeTypes = ['allowedMimeTypes' => ['text/plain', 'application/x-www-form-urlencoded']]; @@ -208,7 +219,7 @@ public function afterBuildingFinishedAddsMimeTypeConverter() /** * @test */ - public function afterBuildingFinishedSetsUpStoragePathToPropertySaveToFileMountIfItExists() + public function afterBuildingFinishedSetsUpStoragePathToPropertySaveToFileMountIfItExists(): void { // Mime Type Validator /** @var \PHPUnit_Framework_MockObject_MockObject|MimeTypeValidator $mimeTypeValidator */ @@ -264,7 +275,7 @@ public function afterBuildingFinishedSetsUpStoragePathToPropertySaveToFileMountI /** * @test */ - public function afterBuildingFinishedSetsUpStoragePathToToFormDefinitionPathIfSaveToFileMountIsNotDefinedAndFormWasNotAddedProgrammatically() + public function afterBuildingFinishedSetsUpStoragePathToToFormDefinitionPathIfSaveToFileMountIsNotDefinedAndFormWasNotAddedProgrammatically(): void { // Mime Type Validator /** @var \PHPUnit_Framework_MockObject_MockObject|MimeTypeValidator $mimeTypeValidator */ @@ -325,7 +336,7 @@ public function afterBuildingFinishedSetsUpStoragePathToToFormDefinitionPathIfSa /** * @test */ - public function afterBuildingFinishedSetsStoragePathToUserUploadIfNeitherSaveToFileMountIsSetNorThereIsAFormDefinitionPath() + public function afterBuildingFinishedSetsStoragePathToUserUploadIfNeitherSaveToFileMountIsSetNorThereIsAFormDefinitionPath(): void { // Mime Type Validator /** @var \PHPUnit_Framework_MockObject_MockObject|MimeTypeValidator $mimeTypeValidator */ @@ -383,7 +394,7 @@ public function afterBuildingFinishedSetsStoragePathToUserUploadIfNeitherSaveToF /** * @test */ - public function afterBuildingFinishedCopiesValidators() + public function afterBuildingFinishedCopiesValidators(): void { // Mime Type Validator /** @var \PHPUnit_Framework_MockObject_MockObject|MimeTypeValidator $mimeTypeValidator */ @@ -439,7 +450,7 @@ public function afterBuildingFinishedCopiesValidators() /** * @test */ - public function afterBuildingFinishedDoesNotCopyNotEmptyValidator() + public function afterBuildingFinishedDoesNotCopyNotEmptyValidator(): void { // Mime Type Validator /** @var \PHPUnit_Framework_MockObject_MockObject|MimeTypeValidator $mimeTypeValidator */ diff --git a/typo3/sysext/form/Tests/Unit/Mvc/Validation/MimeTypeValidatorTest.php b/typo3/sysext/form/Tests/Unit/Mvc/Validation/MimeTypeValidatorTest.php index f8dbaa19eff4..09d234247d69 100644 --- a/typo3/sysext/form/Tests/Unit/Mvc/Validation/MimeTypeValidatorTest.php +++ b/typo3/sysext/form/Tests/Unit/Mvc/Validation/MimeTypeValidatorTest.php @@ -75,7 +75,7 @@ public function MimeTypeValidatorReturnsTrueIfFileResourceIsNotAllowedMimeType() ->disableOriginalConstructor() ->getMock(); - $file = new File(['identifier' => '/foo', 'mime_type' => 'image/png'], $mockedStorage); + $file = new File(['name' => 'foo', 'identifier' => '/foo', 'mime_type' => 'image/png'], $mockedStorage); $this->assertTrue($validator->validate($file)->hasErrors()); }