diff --git a/.php_cs b/.php_cs index d710559e..eee67840 100644 --- a/.php_cs +++ b/.php_cs @@ -38,6 +38,7 @@ return PhpCsFixer\Config::create() 'declare_strict_types' => false, 'native_function_invocation' => true, 'fopen_flags' => ['b_mode' => true], + 'php_unit_mock_short_will_return' => true, ]) ->setFinder($finder) ; diff --git a/Metadata/Driver/AnnotationDriver.php b/Metadata/Driver/AnnotationDriver.php index 7d5c210e..24cdd93c 100644 --- a/Metadata/Driver/AnnotationDriver.php +++ b/Metadata/Driver/AnnotationDriver.php @@ -46,10 +46,10 @@ public function loadMetadataForClass(\ReflectionClass $class): ?JMSClassMetadata $classes[] = $class; $class = $class->getParentClass(); } while (false !== $class); - $classes = array_reverse($classes, false); + $classes = \array_reverse($classes, false); $properties = []; foreach ($classes as $class) { - $properties = array_merge($properties, $class->getProperties()); + $properties = \array_merge($properties, $class->getProperties()); } foreach ($properties as $property) { diff --git a/Naming/CurrentDateTimeDirectoryNamer.php b/Naming/CurrentDateTimeDirectoryNamer.php index 379e436b..95b911ef 100644 --- a/Naming/CurrentDateTimeDirectoryNamer.php +++ b/Naming/CurrentDateTimeDirectoryNamer.php @@ -66,7 +66,7 @@ public function directoryName($object, PropertyMapping $mapping): string } else { // see https://github.com/dustin10/VichUploaderBundle/issues/992 $msg = 'Not passing "date_time_property" option is deprecated and will be removed in version 2.'; - @trigger_error($msg, E_USER_DEPRECATED); + @\trigger_error($msg, E_USER_DEPRECATED); $dateTime = $this->dateTimeHelper->getTimestamp(); } diff --git a/Tests/Adapter/ODM/MongoDB/MongoDBAdapterTest.php b/Tests/Adapter/ODM/MongoDB/MongoDBAdapterTest.php index 28f7ba6f..e9589739 100644 --- a/Tests/Adapter/ODM/MongoDB/MongoDBAdapterTest.php +++ b/Tests/Adapter/ODM/MongoDB/MongoDBAdapterTest.php @@ -34,7 +34,7 @@ public function testGetObjectFromArgs(): void $args ->expects($this->once()) ->method('getDocument') - ->will($this->returnValue($entity)); + ->willReturn($entity); $adapter = new MongoDBAdapter(); diff --git a/Tests/Adapter/ORM/DoctrineORMAdapterTest.php b/Tests/Adapter/ORM/DoctrineORMAdapterTest.php index 3a9ac1d1..3ba28391 100644 --- a/Tests/Adapter/ORM/DoctrineORMAdapterTest.php +++ b/Tests/Adapter/ORM/DoctrineORMAdapterTest.php @@ -34,7 +34,7 @@ public function testGetObjectFromArgs(): void $args ->expects($this->once()) ->method('getEntity') - ->will($this->returnValue($entity)); + ->willReturn($entity); $adapter = new DoctrineORMAdapter(); diff --git a/Tests/Adapter/PHPCR/PHPCRAdapterTest.php b/Tests/Adapter/PHPCR/PHPCRAdapterTest.php index 11dbca51..a842e623 100644 --- a/Tests/Adapter/PHPCR/PHPCRAdapterTest.php +++ b/Tests/Adapter/PHPCR/PHPCRAdapterTest.php @@ -30,7 +30,7 @@ public function testGetObjectFromArgs(): void $args ->expects($this->once()) ->method('getObject') - ->will($this->returnValue($entity)); + ->willReturn($entity); $adapter = new PHPCRAdapter(); diff --git a/Tests/Adapter/Propel/PropelORMAdapterTest.php b/Tests/Adapter/Propel/PropelORMAdapterTest.php index 1e4b434a..a78ab4ed 100644 --- a/Tests/Adapter/Propel/PropelORMAdapterTest.php +++ b/Tests/Adapter/Propel/PropelORMAdapterTest.php @@ -33,7 +33,7 @@ public function testGetObjectFromArgs(): void $event ->expects($this->once()) ->method('getSubject') - ->will($this->returnValue(42)); + ->willReturn(42); $this->assertSame(42, $this->adapter->getObjectFromArgs($event)); } diff --git a/Tests/EventListener/Doctrine/CleanListenerTest.php b/Tests/EventListener/Doctrine/CleanListenerTest.php index 5d205743..c421021e 100644 --- a/Tests/EventListener/Doctrine/CleanListenerTest.php +++ b/Tests/EventListener/Doctrine/CleanListenerTest.php @@ -41,15 +41,15 @@ public function testPreUpdate(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class, self::MAPPING_NAME) - ->will($this->returnValue([ + ->willReturn([ ['propertyName' => 'field_name'], - ])); + ]); $this->handler ->expects($this->once()) @@ -73,7 +73,7 @@ public function testPreUpdateSkipsNonUploadable(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(false)); + ->willReturn(false); $this->handler ->expects($this->never()) diff --git a/Tests/EventListener/Doctrine/InjectListenerTest.php b/Tests/EventListener/Doctrine/InjectListenerTest.php index 07a26d50..181905ee 100644 --- a/Tests/EventListener/Doctrine/InjectListenerTest.php +++ b/Tests/EventListener/Doctrine/InjectListenerTest.php @@ -41,15 +41,15 @@ public function testPostLoad(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class, self::MAPPING_NAME) - ->will($this->returnValue([ + ->willReturn([ ['propertyName' => 'field_name'], - ])); + ]); $this->handler ->expects($this->once()) @@ -68,7 +68,7 @@ public function testPostLoadSkipsNonUploadable(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(false)); + ->willReturn(false); $this->handler ->expects($this->never()) diff --git a/Tests/EventListener/Doctrine/ListenerTestCase.php b/Tests/EventListener/Doctrine/ListenerTestCase.php index 33ab5c91..2a1a77fe 100644 --- a/Tests/EventListener/Doctrine/ListenerTestCase.php +++ b/Tests/EventListener/Doctrine/ListenerTestCase.php @@ -63,9 +63,9 @@ protected function setUp(): void ->expects($this->any()) ->method('getObjectFromArgs') ->with($this->event) - ->will($this->returnCallback(function () use ($that) { + ->willReturnCallback(function () use ($that) { return $that->object; - })); + }); } /** diff --git a/Tests/EventListener/Doctrine/RemoveListenerTest.php b/Tests/EventListener/Doctrine/RemoveListenerTest.php index 2be0cc02..6319fedb 100644 --- a/Tests/EventListener/Doctrine/RemoveListenerTest.php +++ b/Tests/EventListener/Doctrine/RemoveListenerTest.php @@ -44,7 +44,7 @@ public function testPreRemove(): void ->expects($this->once()) ->method('isUploadable') ->with('VichUploaderEntityProxy') - ->will($this->returnValue(true)); + ->willReturn(true); $this->listener->preRemove($this->event); } @@ -60,7 +60,7 @@ public function testPreRemoveSkipNonUploadable(): void ->expects($this->once()) ->method('isUploadable') ->with('VichUploaderEntityProxy') - ->will($this->returnValue(false)); + ->willReturn(false); $this->listener->preRemove($this->event); } @@ -74,15 +74,15 @@ public function testPostRemove(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class, self::MAPPING_NAME) - ->will($this->returnValue([ + ->willReturn([ ['propertyName' => 'field_name'], - ])); + ]); $this->handler ->expects($this->once()) @@ -101,7 +101,7 @@ public function testPostRemoveSkipsNonUploadable(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(false)); + ->willReturn(false); $this->handler ->expects($this->never()) diff --git a/Tests/EventListener/Doctrine/UploadListenerTest.php b/Tests/EventListener/Doctrine/UploadListenerTest.php index ff5963ed..864968f8 100644 --- a/Tests/EventListener/Doctrine/UploadListenerTest.php +++ b/Tests/EventListener/Doctrine/UploadListenerTest.php @@ -41,15 +41,15 @@ public function testPrePersist(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class, self::MAPPING_NAME) - ->will($this->returnValue([ + ->willReturn([ ['propertyName' => 'field_name'], - ])); + ]); $this->handler ->expects($this->once()) @@ -68,7 +68,7 @@ public function testPrePersistSkipsNonUploadable(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(false)); + ->willReturn(false); $this->handler ->expects($this->never()) @@ -91,15 +91,15 @@ public function testPreUpdate(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class, self::MAPPING_NAME) - ->will($this->returnValue([ + ->willReturn([ ['propertyName' => 'field_name'], - ])); + ]); $this->handler ->expects($this->once()) @@ -118,7 +118,7 @@ public function testPreUpdateSkipsNonUploadable(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(false)); + ->willReturn(false); $this->adapter ->expects($this->never()) diff --git a/Tests/EventListener/Propel/ListenerTestCase.php b/Tests/EventListener/Propel/ListenerTestCase.php index 845fe9a5..31bd4f3c 100644 --- a/Tests/EventListener/Propel/ListenerTestCase.php +++ b/Tests/EventListener/Propel/ListenerTestCase.php @@ -66,15 +66,15 @@ protected function setUp(): void ->expects($this->any()) ->method('getObjectFromArgs') ->with($this->event) - ->will($this->returnValue($this->object)); + ->willReturn($this->object); $this->metadata ->expects($this->any()) ->method('getUploadableFields') ->with(DummyEntity::class, self::MAPPING_NAME) - ->will($this->returnValue([ + ->willReturn([ ['propertyName' => self::FIELD_NAME], - ])); + ]); } /** diff --git a/Tests/Form/Type/VichFileTypeTest.php b/Tests/Form/Type/VichFileTypeTest.php index f207924e..db45428b 100644 --- a/Tests/Form/Type/VichFileTypeTest.php +++ b/Tests/Form/Type/VichFileTypeTest.php @@ -82,23 +82,23 @@ public function testBuildView(Product $object = null, array $options, array $var ->expects($this->any()) ->method('resolveUri') ->with($object, $field) - ->will($this->returnValue('resolved-uri')); + ->willReturn('resolved-uri'); $parentForm = $this->createMock(FormInterface::class); $parentForm ->expects($this->any()) ->method('getData') - ->will($this->returnValue($object)); + ->willReturn($object); $form = $this->createMock(FormInterface::class); $form ->expects($this->any()) ->method('getParent') - ->will($this->returnValue($parentForm)); + ->willReturn($parentForm); $form ->expects($this->any()) ->method('getName') - ->will($this->returnValue($field)); + ->willReturn($field); $uploadHandler = $this->createMock(UploadHandler::class); $propertyMappingFactory = $this->createMock(PropertyMappingFactory::class); @@ -112,13 +112,13 @@ public function testBuildView(Product $object = null, array $options, array $var ->expects($this->once()) ->method('readProperty') ->with($object, 'originalName') - ->will($this->returnValue($object->getImageOriginalName())); + ->willReturn($object->getImageOriginalName()); $propertyMappingFactory ->expects($this->once()) ->method('fromField') ->with($object, $field) - ->will($this->returnValue($mapping)); + ->willReturn($mapping); } if ($options['download_label'] instanceof PropertyPath) { @@ -126,7 +126,7 @@ public function testBuildView(Product $object = null, array $options, array $var ->expects($this->once()) ->method('getValue') ->with($object, $options['download_label']) - ->will($this->returnValue($object->getTitle())); + ->willReturn($object->getTitle()); } } diff --git a/Tests/Form/Type/VichImageTypeTest.php b/Tests/Form/Type/VichImageTypeTest.php index 7fb84120..ea1fa03e 100644 --- a/Tests/Form/Type/VichImageTypeTest.php +++ b/Tests/Form/Type/VichImageTypeTest.php @@ -148,23 +148,23 @@ public function testLiipImagineBundleIntegration(): void ->expects($this->any()) ->method('resolveUri') ->with($object, $field) - ->will($this->returnValue('resolved-uri')); + ->willReturn('resolved-uri'); $parentForm = $this->createMock(FormInterface::class); $parentForm ->expects($this->any()) ->method('getData') - ->will($this->returnValue($object)); + ->willReturn($object); $form = $this->createMock(FormInterface::class); $form ->expects($this->any()) ->method('getParent') - ->will($this->returnValue($parentForm)); + ->willReturn($parentForm); $form ->expects($this->any()) ->method('getName') - ->will($this->returnValue($field)); + ->willReturn($field); $uploadHandler = $this->createMock(UploadHandler::class); $propertyMappingFactory = $this->createMock(PropertyMappingFactory::class); @@ -176,7 +176,7 @@ public function testLiipImagineBundleIntegration(): void ->expects($this->once()) ->method('getBrowserPath') ->with('resolved-uri', 'product_sq200') - ->will($this->returnValue('product_sq200/resolved-uri')); + ->willReturn('product_sq200/resolved-uri'); $testedType = static::TESTED_TYPE; @@ -222,13 +222,13 @@ public function testLiipImagineBundleIntegrationThrownExceptionIfNotAvailable(): $parentForm ->expects($this->any()) ->method('getData') - ->will($this->returnValue($object)); + ->willReturn($object); $form = $this->createMock(FormInterface::class); $form ->expects($this->any()) ->method('getParent') - ->will($this->returnValue($parentForm)); + ->willReturn($parentForm); $view = new FormView(); $type = new $testedType($storage, $uploadHandler, $propertyMappingFactory, $propertyAccessor); diff --git a/Tests/Handler/DownloadHandlerTest.php b/Tests/Handler/DownloadHandlerTest.php index 84a7109e..256cb1c5 100644 --- a/Tests/Handler/DownloadHandlerTest.php +++ b/Tests/Handler/DownloadHandlerTest.php @@ -41,7 +41,7 @@ protected function setUp(): void ->expects($this->any()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); } public function filenamesProvider(): array @@ -65,24 +65,24 @@ public function testDownloadObject($fileName, $expectedFileName): void ->expects($this->once()) ->method('getFileName') ->with($this->object) - ->will($this->returnValue($fileName)); + ->willReturn($fileName); $this->mapping ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue($file)); + ->willReturn($file); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue(null)); + ->willReturn(null); $this->storage ->expects($this->once()) ->method('resolveStream') ->with($this->object, 'file_field') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $response = $this->handler->downloadObject($this->object, 'file_field'); @@ -101,24 +101,24 @@ public function testDisplayObject($fileName, $expectedFileName): void ->expects($this->once()) ->method('getFileName') ->with($this->object) - ->will($this->returnValue($fileName)); + ->willReturn($fileName); $this->mapping ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue($file)); + ->willReturn($file); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/pdf')); + ->willReturn('application/pdf'); $this->storage ->expects($this->once()) ->method('resolveStream') ->with($this->object, 'file_field') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $response = $this->handler->downloadObject($this->object, 'file_field', null, null, false); @@ -135,19 +135,19 @@ public function testDownloadObjectWithoutFile($fileName, $expectedFileName): voi ->expects($this->once()) ->method('getFileName') ->with($this->object) - ->will($this->returnValue($fileName)); + ->willReturn($fileName); $this->mapping ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue(null)); + ->willReturn(null); $this->storage ->expects($this->once()) ->method('resolveStream') ->with($this->object, 'file_field') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $response = $this->handler->downloadObject($this->object, 'file_field'); @@ -162,10 +162,10 @@ public function testDownloadObjectCallOriginalName(): void $this->mapping ->expects($this->exactly(2)) ->method('readProperty') - ->will($this->returnValueMap([ + ->willReturnMap([ [$this->object, 'originalName', $this->object->getImageOriginalName()], [$this->object, 'mimeType', $this->object->getImageMimeType()], - ])); + ]); $file = $this->getUploadedFileMock(); @@ -173,18 +173,18 @@ public function testDownloadObjectCallOriginalName(): void ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue($file)); + ->willReturn($file); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue('application/octet-stream')); + ->willReturn('application/octet-stream'); $this->storage ->expects($this->once()) ->method('resolveStream') ->with($this->object, 'file_field') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $response = $this->handler->downloadObject($this->object, 'file_field', null, true); @@ -201,18 +201,18 @@ public function testNonAsciiFilenameIsTransliterated(): void ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue($file)); + ->willReturn($file); $file ->expects($this->once()) ->method('getMimeType') - ->will($this->returnValue(null)); + ->willReturn(null); $this->storage ->expects($this->once()) ->method('resolveStream') ->with($this->object, 'file_field') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $response = $this->handler->downloadObject($this->object, 'file_field', null, 'ÉÁŰÚŐPÓÜÉŰÍÍÍÍ$$$$$$$++4334º'); @@ -237,7 +237,7 @@ public function testAnExceptionIsThrownIfNoFileIsFound(): void ->expects($this->once()) ->method('resolveStream') ->with($this->object, 'file_field') - ->will($this->returnValue(null)); + ->willReturn(null); $this->handler->downloadObject($this->object, 'file_field'); } diff --git a/Tests/Handler/UploadHandlerTest.php b/Tests/Handler/UploadHandlerTest.php index c0baddbc..3d81c88c 100644 --- a/Tests/Handler/UploadHandlerTest.php +++ b/Tests/Handler/UploadHandlerTest.php @@ -49,7 +49,7 @@ protected function setUp(): void ->expects($this->any()) ->method('fromField') ->with($this->object, self::FILE_FIELD) - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); } public function testUpload(): void @@ -60,7 +60,7 @@ public function testUpload(): void ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue($this->getUploadedFileMock())); + ->willReturn($this->getUploadedFileMock()); $this->storage ->expects($this->once()) @@ -135,13 +135,13 @@ public function testClean(): void ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue($this->getUploadedFileMock())); + ->willReturn($this->getUploadedFileMock()); $this->mapping ->expects($this->once()) ->method('getFileName') ->with($this->object) - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $this->storage ->expects($this->once()) @@ -157,7 +157,7 @@ public function testCleanSkipsEmptyObjects(): void ->expects($this->any()) ->method('getFileName') ->with($this->object) - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $this->dispatcher ->expects($this->never()) @@ -178,13 +178,13 @@ public function testRemove(): void ->expects($this->once()) ->method('getFileName') ->with($this->object) - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $this->mapping ->expects($this->once()) ->method('erase') ->with($this->object) - ->will($this->returnValue(null)); + ->willReturn(null); $this->storage ->expects($this->once()) diff --git a/Tests/Injector/FileInjectorTest.php b/Tests/Injector/FileInjectorTest.php index e5f92b34..7c0b4e68 100644 --- a/Tests/Injector/FileInjectorTest.php +++ b/Tests/Injector/FileInjectorTest.php @@ -41,7 +41,7 @@ public function testInjectsOneFile(): void $fileMapping ->expects($this->once()) ->method('getFilePropertyName') - ->will($this->returnValue('file_field')); + ->willReturn('file_field'); $fileMapping ->expects($this->once()) ->method('setFile'); @@ -50,7 +50,7 @@ public function testInjectsOneFile(): void ->expects($this->once()) ->method('resolvePath') ->with($obj, 'file_field') - ->will($this->returnValue('/uploadDir/file.txt')); + ->willReturn('/uploadDir/file.txt'); $inject = new FileInjector($this->storage); $inject->injectFile($obj, $fileMapping); @@ -71,7 +71,7 @@ public function testPropertyIsNullWhenFileNamePropertyIsNull(): void $this->storage ->expects($this->once()) ->method('resolvePath') - ->will($this->returnValue(null)); + ->willReturn(null); $inject = new FileInjector($this->storage); $inject->injectFile($obj, $fileMapping); diff --git a/Tests/Mapping/PropertyMappingFactoryTest.php b/Tests/Mapping/PropertyMappingFactoryTest.php index a99df3c0..011166cb 100644 --- a/Tests/Mapping/PropertyMappingFactoryTest.php +++ b/Tests/Mapping/PropertyMappingFactoryTest.php @@ -45,7 +45,7 @@ public function testFromObjectThrowsExceptionIfNotUploadable(): void $this->metadata ->expects($this->once()) ->method('isUploadable') - ->will($this->returnValue(false)); + ->willReturn(false); $factory = new PropertyMappingFactory($this->container, $this->metadata, []); $factory->fromObject(new DummyEntity()); @@ -71,19 +71,19 @@ public function testFromObjectOneField($object, $givenClassName, $expectedClassN ->expects($this->once()) ->method('isUploadable') ->with($expectedClassName) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with($expectedClassName) - ->will($this->returnValue([ + ->willReturn([ 'file' => [ 'mapping' => 'dummy_file', 'propertyName' => 'file', 'fileNameProperty' => 'fileName', ], - ])); + ]); $factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings); $mappings = $factory->fromObject($object, $givenClassName); @@ -135,18 +135,18 @@ public function testFromObjectOneFieldWithNoExplicitFilenameProperty(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class) - ->will($this->returnValue([ + ->willReturn([ 'file' => [ 'mapping' => 'dummy_file', 'propertyName' => 'file', ], - ])); + ]); $factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings); $mappings = $factory->fromObject($obj); @@ -181,13 +181,13 @@ public function testFromObjectWithExplicitMapping(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class) - ->will($this->returnValue([ + ->willReturn([ 'file' => [ 'mapping' => 'dummy_file', 'propertyName' => 'file', @@ -200,7 +200,7 @@ public function testFromObjectWithExplicitMapping(): void 'mapping' => 'other_mapping', 'propertyName' => 'document', ], - ])); + ]); $factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings); $mappings = $factory->fromObject(new DummyEntity(), null, 'other_mapping'); @@ -228,19 +228,19 @@ public function testThrowsExceptionOnInvalidMappingName(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class) - ->will($this->returnValue([ + ->willReturn([ 'file' => [ 'mapping' => 'dummy_file', 'propertyName' => 'file', 'fileNameProperty' => 'fileName', ], - ])); + ]); $factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings); $factory->fromObject(new DummyEntity()); @@ -263,18 +263,18 @@ public function testFromField($object, $className, $expectedClassName): void ->expects($this->once()) ->method('isUploadable') ->with($expectedClassName) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableField') ->with($expectedClassName, 'file') - ->will($this->returnValue([ + ->willReturn([ 'mapping' => 'dummy_file', 'propertyName' => 'file', 'fileNameProperty' => 'fileName', ] - )); + ); $factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings); $mapping = $factory->fromField($object, 'file', $className); @@ -305,13 +305,13 @@ public function testFromFieldReturnsNullOnInvalidFieldName(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableField') ->with(DummyEntity::class) - ->will($this->returnValue(null)); + ->willReturn(null); $factory = new PropertyMappingFactory($this->container, $this->metadata, []); $mapping = $factory->fromField(new DummyEntity(), 'oops'); @@ -332,16 +332,16 @@ public function testCustomFileNameProperty(): void ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableField') ->with(DummyEntity::class) - ->will($this->returnValue([ + ->willReturn([ 'mapping' => 'dummy_file', 'propertyName' => 'file', - ])); + ]); $factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings, '_suffix'); $mapping = $factory->fromField(new DummyEntity(), 'file'); @@ -364,28 +364,28 @@ public function testConfiguredNamersAreRetrievedFromContainer(): void $this->container ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['my.custom.namer', /* invalid behavior */ 1, $namer], ['my.custom.directory_namer', /* invalid behavior */ 1, $directoryNamer], - ])); + ]); $this->metadata ->expects($this->once()) ->method('isUploadable') ->with(DummyEntity::class) - ->will($this->returnValue(true)); + ->willReturn(true); $this->metadata ->expects($this->once()) ->method('getUploadableFields') ->with(DummyEntity::class) - ->will($this->returnValue([ + ->willReturn([ 'file' => [ 'mapping' => 'dummy_file', 'propertyName' => 'file', 'fileNameProperty' => 'fileName', ], - ])); + ]); $factory = new PropertyMappingFactory($this->container, $this->metadata, $mappings); $mappings = $factory->fromObject(new DummyEntity()); diff --git a/Tests/Mapping/PropertyMappingTest.php b/Tests/Mapping/PropertyMappingTest.php index 3f314e7b..0b649e4f 100644 --- a/Tests/Mapping/PropertyMappingTest.php +++ b/Tests/Mapping/PropertyMappingTest.php @@ -50,7 +50,7 @@ public function testDirectoryNamerIsCalled($dir, $expectedDir): void ->expects($this->once()) ->method('directoryName') ->with($object, $prop) - ->will($this->returnValue($dir)); + ->willReturn($dir); $prop->setDirectoryNamer($namer); @@ -106,7 +106,7 @@ public function testGetUploadNameWithNamer(): void ->expects($this->once()) ->method('name') ->with($object, $prop) - ->will($this->returnValue('123')); + ->willReturn('123'); $prop->setNamer($namer); @@ -122,7 +122,7 @@ public function testGetUploadNameWithoutNamer(): void $file ->expects($this->once()) ->method('getClientOriginalName') - ->will($this->returnValue('filename')); + ->willReturn('filename'); $object->setFile($file); diff --git a/Tests/Metadata/Driver/AnnotationDriverTest.php b/Tests/Metadata/Driver/AnnotationDriverTest.php index 4c4c6d1c..c83cf399 100644 --- a/Tests/Metadata/Driver/AnnotationDriverTest.php +++ b/Tests/Metadata/Driver/AnnotationDriverTest.php @@ -26,14 +26,14 @@ public function testReadUploadableAnnotation(): void $reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $reader ->expects($this->at(1)) ->method('getPropertyAnnotation') - ->will($this->returnValue(new UploadableField([ + ->willReturn(new UploadableField([ 'mapping' => 'dummy_file', 'fileNameProperty' => 'fileName', - ]))); + ])); $driver = new AnnotationDriver($reader); $metadata = $driver->loadMetadataForClass(new \ReflectionClass($entity)); @@ -61,7 +61,7 @@ public function testReadUploadableAnnotationReturnsNullWhenNonePresent(): void $reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue(null)); + ->willReturn(null); $reader ->expects($this->never()) ->method('getPropertyAnnotation'); @@ -80,25 +80,25 @@ public function testReadTwoUploadableFields(): void $reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $reader ->expects($this->at(1)) ->method('getPropertyAnnotation') - ->will($this->returnValue(new UploadableField([ + ->willReturn(new UploadableField([ 'mapping' => 'dummy_file', 'fileNameProperty' => 'attachmentName', - ]))); + ])); $reader ->expects($this->at(3)) ->method('getPropertyAnnotation') - ->will($this->returnValue(new UploadableField([ + ->willReturn(new UploadableField([ 'mapping' => 'dummy_image', 'fileNameProperty' => 'imageName', 'size' => 'sizeField', 'mimeType' => 'mimeTypeField', 'originalName' => 'originalNameField', 'dimensions' => null, - ]))); + ])); $driver = new AnnotationDriver($reader); $metadata = $driver->loadMetadataForClass(new \ReflectionClass($entity)); @@ -133,7 +133,7 @@ public function testReadNoUploadableFieldsWhenNoneExist(): void $reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $driver = new AnnotationDriver($reader); $metadata = $driver->loadMetadataForClass(new \ReflectionClass($entity)); @@ -149,19 +149,17 @@ public function testReadUploadableAnnotationInParentClass(): void $reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $reader ->expects($this->at(4)) ->method('getPropertyAnnotation') - ->will( - $this->returnValue( + ->willReturn( new UploadableField( [ 'mapping' => 'dummyFile_file', 'fileNameProperty' => 'fileName', ] ) - ) ); $driver = new AnnotationDriver($reader); @@ -193,7 +191,7 @@ public function testReadUploadableAnnotationReturnsNullWhenNonePresentInParentCl $reader ->expects($this->once()) ->method('getClassAnnotation') - ->will($this->returnValue(null)); + ->willReturn(null); $reader ->expects($this->never()) ->method('getPropertyAnnotation'); diff --git a/Tests/Metadata/Driver/FileDriverTestCase.php b/Tests/Metadata/Driver/FileDriverTestCase.php index ce6d86d6..52a2585a 100644 --- a/Tests/Metadata/Driver/FileDriverTestCase.php +++ b/Tests/Metadata/Driver/FileDriverTestCase.php @@ -80,7 +80,7 @@ protected function getFileLocatorMock(\ReflectionClass $class, $foundFile = null ->expects($this->once()) ->method('findFileForClass') ->with($this->equalTo($class), $this->equalTo($this->getExtension())) - ->will($this->returnValue($foundFile)); + ->willReturn($foundFile); return $fileLocator; } diff --git a/Tests/Metadata/Driver/YamlDriverTest.php b/Tests/Metadata/Driver/YamlDriverTest.php index 5a70da96..76a5f6ee 100644 --- a/Tests/Metadata/Driver/YamlDriverTest.php +++ b/Tests/Metadata/Driver/YamlDriverTest.php @@ -21,7 +21,7 @@ public function testInconsistentYamlFile(): void ->expects($this->once()) ->method('findFileForClass') ->with($this->equalTo($rClass), $this->equalTo('yml')) - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $driver = new TestableYamlDriver($fileLocator); diff --git a/Tests/Metadata/MetadataReaderTest.php b/Tests/Metadata/MetadataReaderTest.php index ed95ef21..7841a48c 100644 --- a/Tests/Metadata/MetadataReaderTest.php +++ b/Tests/Metadata/MetadataReaderTest.php @@ -24,7 +24,7 @@ public function testIsUploadable(): void ->expects($this->once()) ->method('getMetadataForClass') ->with('ClassName') - ->will($this->returnValue('something not null')); + ->willReturn('something not null'); $this->assertTrue($this->reader->isUploadable('ClassName')); } @@ -40,7 +40,7 @@ public function testIsUploadableWithGivenMapping(): void $this->factory ->method('getMetadataForClass') ->with('ClassName') - ->will($this->returnValue($metadata)); + ->willReturn($metadata); $this->assertTrue($this->reader->isUploadable('ClassName', 'joe')); $this->assertFalse($this->reader->isUploadable('ClassName', 'foo')); @@ -52,7 +52,7 @@ public function testIsUploadableForNotUploadable(): void ->expects($this->once()) ->method('getMetadataForClass') ->with('ClassName') - ->will($this->returnValue(null)); + ->willReturn(null); $this->assertFalse($this->reader->isUploadable('ClassName')); } @@ -82,7 +82,7 @@ public function testGetUploadableFields(): void ->expects($this->exactly(2)) ->method('getMetadataForClass') ->with('ClassName') - ->will($this->returnValue($metadata)); + ->willReturn($metadata); $this->assertSame($fields, $this->reader->getUploadableFields('ClassName')); @@ -106,7 +106,7 @@ public function testGetUploadableFieldsWithInheritance(): void ->expects($this->once()) ->method('getMetadataForClass') ->with('SubClassName') - ->will($this->returnValue($metadata)); + ->willReturn($metadata); $this->assertSame(['bar', 'baz', 'foo'], $this->reader->getUploadableFields('SubClassName')); } @@ -125,7 +125,7 @@ public function testGetUploadableField(array $fields, $expectedMetadata): void ->expects($this->once()) ->method('getMetadataForClass') ->with('ClassName') - ->will($this->returnValue($metadata)); + ->willReturn($metadata); $this->assertSame($expectedMetadata, $this->reader->getUploadableField('ClassName', 'field')); } diff --git a/Tests/Naming/Base64NamerTest.php b/Tests/Naming/Base64NamerTest.php index 5003d4b7..4cb230cc 100644 --- a/Tests/Naming/Base64NamerTest.php +++ b/Tests/Naming/Base64NamerTest.php @@ -39,7 +39,7 @@ public function testNameReturnsTheRightName(string $expectedFileName, string $ex $file->expects($this->once()) ->method('guessExtension') - ->will($this->returnValue($extension)); + ->willReturn($extension); $entity = new DummyEntity(); $entity->setFile($file); @@ -48,7 +48,7 @@ public function testNameReturnsTheRightName(string $expectedFileName, string $ex $mapping->expects($this->once()) ->method('getFile') ->with($entity) - ->will($this->returnValue($file)); + ->willReturn($file); $namer = new Base64Namer(); $namer->configure(['length' => $length]); diff --git a/Tests/Naming/HashNamerTest.php b/Tests/Naming/HashNamerTest.php index 73581900..49588cb2 100644 --- a/Tests/Naming/HashNamerTest.php +++ b/Tests/Naming/HashNamerTest.php @@ -40,7 +40,7 @@ public function testNameReturnsTheRightName($expectedFileName, $extension, $algo $file->expects($this->once()) ->method('guessExtension') - ->will($this->returnValue($extension)); + ->willReturn($extension); $entity = new DummyEntity(); $entity->setFile($file); @@ -49,7 +49,7 @@ public function testNameReturnsTheRightName($expectedFileName, $extension, $algo $mapping->expects($this->once()) ->method('getFile') ->with($entity) - ->will($this->returnValue($file)); + ->willReturn($file); $namer = new HashNamer(); $namer->configure(['algorithm' => $algorithm, 'length' => $length]); diff --git a/Tests/Naming/OrignameNamerTest.php b/Tests/Naming/OrignameNamerTest.php index e1b4c766..c6923f4f 100644 --- a/Tests/Naming/OrignameNamerTest.php +++ b/Tests/Naming/OrignameNamerTest.php @@ -31,7 +31,7 @@ public function testNameReturnsAnUniqueName($name, $pattern, $transliterate): vo $file ->expects($this->any()) ->method('getClientOriginalName') - ->will($this->returnValue($name)); + ->willReturn($name); $entity = new \DateTime(); @@ -41,7 +41,7 @@ public function testNameReturnsAnUniqueName($name, $pattern, $transliterate): vo $mapping->expects($this->once()) ->method('getFile') ->with($entity) - ->will($this->returnValue($file)); + ->willReturn($file); $namer = new OrignameNamer(); $namer->configure(['transliterate' => $transliterate]); diff --git a/Tests/Naming/PropertyNamerTest.php b/Tests/Naming/PropertyNamerTest.php index 50115e91..3b7a69eb 100644 --- a/Tests/Naming/PropertyNamerTest.php +++ b/Tests/Naming/PropertyNamerTest.php @@ -38,13 +38,13 @@ public function testNameReturnsTheRightName($originalFileName, $expectedFileName $file ->expects($this->any()) ->method('getClientOriginalName') - ->will($this->returnValue($originalFileName)); + ->willReturn($originalFileName); $mapping = $this->getPropertyMappingMock(); $mapping->expects($this->once()) ->method('getFile') ->with($entity) - ->will($this->returnValue($file)); + ->willReturn($file); $namer = new PropertyNamer(); $namer->configure(['property' => $propertyName, 'transliterate' => $transliterate]); diff --git a/Tests/Naming/SmartUniqidNamerTest.php b/Tests/Naming/SmartUniqidNamerTest.php index 70688c25..457bab5d 100644 --- a/Tests/Naming/SmartUniqidNamerTest.php +++ b/Tests/Naming/SmartUniqidNamerTest.php @@ -28,7 +28,7 @@ public function testNameReturnsAnUniqueName(string $originalName, string $patter $file ->expects($this->once()) ->method('getClientOriginalName') - ->will($this->returnValue($originalName)) + ->willReturn($originalName) ; $entity = new \StdClass(); @@ -40,7 +40,7 @@ public function testNameReturnsAnUniqueName(string $originalName, string $patter $mapping->expects($this->once()) ->method('getFile') ->with($entity) - ->will($this->returnValue($file)) + ->willReturn($file) ; $namer = new SmartUniqueNamer(); diff --git a/Tests/Naming/SubdirDirectoryNamerTest.php b/Tests/Naming/SubdirDirectoryNamerTest.php index 5669b1c8..6bd3769c 100644 --- a/Tests/Naming/SubdirDirectoryNamerTest.php +++ b/Tests/Naming/SubdirDirectoryNamerTest.php @@ -34,7 +34,7 @@ public function testNameReturnsTheRightName($fileName, $expectedFileName, $chars $mapping->expects($this->once()) ->method('getFileName') ->with($entity) - ->will($this->returnValue($fileName)); + ->willReturn($fileName); $namer = new SubdirDirectoryNamer(); $namer->configure(['chars_per_dir' => $charsPerDir, 'dirs' => $dirs]); diff --git a/Tests/Naming/UniqidNamerTest.php b/Tests/Naming/UniqidNamerTest.php index cbeec6e8..9f06da1e 100644 --- a/Tests/Naming/UniqidNamerTest.php +++ b/Tests/Naming/UniqidNamerTest.php @@ -33,11 +33,11 @@ public function testNameReturnsAnUniqueName($originalName, $guessedExtension, $p $file ->expects($this->any()) ->method('getClientOriginalName') - ->will($this->returnValue($originalName)); + ->willReturn($originalName); $file ->expects($this->any()) ->method('guessExtension') - ->will($this->returnValue($guessedExtension)); + ->willReturn($guessedExtension); $entity = new \DateTime(); @@ -47,7 +47,7 @@ public function testNameReturnsAnUniqueName($originalName, $guessedExtension, $p $mapping->expects($this->once()) ->method('getFile') ->with($entity) - ->will($this->returnValue($file)); + ->willReturn($file); $namer = new UniqidNamer(); diff --git a/Tests/Storage/FileSystemStorageTest.php b/Tests/Storage/FileSystemStorageTest.php index 47357eb8..3f4fdeb4 100644 --- a/Tests/Storage/FileSystemStorageTest.php +++ b/Tests/Storage/FileSystemStorageTest.php @@ -28,7 +28,7 @@ public function testRemoveSkipsEmptyFilenameProperties($propertyValue): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue($propertyValue)); + ->willReturn($propertyValue); $this->mapping ->expects($this->never()) @@ -45,12 +45,12 @@ public function testRemoveSkipsNonExistingFile(): void $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue($this->getValidUploadDir())); + ->willReturn($this->getValidUploadDir()); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('foo.txt')); + ->willReturn('foo.txt'); $this->storage->remove($this->object, $this->mapping); } @@ -60,12 +60,12 @@ public function testRemove(): void $this->mapping ->expects($this->once()) ->method('getUploadDestination') - ->will($this->returnValue($this->getValidUploadDir())); + ->willReturn($this->getValidUploadDir()); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $this->storage->remove($this->object, $this->mapping); $this->assertFalse($this->root->hasChild('uploads'.\DIRECTORY_SEPARATOR.'test.txt')); @@ -79,23 +79,23 @@ public function testResolvePath(): void $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue('')); + ->willReturn(''); $this->mapping ->expects($this->once()) ->method('getUploadDestination') - ->will($this->returnValue('/tmp')); + ->willReturn('/tmp'); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $path = $this->storage->resolvePath($this->object, 'file_field'); @@ -110,18 +110,18 @@ public function testResolveRelativePath(): void $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue('upload_dir')); + ->willReturn('upload_dir'); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $path = $this->storage->resolvePath($this->object, 'file_field', null, true); @@ -133,13 +133,13 @@ public function testResolveUriReturnsNullIfNoFile(): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue(null)); + ->willReturn(null); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $this->assertNull($this->storage->resolveUri($this->object, 'file_field')); } @@ -154,23 +154,23 @@ public function testResolveUri($uploadDir, $uri): void $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue($uploadDir)); + ->willReturn($uploadDir); $this->mapping ->expects($this->once()) ->method('getUriPrefix') - ->will($this->returnValue('/uploads')); + ->willReturn('/uploads'); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $path = $this->storage->resolveUri($this->object, 'file_field'); @@ -182,23 +182,23 @@ public function testResolveStream(): void $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue('')); + ->willReturn(''); $this->mapping ->expects($this->once()) ->method('getUploadDestination') - ->will($this->returnValue($this->root->url().'/uploads')); + ->willReturn($this->root->url().'/uploads'); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $stream = $this->storage->resolveStream($this->object, 'file_field', null); @@ -238,30 +238,30 @@ public function testUploadedFileIsCorrectlyMoved($uploadDir, $dir, $expectedDir) $file ->expects($this->any()) ->method('getClientOriginalName') - ->will($this->returnValue('filename.txt')); + ->willReturn('filename.txt'); $this->mapping ->expects($this->once()) ->method('getFile') ->with($this->object) - ->will($this->returnValue($file)); + ->willReturn($file); $this->mapping ->expects($this->once()) ->method('getUploadDestination') - ->will($this->returnValue($uploadDir)); + ->willReturn($uploadDir); $this->mapping ->expects($this->once()) ->method('getUploadName') ->with($this->object) - ->will($this->returnValue('filename.txt')); + ->willReturn('filename.txt'); $this->mapping ->expects($this->once()) ->method('getUploadDir') ->with($this->object) - ->will($this->returnValue($dir)); + ->willReturn($dir); $file ->expects($this->once()) diff --git a/Tests/Storage/FlysystemStorageTest.php b/Tests/Storage/FlysystemStorageTest.php index 34781297..25c93538 100644 --- a/Tests/Storage/FlysystemStorageTest.php +++ b/Tests/Storage/FlysystemStorageTest.php @@ -47,14 +47,14 @@ protected function setUp(): void ->expects($this->any()) ->method('getFilesystem') ->with(self::FS_KEY) - ->will($this->returnValue($this->filesystem)); + ->willReturn($this->filesystem); parent::setUp(); $this->mapping ->expects($this->any()) ->method('getUploadDestination') - ->will($this->returnValue(self::FS_KEY)); + ->willReturn(self::FS_KEY); } public function testUpload(): void @@ -64,23 +64,23 @@ public function testUpload(): void $file ->expects($this->once()) ->method('getRealPath') - ->will($this->returnValue($this->root->url().\DIRECTORY_SEPARATOR.'uploads'.\DIRECTORY_SEPARATOR.'test.txt')); + ->willReturn($this->root->url().\DIRECTORY_SEPARATOR.'uploads'.\DIRECTORY_SEPARATOR.'test.txt'); $file ->expects($this->once()) ->method('getClientOriginalName') - ->will($this->returnValue('originalName.txt')); + ->willReturn('originalName.txt'); $this->mapping ->expects($this->once()) ->method('getFile') - ->will($this->returnValue($file)); + ->willReturn($file); $this->mapping ->expects($this->once()) ->method('getUploadName') ->with($this->object) - ->will($this->returnValue('originalName.txt')); + ->willReturn('originalName.txt'); $this->filesystem ->expects($this->once()) @@ -104,7 +104,7 @@ public function testRemove(): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $this->storage->remove($this->object, $this->mapping); } @@ -120,7 +120,7 @@ public function testRemoveOnNonExistentFile(): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('not_found.txt')); + ->willReturn('not_found.txt'); $this->storage->remove($this->object, $this->mapping); } @@ -133,28 +133,28 @@ public function testResolvePath(?string $uploadDir, string $expectedPath, bool $ $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue($uploadDir)); + ->willReturn($uploadDir); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $this->filesystem ->expects($this->any()) ->method('get') - ->will($this->returnValue( + ->willReturn( new File( $this->filesystem, $uploadDir ? '/absolute/'.$uploadDir.'/file.txt' : '/absolute/file.txt' ) - )); + ); $path = $this->storage->resolvePath($this->object, 'file_field', null, $relative); diff --git a/Tests/Storage/GaufretteStorageTest.php b/Tests/Storage/GaufretteStorageTest.php index 259191c5..0f9bb116 100644 --- a/Tests/Storage/GaufretteStorageTest.php +++ b/Tests/Storage/GaufretteStorageTest.php @@ -43,7 +43,7 @@ public function testRemoveSkipsNullFileNameProperty(): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue(null)); + ->willReturn(null); $this->mapping ->expects($this->never()) @@ -61,23 +61,23 @@ public function testResolvePath($protocol, $filesystemKey, $uploadDir, $expected { $this->mapping ->method('getUploadDestination') - ->will($this->returnValue($filesystemKey)); + ->willReturn($filesystemKey); $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue($uploadDir)); + ->willReturn($uploadDir); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $this->storage = new GaufretteStorage($this->factory, $this->filesystemMap, $protocol); $path = $this->storage->resolvePath($this->object, 'file_field', null, $relative); @@ -90,18 +90,18 @@ public function testResolveUri(): void $this->mapping ->expects($this->once()) ->method('getUriPrefix') - ->will($this->returnValue('/uploads')); + ->willReturn('/uploads'); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $this->storage = new GaufretteStorage($this->factory, $this->filesystemMap, 'gaufrette'); $path = $this->storage->resolveUri($this->object, 'file_field'); @@ -114,13 +114,13 @@ public function testResolveUriFileNull(): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('')); + ->willReturn(''); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $this->storage = new GaufretteStorage($this->factory, $this->filesystemMap, 'gaufrette'); $path = $this->storage->resolveUri($this->object, 'file_field'); @@ -148,11 +148,11 @@ public function testThatRemoveMethodDoesDeleteFile(): void $this->mapping ->expects($this->any()) ->method('getUploadDestination') - ->will($this->returnValue('filesystemKey')); + ->willReturn('filesystemKey'); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $filesystem = $this->getFilesystemMock(); $filesystem @@ -165,7 +165,7 @@ public function testThatRemoveMethodDoesDeleteFile(): void ->expects($this->once()) ->method('get') ->with('filesystemKey') - ->will($this->returnValue($filesystem)); + ->willReturn($filesystem); $this->storage->remove($this->object, $this->mapping); } @@ -178,11 +178,11 @@ public function testRemoveNotFoundFile(): void $this->mapping ->expects($this->any()) ->method('getUploadDestination') - ->will($this->returnValue('filesystemKey')); + ->willReturn('filesystemKey'); $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue('file.txt')); + ->willReturn('file.txt'); $filesystem = $this->getFilesystemMock(); $filesystem @@ -196,7 +196,7 @@ public function testRemoveNotFoundFile(): void ->expects($this->once()) ->method('get') ->with('filesystemKey') - ->will($this->returnValue($filesystem)); + ->willReturn($filesystem); $this->storage->remove($this->object, $this->mapping); } @@ -210,34 +210,34 @@ public function testUploadSetsMetadataWhenUsingMetadataSupporterAdapter(): void $file ->expects($this->once()) ->method('getClientOriginalName') - ->will($this->returnValue('filename')); + ->willReturn('filename'); $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->getValidUploadDir().\DIRECTORY_SEPARATOR.'test.txt')); + ->willReturn($this->getValidUploadDir().\DIRECTORY_SEPARATOR.'test.txt'); $this->mapping ->expects($this->once()) ->method('getFile') - ->will($this->returnValue($file)); + ->willReturn($file); $this->mapping ->expects($this->once()) ->method('getUploadName') ->with($this->object) - ->will($this->returnValue('filename')); + ->willReturn('filename'); $this->mapping ->expects($this->once()) ->method('getUploadDestination') - ->will($this->returnValue('filesystemKey')); + ->willReturn('filesystemKey'); $this->filesystemMap ->expects($this->once()) ->method('get') ->with('filesystemKey') - ->will($this->returnValue($filesystem)); + ->willReturn($filesystem); $adapter ->expects($this->once()) @@ -246,7 +246,7 @@ public function testUploadSetsMetadataWhenUsingMetadataSupporterAdapter(): void $filesystem ->expects($this->any()) ->method('getAdapter') - ->will($this->returnValue($adapter)); + ->willReturn($adapter); $filesystem ->expects($this->once()) @@ -265,44 +265,44 @@ public function testUploadDoesNotSetMetadataWhenUsingNonMetadataSupporterAdapter $file ->expects($this->once()) ->method('getClientOriginalName') - ->will($this->returnValue('filename')); + ->willReturn('filename'); $file ->expects($this->once()) ->method('getPathname') - ->will($this->returnValue($this->getValidUploadDir().\DIRECTORY_SEPARATOR.'test.txt')); + ->willReturn($this->getValidUploadDir().\DIRECTORY_SEPARATOR.'test.txt'); $this->mapping ->expects($this->once()) ->method('getFile') - ->will($this->returnValue($file)); + ->willReturn($file); $this->mapping ->expects($this->once()) ->method('getUploadName') ->with($this->object) - ->will($this->returnValue('filename')); + ->willReturn('filename'); $this->mapping ->expects($this->once()) ->method('getUploadDir') - ->will($this->returnValue('')); + ->willReturn(''); $this->mapping ->expects($this->once()) ->method('getUploadDestination') - ->will($this->returnValue('filesystemKey')); + ->willReturn('filesystemKey'); $this->filesystemMap ->expects($this->once()) ->method('get') ->with('filesystemKey') - ->will($this->returnValue($filesystem)); + ->willReturn($filesystem); $filesystem ->expects($this->any()) ->method('getAdapter') - ->will($this->returnValue($adapter)); + ->willReturn($adapter); $filesystem ->expects($this->once()) diff --git a/Tests/Storage/StorageTestCase.php b/Tests/Storage/StorageTestCase.php index d4ef140b..62617ba5 100644 --- a/Tests/Storage/StorageTestCase.php +++ b/Tests/Storage/StorageTestCase.php @@ -63,7 +63,7 @@ protected function setUp(): void ->expects($this->any()) ->method('fromObject') ->with($this->object) - ->will($this->returnValue([$this->mapping])); + ->willReturn([$this->mapping]); // and initialize the virtual filesystem $this->root = vfsStream::setup('vich_uploader_bundle', null, [ @@ -89,13 +89,13 @@ public function testResolvePathWithEmptyFile($filename): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue($filename)); + ->willReturn($filename); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $this->assertNull($this->storage->resolvePath($this->object, 'file_field')); } @@ -108,13 +108,13 @@ public function testResolveUriWithEmptyFile($filename): void $this->mapping ->expects($this->once()) ->method('getFileName') - ->will($this->returnValue($filename)); + ->willReturn($filename); $this->factory ->expects($this->once()) ->method('fromField') ->with($this->object, 'file_field') - ->will($this->returnValue($this->mapping)); + ->willReturn($this->mapping); $this->assertNull($this->storage->resolvePath($this->object, 'file_field')); }