diff --git a/.travis.yml b/.travis.yml index 84e6fff8d..1da5be0e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ env: - SYMFONY_DEPRECATIONS_HELPER="max[self]=0" - PHPUNIT_FLAGS="-v" - PHPUNIT_ENABLED="true" - - SYMFONY_PHPUNIT_VERSION="6.5" + - SYMFONY_PHPUNIT_VERSION="7.5" - COVERALLS_ENABLED="false" - STABILITY=stable diff --git a/Tests/AbstractTest.php b/Tests/AbstractTest.php index c017ef21c..8a082c475 100644 --- a/Tests/AbstractTest.php +++ b/Tests/AbstractTest.php @@ -25,6 +25,7 @@ use Liip\ImagineBundle\Imagine\Filter\FilterManager; use Liip\ImagineBundle\Imagine\Filter\PostProcessor\PostProcessorInterface; use Liip\ImagineBundle\Service\FilterService; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -77,7 +78,7 @@ protected function tearDown() /** * @return string[] */ - public function invalidPathProvider() + public function invalidPathProvider(): array { return [ [$this->fixturesPath.'/assets/../../foobar.png'], @@ -86,10 +87,7 @@ public function invalidPathProvider() ]; } - /** - * @return FilterConfiguration - */ - protected function createFilterConfiguration() + protected function createFilterConfiguration(): FilterConfiguration { $config = new FilterConfiguration(); $config->set('thumbnail', [ @@ -101,7 +99,7 @@ protected function createFilterConfiguration() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|CacheManager + * @return MockObject|CacheManager */ protected function createCacheManagerMock() { @@ -117,7 +115,7 @@ protected function createCacheManagerMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|FilterConfiguration + * @return MockObject|FilterConfiguration */ protected function createFilterConfigurationMock() { @@ -125,7 +123,7 @@ protected function createFilterConfigurationMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|SignerInterface + * @return MockObject|SignerInterface */ protected function createSignerInterfaceMock() { @@ -133,7 +131,7 @@ protected function createSignerInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|RouterInterface + * @return MockObject|RouterInterface */ protected function createRouterInterfaceMock() { @@ -141,7 +139,7 @@ protected function createRouterInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|ResolverInterface + * @return MockObject|ResolverInterface */ protected function createCacheResolverInterfaceMock() { @@ -149,7 +147,7 @@ protected function createCacheResolverInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|EventDispatcherInterface + * @return MockObject|EventDispatcherInterface */ protected function createEventDispatcherInterfaceMock() { @@ -157,7 +155,7 @@ protected function createEventDispatcherInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|ImageInterface + * @return MockObject|ImageInterface */ protected function getImageInterfaceMock() { @@ -165,7 +163,7 @@ protected function getImageInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|MetadataBag + * @return MockObject|MetadataBag */ protected function getMetadataBagMock() { @@ -173,7 +171,7 @@ protected function getMetadataBagMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|ImagineInterface + * @return MockObject|ImagineInterface */ protected function createImagineInterfaceMock() { @@ -181,7 +179,7 @@ protected function createImagineInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|LoggerInterface + * @return MockObject|LoggerInterface */ protected function createLoggerInterfaceMock() { @@ -189,7 +187,7 @@ protected function createLoggerInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|LoaderInterface + * @return MockObject|LoaderInterface */ protected function createBinaryLoaderInterfaceMock() { @@ -197,7 +195,7 @@ protected function createBinaryLoaderInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|MimeTypeGuesserInterface + * @return MockObject|MimeTypeGuesserInterface */ protected function createMimeTypeGuesserInterfaceMock() { @@ -205,7 +203,7 @@ protected function createMimeTypeGuesserInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|ExtensionGuesserInterface + * @return MockObject|ExtensionGuesserInterface */ protected function createExtensionGuesserInterfaceMock() { @@ -217,7 +215,7 @@ protected function createExtensionGuesserInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|PostProcessorInterface + * @return MockObject|PostProcessorInterface */ protected function createPostProcessorInterfaceMock() { @@ -225,7 +223,7 @@ protected function createPostProcessorInterfaceMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|FilterManager + * @return MockObject|FilterManager */ protected function createFilterManagerMock() { @@ -233,15 +231,15 @@ protected function createFilterManagerMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|FilterService + * @return MockObject|FilterService */ protected function createFilterServiceMock() { - return $this->createObjectMock('\Liip\ImagineBundle\Service\FilterService'); + return $this->createObjectMock(FilterService::class); } /** - * @return \PHPUnit_Framework_MockObject_MockObject|DataManager + * @return MockObject|DataManager */ protected function createDataManagerMock() { @@ -254,14 +252,10 @@ protected function createControllerConfigInstance(int $redirectResponseCode = nu } /** - * @param string $object * @param string[] $methods - * @param bool $constructorInvoke * @param mixed[] $constructorParams - * - * @return \PHPUnit_Framework_MockObject_MockObject */ - protected function createObjectMock($object, array $methods = [], $constructorInvoke = false, array $constructorParams = []) + protected function createObjectMock(string $object, array $methods = [], bool $constructorInvoke = false, array $constructorParams = []): MockObject { $builder = $this->getMockBuilder($object); @@ -284,11 +278,8 @@ protected function createObjectMock($object, array $methods = [], $constructorIn /** * @param object $object - * @param string $name - * - * @return \ReflectionMethod */ - protected function getVisibilityRestrictedMethod($object, $name) + protected function getVisibilityRestrictedMethod($object, string $name): \ReflectionMethod { $r = new \ReflectionObject($object); diff --git a/Tests/Async/CacheResolvedTest.php b/Tests/Async/CacheResolvedTest.php index 7c79b029b..fbd6ef4fa 100644 --- a/Tests/Async/CacheResolvedTest.php +++ b/Tests/Async/CacheResolvedTest.php @@ -27,7 +27,7 @@ public static function setUpBeforeClass() } } - public function testCouldBeJsonSerialized() + public function testCouldBeJsonSerialized(): void { $message = new CacheResolved('thePath', [ 'fooFilter' => 'http://example.com/fooFilter/thePath', @@ -40,11 +40,10 @@ public function testCouldBeJsonSerialized() ); } - public function testCouldBeJsonDeSerialized() + public function testCouldBeJsonDeSerialized(): void { $message = CacheResolved::jsonDeserialize('{"path":"thePath","uris":{"fooFilter":"http:\/\/example.com\/fooFilter\/thePath","barFilter":"http:\/\/example.com\/barFilter\/thePath"}}'); - $this->assertInstanceOf('Liip\ImagineBundle\Async\CacheResolved', $message); $this->assertSame('thePath', $message->getPath()); $this->assertSame([ 'fooFilter' => 'http://example.com/fooFilter/thePath', diff --git a/Tests/Async/ResolveCacheProcessorTest.php b/Tests/Async/ResolveCacheProcessorTest.php index 7ebc8b9a4..6c26a86d3 100644 --- a/Tests/Async/ResolveCacheProcessorTest.php +++ b/Tests/Async/ResolveCacheProcessorTest.php @@ -28,6 +28,7 @@ use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Service\FilterService; use Liip\ImagineBundle\Tests\AbstractTest; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers \Liip\ImagineBundle\Async\ResolveCacheProcessor @@ -41,32 +42,32 @@ public static function setUpBeforeClass() } } - public function testShouldImplementProcessorInterface() + public function testShouldImplementProcessorInterface(): void { $rc = new \ReflectionClass(ResolveCacheProcessor::class); $this->assertTrue($rc->implementsInterface(Processor::class)); } - public function testShouldImplementCommandSubscriberInterface() + public function testShouldImplementCommandSubscriberInterface(): void { $rc = new \ReflectionClass(ResolveCacheProcessor::class); $this->assertTrue($rc->implementsInterface(CommandSubscriberInterface::class)); } - public function testShouldImplementQueueSubscriberInterface() + public function testShouldImplementQueueSubscriberInterface(): void { $rc = new \ReflectionClass(ResolveCacheProcessor::class); $this->assertTrue($rc->implementsInterface(QueueSubscriberInterface::class)); } - public function testShouldSubscribeToExpectedCommand() + public function testShouldSubscribeToExpectedCommand(): void { $command = ResolveCacheProcessor::getSubscribedCommand(); - $this->assertInternalType('array', $command); + $this->assertIsArray($command); $this->assertSame([ 'command' => Commands::RESOLVE_CACHE, 'queue' => Commands::RESOLVE_CACHE, @@ -75,15 +76,15 @@ public function testShouldSubscribeToExpectedCommand() ], $command); } - public function testShouldSubscribeToExpectedQueue() + public function testShouldSubscribeToExpectedQueue(): void { $queues = ResolveCacheProcessor::getSubscribedQueues(); - $this->assertInternalType('array', $queues); + $this->assertIsArray($queues); $this->assertSame(['liip_imagine_resolve_cache'], $queues); } - public function testCouldBeConstructedWithExpectedArguments() + public function testCouldBeConstructedWithExpectedArguments(): void { $processor = new ResolveCacheProcessor( $this->createFilterManagerMock(), @@ -94,7 +95,7 @@ public function testCouldBeConstructedWithExpectedArguments() $this->assertInstanceOf(ResolveCacheProcessor::class, $processor); } - public function testShouldRejectMessagesWithInvalidJsonBody() + public function testShouldRejectMessagesWithInvalidJsonBody(): void { $processor = new ResolveCacheProcessor( $this->createFilterManagerMock(), @@ -107,12 +108,12 @@ public function testShouldRejectMessagesWithInvalidJsonBody() $result = $processor->process($message, new NullContext()); - $this->assertInstanceOf('Enqueue\Consumption\Result', $result); + $this->assertInstanceOf(Result::class, $result); $this->assertSame(Result::REJECT, $result->getStatus()); $this->assertStringStartsWith('The malformed json given.', $result->getReason()); } - public function testShouldSendFailedReplyOnException() + public function testShouldSendFailedReplyOnException(): void { $processor = new ResolveCacheProcessor( $this->createFilterManagerMock(), @@ -136,7 +137,7 @@ public function testShouldSendFailedReplyOnException() ); } - public function testShouldRejectMessagesWithoutPass() + public function testShouldRejectMessagesWithoutPass(): void { $processor = new ResolveCacheProcessor( $this->createFilterManagerMock(), @@ -149,12 +150,12 @@ public function testShouldRejectMessagesWithoutPass() $result = $processor->process($message, new NullContext()); - $this->assertInstanceOf('Enqueue\Consumption\Result', $result); + $this->assertInstanceOf(Result::class, $result); $this->assertSame(Result::REJECT, (string) $result); $this->assertSame('The message does not contain "path" but it is required.', $result->getReason()); } - public function testShouldCreateFilteredImage() + public function testShouldCreateFilteredImage(): void { $filterName = 'fooFilter'; $imagePath = 'theImagePath'; @@ -187,7 +188,7 @@ public function testShouldCreateFilteredImage() $this->assertSame(Result::ACK, (string) $result); } - public function testShouldCreateOneImagePerFilter() + public function testShouldCreateOneImagePerFilter(): void { $filterName1 = 'fooFilter'; $filterName2 = 'barFilter'; @@ -225,7 +226,7 @@ public function testShouldCreateOneImagePerFilter() $this->assertSame(Result::ACK, (string) $result); } - public function testShouldOnlyCreateImageForRequestedFilter() + public function testShouldOnlyCreateImageForRequestedFilter(): void { $relevantFilter = 'fooFilter'; $imagePath = 'theImagePath'; @@ -255,7 +256,7 @@ public function testShouldOnlyCreateImageForRequestedFilter() $this->assertSame(Result::ACK, (string) $result); } - public function testShouldCreateOneImagePerRequestedFilter() + public function testShouldCreateOneImagePerRequestedFilter(): void { $relevantFilter1 = 'fooFilter'; $relevantFilter2 = 'fooFilter'; @@ -289,7 +290,7 @@ public function testShouldCreateOneImagePerRequestedFilter() $this->assertSame(Result::ACK, (string) $result); } - public function testShouldBurstCacheWhenResolvingForced() + public function testShouldBurstCacheWhenResolvingForced(): void { $filterName = 'fooFilter'; $imagePath = 'theImagePath'; @@ -319,11 +320,11 @@ public function testShouldBurstCacheWhenResolvingForced() $result = $processor->process($message, new NullContext()); - $this->assertInstanceOf('Enqueue\Consumption\Result', $result); + $this->assertInstanceOf(Result::class, $result); $this->assertSame(Result::ACK, (string) $result); } - public function testShouldNotBurstCacheWhenResolvingNotForced() + public function testShouldNotBurstCacheWhenResolvingNotForced(): void { $filterManagerMock = $this->createFilterManagerMock(); $filterManagerMock @@ -349,11 +350,11 @@ public function testShouldNotBurstCacheWhenResolvingNotForced() $result = $processor->process($message, new NullContext()); - $this->assertInstanceOf('Enqueue\Consumption\Result', $result); + $this->assertInstanceOf(Result::class, $result); $this->assertSame(Result::ACK, (string) $result); } - public function testShouldSendMessageOnSuccessResolve() + public function testShouldSendMessageOnSuccessResolve(): void { $filterManagerMock = $this->createFilterManagerMock(); $filterManagerMock @@ -377,7 +378,7 @@ public function testShouldSendMessageOnSuccessResolve() $producerMock ->expects($this->once()) ->method('sendEvent') - ->with(Topics::CACHE_RESOLVED, $this->isInstanceOf('Liip\ImagineBundle\Async\CacheResolved')) + ->with(Topics::CACHE_RESOLVED, $this->isInstanceOf(CacheResolved::class)) ->willReturnCallback(function ($topic, CacheResolved $message) { $this->assertSame('theImagePath', $message->getPath()); $this->assertSame([ @@ -398,11 +399,11 @@ public function testShouldSendMessageOnSuccessResolve() $result = $processor->process($message, new NullContext()); - $this->assertInstanceOf('Enqueue\Consumption\Result', $result); + $this->assertInstanceOf(Result::class, $result); $this->assertSame(Result::ACK, (string) $result); } - public function testShouldReturnReplyOnSuccessResolve() + public function testShouldReturnReplyOnSuccessResolve(): void { $filterManagerMock = $this->createFilterManagerMock(); $filterManagerMock @@ -472,17 +473,14 @@ public function testShouldReturnReplyOnSuccessResolve() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|ProducerInterface + * @return MockObject|ProducerInterface */ private function createProducerMock() { return $this->createMock(ProducerInterface::class); } - /** - * @return Binary - */ - private function createDummyBinary() + private function createDummyBinary(): Binary { return new Binary('theContent', 'image/png', 'png'); } diff --git a/Tests/Async/ResolveCacheTest.php b/Tests/Async/ResolveCacheTest.php index e93456586..19aeffb77 100644 --- a/Tests/Async/ResolveCacheTest.php +++ b/Tests/Async/ResolveCacheTest.php @@ -27,68 +27,64 @@ public static function setUpBeforeClass() } } - public function testCouldBeJsonSerializedWithoutFiltersAndForce() + public function testCouldBeJsonSerializedWithoutFiltersAndForce(): void { $message = new ResolveCache('thePath'); $this->assertSame('{"path":"thePath","filters":null,"force":false}', json_encode($message)); } - public function testCouldBeJsonSerializedWithFilters() + public function testCouldBeJsonSerializedWithFilters(): void { $message = new ResolveCache('thePath', ['fooFilter', 'barFilter']); $this->assertSame('{"path":"thePath","filters":["fooFilter","barFilter"],"force":false}', json_encode($message)); } - public function testCouldBeJsonSerializedWithFiltersAndForce() + public function testCouldBeJsonSerializedWithFiltersAndForce(): void { $message = new ResolveCache('thePath', ['fooFilter', 'barFilter'], true); $this->assertSame('{"path":"thePath","filters":["fooFilter","barFilter"],"force":true}', json_encode($message)); } - public function testCouldBeJsonDeSerializedWithoutFiltersAndForce() + public function testCouldBeJsonDeSerializedWithoutFiltersAndForce(): void { $message = ResolveCache::jsonDeserialize('{"path":"thePath","filters":null,"force":false}'); - $this->assertInstanceOf('Liip\ImagineBundle\Async\ResolveCache', $message); $this->assertSame('thePath', $message->getPath()); $this->assertNull($message->getFilters()); $this->assertFalse($message->isForce()); } - public function testCouldBeJsonDeSerializedWithFilters() + public function testCouldBeJsonDeSerializedWithFilters(): void { $message = ResolveCache::jsonDeserialize('{"path":"thePath","filters":["fooFilter","barFilter"],"force":false}'); - $this->assertInstanceOf('Liip\ImagineBundle\Async\ResolveCache', $message); $this->assertSame('thePath', $message->getPath()); $this->assertSame(['fooFilter', 'barFilter'], $message->getFilters()); $this->assertFalse($message->isForce()); } - public function testCouldBeJsonDeSerializedWithFiltersAndForce() + public function testCouldBeJsonDeSerializedWithFiltersAndForce(): void { $message = ResolveCache::jsonDeserialize('{"path":"thePath","filters":["fooFilter","barFilter"],"force":true}'); - $this->assertInstanceOf('Liip\ImagineBundle\Async\ResolveCache', $message); $this->assertSame('thePath', $message->getPath()); $this->assertSame(['fooFilter', 'barFilter'], $message->getFilters()); $this->assertTrue($message->isForce()); } - public function testCouldBeJsonDeSerializedWithOnlyPath() + public function testCouldBeJsonDeSerializedWithOnlyPath(): void { $message = ResolveCache::jsonDeserialize('{"path":"thePath"}'); - $this->assertInstanceOf('Liip\ImagineBundle\Async\ResolveCache', $message); $this->assertSame('thePath', $message->getPath()); $this->assertNull($message->getFilters()); $this->assertFalse($message->isForce()); } - public function testThrowIfMessageMissingPathOnJsonDeserialize() + public function testThrowIfMessageMissingPathOnJsonDeserialize(): void { $this->expectException(\Liip\ImagineBundle\Exception\LogicException::class); $this->expectExceptionMessage('The message does not contain "path" but it is required.'); @@ -96,7 +92,7 @@ public function testThrowIfMessageMissingPathOnJsonDeserialize() ResolveCache::jsonDeserialize('{}'); } - public function testThrowIfMessageContainsNotSupportedFilters() + public function testThrowIfMessageContainsNotSupportedFilters(): void { $this->expectException(\Liip\ImagineBundle\Exception\LogicException::class); $this->expectExceptionMessage('The message filters could be either null or array.'); diff --git a/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php b/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php index 5ffee29e7..956f34e23 100644 --- a/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php +++ b/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php @@ -14,6 +14,7 @@ use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectRepository; use Liip\ImagineBundle\Binary\Loader\AbstractDoctrineLoader; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** @@ -22,12 +23,12 @@ class AbstractDoctrineLoaderTest extends TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject|ObjectRepository + * @var MockObject|ObjectRepository */ private $om; /** - * @var \PHPUnit_Framework_MockObject_MockObject|AbstractDoctrineLoader + * @var MockObject|AbstractDoctrineLoader */ private $loader; @@ -47,7 +48,7 @@ public function setUp() ->getMockForAbstractClass(); } - public function testFindWithValidObjectFirstHit() + public function testFindWithValidObjectFirstHit(): void { $image = new \stdClass(); @@ -72,7 +73,7 @@ public function testFindWithValidObjectFirstHit() $this->assertSame('foo', $this->loader->find('/foo/bar')); } - public function testFindWithValidObjectSecondHit() + public function testFindWithValidObjectSecondHit(): void { $image = new \stdClass(); @@ -101,7 +102,7 @@ public function testFindWithValidObjectSecondHit() $this->assertSame('foo', $this->loader->find('/foo/bar.png')); } - public function testFindWithInvalidObject() + public function testFindWithInvalidObject(): void { $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); diff --git a/Tests/Binary/Loader/ChainLoaderTest.php b/Tests/Binary/Loader/ChainLoaderTest.php index 57307069b..2ce0b857b 100644 --- a/Tests/Binary/Loader/ChainLoaderTest.php +++ b/Tests/Binary/Loader/ChainLoaderTest.php @@ -21,8 +21,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\Mime\MimeTypes; use Symfony\Component\Mime\MimeTypeGuesserInterface; +use Symfony\Component\Mime\MimeTypes; /** * @covers \Liip\ImagineBundle\Binary\Loader\ChainLoader @@ -71,9 +71,6 @@ public static function provideLoadCases(): array /** * @dataProvider provideLoadCases - * - * @param string $root - * @param string $path */ public function testLoad(string $root, string $path): void { @@ -93,8 +90,6 @@ public function provideInvalidPathsData(): array /** * @dataProvider provideInvalidPathsData - * - * @param string $path */ public function testThrowsIfFileDoesNotExist(string $path): void { @@ -106,8 +101,6 @@ public function testThrowsIfFileDoesNotExist(string $path): void /** * @dataProvider provideInvalidPathsData - * - * @param string $path */ public function testThrowsIfFileDoesNotExistWithMultipleLoaders(string $path): void { @@ -130,8 +123,6 @@ public function testThrowsIfFileDoesNotExistWithMultipleLoaders(string $path): v /** * @param string[] $paths - * - * @return FileSystemLocator */ private function getFileSystemLocator(array $paths = []): FileSystemLocator { @@ -141,8 +132,6 @@ private function getFileSystemLocator(array $paths = []): FileSystemLocator /** * @param string[] $paths * @param FileSystemLoader[] $loaders - * - * @return ChainLoader */ private function getChainLoader(array $paths = [], array $loaders = null): ChainLoader { @@ -155,11 +144,7 @@ private function getChainLoader(array $paths = [], array $loaders = null): Chain return new ChainLoader($loaders); } - /** - * @param FileBinary|mixed $return - * @param string|null $message - */ - private function assertValidLoaderFindReturn($return, string $message = ''): void + private function assertValidLoaderFindReturn(FileBinary $return, string $message = ''): void { $this->assertInstanceOf(FileBinary::class, $return, $message); $this->assertStringStartsWith('text/', $return->getMimeType(), $message); diff --git a/Tests/Binary/Loader/FileSystemLoaderTest.php b/Tests/Binary/Loader/FileSystemLoaderTest.php index feef24dce..1557d7d09 100644 --- a/Tests/Binary/Loader/FileSystemLoaderTest.php +++ b/Tests/Binary/Loader/FileSystemLoaderTest.php @@ -19,15 +19,15 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; -use Symfony\Component\Mime\MimeTypes; use Symfony\Component\Mime\MimeTypeGuesserInterface; +use Symfony\Component\Mime\MimeTypes; /** * @covers \Liip\ImagineBundle\Binary\Loader\FileSystemLoader */ class FileSystemLoaderTest extends TestCase { - public function testConstruction() + public function testConstruction(): void { $loader = $this->getFileSystemLoader(); @@ -41,7 +41,7 @@ public function testConstruction() * @param $mimeGuesser * @param $extensionGuesser */ - public function testThrowsIfConstructedWithWrongTypeArguments($expectedMessage, $mimeGuesser, $extensionGuesser) + public function testThrowsIfConstructedWithWrongTypeArguments($expectedMessage, $mimeGuesser, $extensionGuesser): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage($expectedMessage); @@ -49,30 +49,30 @@ public function testThrowsIfConstructedWithWrongTypeArguments($expectedMessage, new FileSystemLoader( $mimeGuesser, $extensionGuesser, - $this->getFileSystemLocator( $this->getDefaultDataRoots()) + $this->getFileSystemLocator($this->getDefaultDataRoots()) ); } /** * @return string[][] */ - public static function provideMultipleWrongArgumentsConstructorCases() + public static function provideMultipleWrongArgumentsConstructorCases(): array { return [ [ '$mimeGuesser must be an instance of Symfony\Component\Mime\MimeTypeGuesserInterface or Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface', 'foo', - 'bar' + 'bar', ], [ '$extensionGuesser must be an instance of Symfony\Component\Mime\MimeTypesInterface or Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface', class_exists(MimeTypes::class) ? MimeTypes::getDefault() : MimeTypeGuesser::getInstance(), - 'bar' + 'bar', ], ]; } - public function testImplementsLoaderInterface() + public function testImplementsLoaderInterface(): void { $this->assertInstanceOf(LoaderInterface::class, $this->getFileSystemLoader()); } @@ -80,7 +80,7 @@ public function testImplementsLoaderInterface() /** * @return array[] */ - public static function provideLoadCases() + public static function provideLoadCases(): array { $file = pathinfo(__FILE__, PATHINFO_BASENAME); @@ -114,11 +114,8 @@ public static function provideLoadCases() /** * @dataProvider provideLoadCases - * - * @param string $root - * @param string $path */ - public function testLoad($root, $path) + public function testLoad(string $root, string $path): void { $this->assertValidLoaderFindReturn($this->getFileSystemLoader([$root])->find($path)); } @@ -126,7 +123,7 @@ public function testLoad($root, $path) /** * @return string[][] */ - public static function provideMultipleRootLoadCases() + public static function provideMultipleRootLoadCases(): array { $pathsPrepended = [ realpath(__DIR__.'/../'), @@ -143,21 +140,20 @@ public static function provideMultipleRootLoadCases() * @dataProvider provideMultipleRootLoadCases * * @param string[] $roots - * @param string $path */ - public function testMultipleRootLoadCases($roots, $path) + public function testMultipleRootLoadCases(array $roots, string $path): void { $this->assertValidLoaderFindReturn($this->getFileSystemLoader($roots)->find($path)); } - public function testAllowsEmptyRootPath() + public function testAllowsEmptyRootPath(): void { $loader = $this->getFileSystemLoader([]); $this->assertInstanceOf(FileSystemLoader::class, $loader); } - public function testThrowsIfRootPathDoesNotExist() + public function testThrowsIfRootPathDoesNotExist(): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Root image path not resolvable'); @@ -170,7 +166,7 @@ public function testThrowsIfRootPathDoesNotExist() /** * @return array[] */ - public function provideOutsideRootPathsData() + public function provideOutsideRootPathsData(): array { return [ ['../Loader/../../Binary/Loader/../../../Resources/config/routing.yaml'], @@ -183,7 +179,7 @@ public function provideOutsideRootPathsData() * * @param string $path */ - public function testThrowsIfRealPathOutsideRootPath($path) + public function testThrowsIfRealPathOutsideRootPath($path): void { $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); $this->expectExceptionMessage('Source image invalid'); @@ -193,12 +189,12 @@ public function testThrowsIfRealPathOutsideRootPath($path) $this->assertInstanceOf(FileSystemLoader::class, $loader); } - public function testPathWithDoublePeriodBackStep() + public function testPathWithDoublePeriodBackStep(): void { $this->assertValidLoaderFindReturn($this->getFileSystemLoader()->find('/../../Binary/Loader/'.pathinfo(__FILE__, PATHINFO_BASENAME))); } - public function testThrowsIfFileDoesNotExist() + public function testThrowsIfFileDoesNotExist(): void { $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); $this->expectExceptionMessage('Source image not resolvable'); @@ -210,10 +206,8 @@ public function testThrowsIfFileDoesNotExist() /** * @param string[] $roots - * - * @return FileSystemLocator */ - private function getFileSystemLocator(array $roots) + private function getFileSystemLocator(array $roots): FileSystemLocator { return new FileSystemLocator($roots); } @@ -221,18 +215,12 @@ private function getFileSystemLocator(array $roots) /** * @return string[] */ - private function getDefaultDataRoots() + private function getDefaultDataRoots(): array { return [__DIR__]; } - /** - * @param array $roots - * @param LocatorInterface|null $locator - * - * @return FileSystemLoader - */ - private function getFileSystemLoader(array $roots = [], LocatorInterface $locator = null) + private function getFileSystemLoader(array $roots = [], LocatorInterface $locator = null): FileSystemLoader { if (interface_exists(MimeTypeGuesserInterface::class)) { $mimeTypes = MimeTypes::getDefault(); @@ -240,22 +228,18 @@ private function getFileSystemLoader(array $roots = [], LocatorInterface $locato return new FileSystemLoader( $mimeTypes, $mimeTypes, - null !== $locator ? $locator : $this->getFileSystemLocator(\count($roots) ? $roots : $this->getDefaultDataRoots()) + $locator ?? $this->getFileSystemLocator(\count($roots) ? $roots : $this->getDefaultDataRoots()) ); } return new FileSystemLoader( MimeTypeGuesser::getInstance(), ExtensionGuesser::getInstance(), - null !== $locator ? $locator : $this->getFileSystemLocator(\count($roots) ? $roots : $this->getDefaultDataRoots()) + $locator ?? $this->getFileSystemLocator(\count($roots) ? $roots : $this->getDefaultDataRoots()) ); } - /** - * @param FileBinary|mixed $return - * @param string|null $message - */ - private function assertValidLoaderFindReturn($return, string $message = ''): void + private function assertValidLoaderFindReturn(FileBinary $return, string $message = ''): void { $this->assertInstanceOf(FileBinary::class, $return, $message); $this->assertStringStartsWith('text/', $return->getMimeType(), $message); diff --git a/Tests/Binary/Loader/FlysystemLoaderTest.php b/Tests/Binary/Loader/FlysystemLoaderTest.php index 70527526d..e070c615f 100644 --- a/Tests/Binary/Loader/FlysystemLoaderTest.php +++ b/Tests/Binary/Loader/FlysystemLoaderTest.php @@ -39,22 +39,19 @@ public function setUp() $this->flyFilesystem = new Filesystem(new Local($this->fixturesPath)); } - /** - * @return FlysystemLoader - */ - public function getFlysystemLoader() + public function getFlysystemLoader(): FlysystemLoader { $extensionGuesser = class_exists(MimeTypes::class) ? MimeTypes::getDefault() : ExtensionGuesser::getInstance(); return new FlysystemLoader($extensionGuesser, $this->flyFilesystem); } - public function testShouldImplementLoaderInterface() + public function testShouldImplementLoaderInterface(): void { $this->assertInstanceOf(LoaderInterface::class, $this->getFlysystemLoader()); } - public function testThrowsIfConstructedWithWrongTypeArguments() + public function testThrowsIfConstructedWithWrongTypeArguments(): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('$extensionGuesser must be an instance of Symfony\Component\Mime\MimeTypesInterface or Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface'); @@ -65,7 +62,7 @@ public function testThrowsIfConstructedWithWrongTypeArguments() ); } - public function testReturnImageContentOnFind() + public function testReturnImageContentOnFind(): void { $loader = $this->getFlysystemLoader(); @@ -74,7 +71,7 @@ public function testReturnImageContentOnFind() ); } - public function testThrowsIfInvalidPathGivenOnFind() + public function testThrowsIfInvalidPathGivenOnFind(): void { $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); $this->expectExceptionMessageRegExp('{Source image .+ not found}'); diff --git a/Tests/Binary/Loader/StreamLoaderTest.php b/Tests/Binary/Loader/StreamLoaderTest.php index ebcd8baff..e9f547c99 100644 --- a/Tests/Binary/Loader/StreamLoaderTest.php +++ b/Tests/Binary/Loader/StreamLoaderTest.php @@ -19,7 +19,7 @@ */ class StreamLoaderTest extends AbstractTest { - public function testThrowsIfInvalidPathGivenOnFind() + public function testThrowsIfInvalidPathGivenOnFind(): void { $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); $this->expectExceptionMessageRegExp('{Source image file://.+ not found.}'); @@ -28,7 +28,7 @@ public function testThrowsIfInvalidPathGivenOnFind() $loader->find($this->temporaryPath.'/invalid.jpeg'); } - public function testReturnImageContentOnFind() + public function testReturnImageContentOnFind(): void { $loader = new StreamLoader('file://'); @@ -37,7 +37,7 @@ public function testReturnImageContentOnFind() ); } - public function testReturnImageContentWhenStreamContextProvidedOnFind() + public function testReturnImageContentWhenStreamContextProvidedOnFind(): void { $loader = new StreamLoader('file://', stream_context_create()); @@ -46,7 +46,7 @@ public function testReturnImageContentWhenStreamContextProvidedOnFind() ); } - public function testThrowsIfInvalidResourceGivenInConstructor() + public function testThrowsIfInvalidResourceGivenInConstructor(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The given context is no valid resource'); diff --git a/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php b/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php index d64ff3593..1c33292d9 100644 --- a/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php +++ b/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php @@ -13,42 +13,44 @@ use Liip\ImagineBundle\Binary\Locator\FileSystemLocator; use Liip\ImagineBundle\Binary\Locator\LocatorInterface; +use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException; +use Liip\ImagineBundle\Exception\InvalidArgumentException; use PHPUnit\Framework\TestCase; abstract class AbstractFileSystemLocatorTest extends TestCase { - public function testImplementsLocatorInterface() + public function testImplementsLocatorInterface(): void { $this->assertInstanceOf(LocatorInterface::class, new FileSystemLocator()); } - public function testThrowsIfEmptyRootPath() + public function testThrowsIfEmptyRootPath(): void { - $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Root image path not resolvable'); $this->getFileSystemLocator(''); } - public function testThrowsIfRootPathDoesNotExist() + public function testThrowsIfRootPathDoesNotExist(): void { - $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Root image path not resolvable'); $this->getFileSystemLocator('/a/bad/root/path'); } - public function testThrowsIfFileDoesNotExist() + public function testThrowsIfFileDoesNotExist(): void { - $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); + $this->expectException(NotLoadableException::class); $this->expectExceptionMessage('Source image not resolvable'); $this->getFileSystemLocator(__DIR__)->locate('fileNotExist'); } - public function testThrowsIfRootPlaceholderInvalid() + public function testThrowsIfRootPlaceholderInvalid(): void { - $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); + $this->expectException(NotLoadableException::class); $this->expectExceptionMessage('Invalid root placeholder "@invalid-placeholder" for path'); $this->getFileSystemLocator(__DIR__)->locate('@invalid-placeholder:file.ext'); @@ -57,18 +59,15 @@ public function testThrowsIfRootPlaceholderInvalid() /** * @return array[] */ - public static function provideLoadCases() + public static function provideLoadCases(): array { return []; } /** * @dataProvider provideLoadCases - * - * @param string $root - * @param string $path */ - public function testLoad($root, $path) + public function testLoad(string $root, string $path): void { $this->assertStringStartsWith(realpath($root.'/../'), $this->getFileSystemLocator($root)->locate($path)); } @@ -76,18 +75,15 @@ public function testLoad($root, $path) /** * @return array[] */ - public static function provideMultipleRootLoadCases() + public static function provideMultipleRootLoadCases(): array { return []; } /** * @dataProvider provideMultipleRootLoadCases - * - * @param string $root - * @param string $path */ - public function testMultipleRootLoadCases($root, $path) + public function testMultipleRootLoadCases(array $root, string $path): void { $this->assertNotNull($this->getFileSystemLocator($root)->locate($path)); } @@ -95,7 +91,7 @@ public function testMultipleRootLoadCases($root, $path) /** * @return array[] */ - public function provideOutsideRootPathsData() + public function provideOutsideRootPathsData(): array { return [ ['../Loader/../../Binary/Loader/../../../Resources/config/routing.yaml'], @@ -105,12 +101,10 @@ public function provideOutsideRootPathsData() /** * @dataProvider provideOutsideRootPathsData - * - * @param string $path */ - public function testThrowsIfRealPathOutsideRootPath($path) + public function testThrowsIfRealPathOutsideRootPath(string $path): void { - $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Root image path not resolvable'); $this->getFileSystemLocator($path)->locate($path); @@ -118,8 +112,6 @@ public function testThrowsIfRealPathOutsideRootPath($path) /** * @param string[]|string $paths - * - * @return LocatorInterface */ - abstract protected function getFileSystemLocator($paths); + abstract protected function getFileSystemLocator($paths): LocatorInterface; } diff --git a/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php b/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php index ff9de4ca8..e63041702 100644 --- a/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php +++ b/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php @@ -19,13 +19,13 @@ */ class FileSystemInsecureLocatorTest extends AbstractFileSystemLocatorTest { - public function testLoadsOnSymbolicLinks() + public function testLoadsOnSymbolicLinks(): void { $loader = $this->getFileSystemLocator($root = realpath(__DIR__.'/../../Fixtures/FileSystemLocator/root-02')); $this->assertStringStartsWith(realpath($root), $loader->locate('root-01/file.ext')); } - public function testThrowsIfPathHasDoublePeriodBackStep() + public function testThrowsIfPathHasDoublePeriodBackStep(): void { $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); $this->expectExceptionMessage('Source image not resolvable'); @@ -33,7 +33,7 @@ public function testThrowsIfPathHasDoublePeriodBackStep() $this->getFileSystemLocator(realpath(__DIR__.'/../../Fixtures/FileSystemLocator/root-02'))->locate('/../root-01/file.ext'); } - public function testRootPlaceholders() + public function testRootPlaceholders(): void { $root01 = realpath(__DIR__.'/../../Fixtures/FileSystemLocator/root-01'); $root02 = realpath(__DIR__.'/../../Fixtures/FileSystemLocator/root-02'); @@ -50,7 +50,7 @@ public function testRootPlaceholders() /** * @return array[] */ - public static function provideLoadCases() + public static function provideLoadCases(): array { $fileName = pathinfo(__FILE__, PATHINFO_BASENAME); @@ -66,7 +66,7 @@ public static function provideLoadCases() /** * @return array[] */ - public static function provideMultipleRootLoadCases() + public static function provideMultipleRootLoadCases(): array { $prepend = [ realpath(__DIR__.'/../'), @@ -81,10 +81,8 @@ public static function provideMultipleRootLoadCases() /** * @param string|string[] $paths - * - * @return LocatorInterface */ - protected function getFileSystemLocator($paths) + protected function getFileSystemLocator($paths): LocatorInterface { return new FileSystemInsecureLocator((array) $paths); } diff --git a/Tests/Binary/Locator/FileSystemLocatorTest.php b/Tests/Binary/Locator/FileSystemLocatorTest.php index 8170439b0..48e6b7dbf 100644 --- a/Tests/Binary/Locator/FileSystemLocatorTest.php +++ b/Tests/Binary/Locator/FileSystemLocatorTest.php @@ -19,7 +19,7 @@ */ class FileSystemLocatorTest extends AbstractFileSystemLocatorTest { - public function testAllowInvalidPaths() + public function testAllowInvalidPaths(): void { $locator = new FileSystemLocator(['/does/not/exist/foo', '/does/not/exist/bar', $temp = sys_get_temp_dir()], true); $roots = (new \ReflectionObject($locator))->getProperty('roots'); @@ -34,7 +34,7 @@ public function testAllowInvalidPaths() $this->assertSame($array, $roots->getValue($locator)); } - public function testThrowsIfPathHasSymbolicLinksPointOutsideRoot() + public function testThrowsIfPathHasSymbolicLinksPointOutsideRoot(): void { $this->expectException(\Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException::class); $this->expectExceptionMessage('Source image invalid'); @@ -42,7 +42,7 @@ public function testThrowsIfPathHasSymbolicLinksPointOutsideRoot() $this->getFileSystemLocator(realpath(__DIR__.'/../../Fixtures/FileSystemLocator/root-02'))->locate('root-01/file.ext'); } - public function testRootPlaceholders() + public function testRootPlaceholders(): void { $root01 = realpath(__DIR__.'/../../Fixtures/FileSystemLocator/root-01'); $root02 = realpath(__DIR__.'/../../Fixtures/FileSystemLocator/root-02'); @@ -59,7 +59,7 @@ public function testRootPlaceholders() /** * @return array[] */ - public static function provideLoadCases() + public static function provideLoadCases(): array { $fileName = pathinfo(__FILE__, PATHINFO_BASENAME); @@ -76,7 +76,7 @@ public static function provideLoadCases() /** * @return array[] */ - public static function provideMultipleRootLoadCases() + public static function provideMultipleRootLoadCases(): array { $prepend = [ realpath(__DIR__.'/../'), @@ -91,10 +91,8 @@ public static function provideMultipleRootLoadCases() /** * @param string|string[] $paths - * - * @return LocatorInterface */ - protected function getFileSystemLocator($paths) + protected function getFileSystemLocator($paths): LocatorInterface { return new FileSystemLocator((array) $paths); } diff --git a/Tests/Binary/SimpleMimeTypeGuesserTest.php b/Tests/Binary/SimpleMimeTypeGuesserTest.php index a48734343..3a3a8416c 100644 --- a/Tests/Binary/SimpleMimeTypeGuesserTest.php +++ b/Tests/Binary/SimpleMimeTypeGuesserTest.php @@ -23,14 +23,14 @@ */ class SimpleMimeTypeGuesserTest extends TestCase { - public function testCouldBeConstructedWithSymfonyMimeTypeGuesserAsFirstArgument() + public function testCouldBeConstructedWithSymfonyMimeTypeGuesserAsFirstArgument(): void { $guesser = $this->getSimpleMimeTypeGuesser(); $this->assertInstanceOf(SimpleMimeTypeGuesser::class, $guesser); } - public function testThrowsIfConstructedWithWrongTypeArguments() + public function testThrowsIfConstructedWithWrongTypeArguments(): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('$mimeTypeGuesser must be an instance of Symfony\Component\Mime\MimeTypeGuesserInterface or Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface'); @@ -38,7 +38,7 @@ public function testThrowsIfConstructedWithWrongTypeArguments() new SimpleMimeTypeGuesser('foo'); } - public function testImplementsMimeTypeGuesserInterface() + public function testImplementsMimeTypeGuesserInterface(): void { $this->assertInstanceOf(MimeTypeGuesserInterface::class, $this->getSimpleMimeTypeGuesser()); } @@ -46,7 +46,7 @@ public function testImplementsMimeTypeGuesserInterface() /** * @return array[] */ - public static function provideImageData() + public static function provideImageData(): array { return [ 'gif' => [__DIR__.'/../Fixtures/assets/cats.gif', 'image/gif'], @@ -65,15 +65,12 @@ public static function provideImageData() * * @throws \Exception */ - public function testGuessMimeType($fileName, $mimeType) + public function testGuessMimeType($fileName, $mimeType): void { $this->assertSame($mimeType, $this->getSimpleMimeTypeGuesser()->guess(file_get_contents($fileName))); } - /** - * @return SimpleMimeTypeGuesser - */ - private function getSimpleMimeTypeGuesser() + private function getSimpleMimeTypeGuesser(): SimpleMimeTypeGuesser { if (interface_exists(SymfonyMimeTypeGuesserInterface::class)) { return new SimpleMimeTypeGuesser(MimeTypes::getDefault()); diff --git a/Tests/Component/Console/Style/ImagineStyleTest.php b/Tests/Component/Console/Style/ImagineStyleTest.php index ed65514c8..e01dc6d55 100644 --- a/Tests/Component/Console/Style/ImagineStyleTest.php +++ b/Tests/Component/Console/Style/ImagineStyleTest.php @@ -32,7 +32,7 @@ public function testText(string $format, array $replacements): void $style = $this->createImagineStyle($output = $this->createBufferedOutput()); $style->text($format, $replacements); - $this->assertContains(vsprintf($format, $replacements), $output->getBuffer()); + $this->assertStringContainsString(vsprintf($format, $replacements), $output->getBuffer()); } public static function provideTextData(): Generator @@ -51,7 +51,7 @@ public function testTextWithoutDecoration(string $format, array $replacements): $style = $this->createImagineStyle($output = $this->createBufferedOutput(), false); $style->text($format, $replacements); - $this->assertContains(strip_tags(vsprintf($format, $replacements)), $output->getBuffer()); + $this->assertStringContainsString(strip_tags(vsprintf($format, $replacements)), $output->getBuffer()); } public static function provideTextWithoutDecorationData(): Generator @@ -67,7 +67,7 @@ public function testLine(string $format, array $replacements): void $style = $this->createImagineStyle($output = $this->createBufferedOutput()); $style->line($format, $replacements); - $this->assertContains(vsprintf($format, $replacements).PHP_EOL, $output->getBuffer()); + $this->assertStringContainsString(vsprintf($format, $replacements).PHP_EOL, $output->getBuffer()); } public static function provideLineData(): Generator @@ -85,7 +85,7 @@ public function testNewline(int $newlineCount, string $separator): void $style->newline($newlineCount); $style->text($separator); - $this->assertContains(sprintf('%1$s%2$s%1$s', $separator, str_repeat(PHP_EOL, $newlineCount)), $output->getBuffer()); + $this->assertStringContainsString(sprintf('%1$s%2$s%1$s', $separator, str_repeat(PHP_EOL, $newlineCount)), $output->getBuffer()); } public static function provideNewlineData(): Generator @@ -117,7 +117,7 @@ public function testTitle(string $title, string $type = null, bool $decoration): } } - $this->assertContains($expected, $output->getBuffer()); + $this->assertStringContainsString($expected, $output->getBuffer()); } public static function provideTitleData(): Generator @@ -128,8 +128,8 @@ public static function provideTitleData(): Generator ]; foreach ($titles as $type => $title) { - yield [$title, is_string($type) ? $type : null, true]; - yield [$title, is_string($type) ? $type : null, false]; + yield [$title, \is_string($type) ? $type : null, true]; + yield [$title, \is_string($type) ? $type : null, false]; } } @@ -141,14 +141,14 @@ public function testBlockTypes(string $type, string $expectedFormat, string $for $blockMethod = sprintf('%sBlock', $type); $style = $this->createImagineStyle($output = $this->createBufferedOutput(), $decoration); - if (!is_callable([$style, $blockMethod])) { + if (!\is_callable([$style, $blockMethod])) { static::fail(sprintf('Required method "%s" for "%s" block type is not callable!', $blockMethod, $type)); } $style->{$blockMethod}($format, $replacements); $compiled = vsprintf(strip_tags($format), $replacements); - $this->assertContains(sprintf($expectedFormat, $compiled), $output->getBuffer()); + $this->assertStringContainsString(sprintf($expectedFormat, $compiled), $output->getBuffer()); } public static function provideBlockTypesData(): Generator @@ -178,11 +178,11 @@ public static function provideBlockTypesData(): Generator public function testStatus(string $status, string $fg = null, string $bg = null): void { $style = $this->createImagineStyle($output = $this->createBufferedOutput()); - $style->status($status, $fg, $bg); + $style->status($status, $fg); - $this->assertContains($fg ?: 'default', $output->getBuffer()); - $this->assertContains($bg ?: 'default', $output->getBuffer()); - $this->assertContains(sprintf('(%s)', $status), strip_tags($output->getBuffer())); + $this->assertStringContainsString($fg ?: 'default', $output->getBuffer()); + $this->assertStringContainsString($bg ?: 'default', $output->getBuffer()); + $this->assertStringContainsString(sprintf('(%s)', $status), strip_tags($output->getBuffer())); } public static function provideStatusData(): Generator @@ -204,9 +204,9 @@ public function testGroup(string $item, string $group, string $fg = null, string $style = $this->createImagineStyle($output = $this->createBufferedOutput()); $style->group($item, $group, $fg, $bg); - $this->assertContains($fg ?: 'default', $output->getBuffer()); - $this->assertContains($bg ?: 'default', $output->getBuffer()); - $this->assertContains(sprintf('%s[%s]', $item, $group), strip_tags($output->getBuffer())); + $this->assertStringContainsString($fg ?: 'default', $output->getBuffer()); + $this->assertStringContainsString($bg ?: 'default', $output->getBuffer()); + $this->assertStringContainsString(sprintf('%s[%s]', $item, $group), strip_tags($output->getBuffer())); } public static function provideGroupData(): Generator diff --git a/Tests/Config/FilterSetBuilderTest.php b/Tests/Config/FilterSetBuilderTest.php index be05c5e9d..42f05ec3b 100644 --- a/Tests/Config/FilterSetBuilderTest.php +++ b/Tests/Config/FilterSetBuilderTest.php @@ -18,6 +18,7 @@ use Liip\ImagineBundle\Factory\Config\FilterFactoryInterface; use Liip\ImagineBundle\Factory\Config\StackFactory; use Liip\ImagineBundle\Factory\Config\StackFactoryInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** @@ -26,12 +27,12 @@ class FilterSetBuilderTest extends TestCase { /** - * @var StackFactory|\PHPUnit_Framework_MockObject_MockObject + * @var StackFactory|MockObject */ private $filterSetFactoryMock; /** - * @var FilterFactoryCollection|\PHPUnit_Framework_MockObject_MockObject + * @var FilterFactoryCollection|MockObject */ private $filterFactoryCollectionMock; @@ -47,7 +48,7 @@ protected function setUp() $this->model = new StackBuilder($this->filterSetFactoryMock, $this->filterFactoryCollectionMock); } - public function testBuildWithEmptyFilters() + public function testBuildWithEmptyFilters(): void { $name = 'foo'; $dataLoader = 'bar'; @@ -72,7 +73,7 @@ public function testBuildWithEmptyFilters() $this->assertSame($filterSetMock, $filterSet); } - public function testBuildWithFilters() + public function testBuildWithFilters(): void { $name = 'foo'; $dataLoader = 'bar'; diff --git a/Tests/Config/FilterSetCollectionTest.php b/Tests/Config/FilterSetCollectionTest.php index 18306728b..8001437ea 100644 --- a/Tests/Config/FilterSetCollectionTest.php +++ b/Tests/Config/FilterSetCollectionTest.php @@ -21,7 +21,7 @@ */ class FilterSetCollectionTest extends TestCase { - public function testGetFilterSets() + public function testGetFilterSets(): void { $filterSetName = 'foo'; $filterSetData = ['bar']; diff --git a/Tests/Config/FilterSetTest.php b/Tests/Config/FilterSetTest.php index 9be932651..a4517199f 100644 --- a/Tests/Config/FilterSetTest.php +++ b/Tests/Config/FilterSetTest.php @@ -20,7 +20,7 @@ */ class FilterSetTest extends TestCase { - public function testSetFiltersWithInvalidFilterThrowsException() + public function testSetFiltersWithInvalidFilterThrowsException(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Unknown filter provided.'); @@ -28,21 +28,17 @@ public function testSetFiltersWithInvalidFilterThrowsException() $this->buildFilterSet(['not_a_filter']); } - public function testSetFiltersWithValidFilterSuccess() + public function testSetFiltersWithValidFilterSuccess(): void { $filterMock = $this->createMock(FilterInterface::class); $stack = $this->buildFilterSet([$filterMock]); - $this->assertInstanceOf(Stack::class, $stack); $this->assertSame('filter_name', $stack->getName()); $this->assertSame('data_loader', $stack->getDataLoader()); $this->assertSame(42, $stack->getQuality()); $this->assertSame([$filterMock], $stack->getFilters()); } - /** - * @param array $filters - */ private function buildFilterSet(array $filters): Stack { return new Stack('filter_name', 'data_loader', 42, $filters); diff --git a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php index fb3b83d08..0f7d99794 100644 --- a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php @@ -12,13 +12,14 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; use Liip\ImagineBundle\DependencyInjection\Compiler\AbstractCompilerPass; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers \Liip\ImagineBundle\DependencyInjection\Compiler\AbstractCompilerPass */ class AbstractCompilerPassTest extends AbstractCompilerPassTestCase { - public function testCompilerLogging() + public function testCompilerLogging(): void { $pass = $this->createAbstractCompilerPassMock(); @@ -36,7 +37,7 @@ public function testCompilerLogging() /** * @param string[] $methods * - * @return \PHPUnit_Framework_MockObject_MockObject|AbstractCompilerPass + * @return MockObject|AbstractCompilerPass */ private function createAbstractCompilerPassMock(array $methods = []) { diff --git a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php index 1ed1864e0..828abf79f 100644 --- a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php +++ b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php @@ -13,6 +13,7 @@ use Liip\ImagineBundle\DependencyInjection\Compiler\AbstractCompilerPass; use Liip\ImagineBundle\Tests\AbstractTest; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -21,12 +22,7 @@ */ class AbstractCompilerPassTestCase extends AbstractTest { - /** - * @param array $tags - * - * @return Definition - */ - protected function createDefinition(array $tags = []) + protected function createDefinition(array $tags = []): Definition { $definition = new Definition(); @@ -39,10 +35,8 @@ protected function createDefinition(array $tags = []) /** * @param Definition[] $definitions - * - * @return ContainerBuilder */ - protected function createContainerBuilder(array $definitions = []) + protected function createContainerBuilder(array $definitions = []): ContainerBuilder { $container = new ContainerBuilder(); @@ -57,7 +51,7 @@ protected function createContainerBuilder(array $definitions = []) * @param string[] $methods * @param Definition[] $definitions * - * @return ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject + * @return ContainerBuilder|MockObject */ protected function createContainerBuilderMock(array $methods = [], array $definitions = []) { @@ -74,10 +68,9 @@ protected function createContainerBuilderMock(array $methods = [], array $defini } /** - * @param \PHPUnit_Framework_MockObject_MockObject $container - * @param mixed[] ...$expectedArguments + * @param mixed[] ...$expectedArguments */ - protected function expectContainerLogMethodCalledOnce(\PHPUnit_Framework_MockObject_MockObject $container, ...$expectedArguments): void + protected function expectContainerLogMethodCalledOnce(MockObject $container, ...$expectedArguments): void { $expectation = $container ->expects($this->once()) @@ -90,27 +83,17 @@ protected function expectContainerLogMethodCalledOnce(\PHPUnit_Framework_MockObj } } - /** - * @param Definition $definition - * @param string|null $message - */ - protected function assertDefinitionMethodCallsNone(Definition $definition, $message = '') + protected function assertDefinitionMethodCallsNone(Definition $definition, string $message = ''): void { $this->assertDefinitionMethodCallCount(0, $definition, $message); } - /** - * @param int $expect - * @param Definition $definition - * @param string|null $message - */ - protected function assertDefinitionMethodCallCount($expect, Definition $definition, $message = '') + protected function assertDefinitionMethodCallCount(int $expect, Definition $definition, string $message = ''): void { $this->assertCount($expect, $definition->getMethodCalls(), $message); } /** - * @param AbstractCompilerPass $pass * @param Definition[]|array[] $definitions */ protected function assertContainerLogMethodCalledForCompilerPass(AbstractCompilerPass $pass, array $definitions): void @@ -122,10 +105,6 @@ protected function assertContainerLogMethodCalledForCompilerPass(AbstractCompile } /** - * @param string $definition - * @param string $manager - * @param array $tags - * * @return Definition[]|array[] */ protected function getCompilerPassContainerDefinitions(string $definition, string $manager, array $tags): array diff --git a/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php b/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php index 53caa56c7..13858992f 100644 --- a/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php @@ -19,7 +19,7 @@ */ class FiltersCompilerPassTest extends AbstractCompilerPassTestCase { - public function testProcess() + public function testProcess(): void { [$d, $m] = $this->getFiltersCompilerPassContainerDefinitions(); @@ -32,7 +32,7 @@ public function testProcess() $this->assertDefinitionMethodCallCount(1, $m); } - public function testProcessLogging() + public function testProcessLogging(): void { $this->assertContainerLogMethodCalledForCompilerPass( new FiltersCompilerPass(), diff --git a/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php b/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php index 845e78a3c..62f4cb1f5 100644 --- a/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php @@ -19,7 +19,7 @@ */ class LoadersCompilerPassTest extends AbstractCompilerPassTestCase { - public function testProcess() + public function testProcess(): void { [$d, $m] = $this->getLoadersCompilerPassContainerDefinitions(); @@ -32,7 +32,7 @@ public function testProcess() $this->assertDefinitionMethodCallCount(1, $m); } - public function testProcessLogging() + public function testProcessLogging(): void { $this->assertContainerLogMethodCalledForCompilerPass( new LoadersCompilerPass(), diff --git a/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php b/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php index 131cca537..9f4e86cec 100644 --- a/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php @@ -12,6 +12,7 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; use Liip\ImagineBundle\DependencyInjection\Compiler\MetadataReaderCompilerPass; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -21,7 +22,7 @@ */ class MetadataReaderCompilerPassTest extends TestCase { - public function testProcessBasedOnExtensionsInEnvironment() + public function testProcessBasedOnExtensionsInEnvironment(): void { [$metadataServiceId, $metadataExifClass, $metadataDefaultClass] = static::getReaderParamAndDefaultAndExifValues(); @@ -33,7 +34,7 @@ public function testProcessBasedOnExtensionsInEnvironment() $this->assertInstanceOf(\extension_loaded('exif') ? $metadataExifClass : $metadataDefaultClass, $container->get($metadataServiceId)); } - public function testProcessWithoutExtExifAddsDefaultReader() + public function testProcessWithoutExtExifAddsDefaultReader(): void { [$metadataServiceId, $metadataExifClass, $metadataDefaultClass] = static::getReaderParamAndDefaultAndExifValues(); @@ -46,7 +47,7 @@ public function testProcessWithoutExtExifAddsDefaultReader() $this->assertInstanceOf($metadataDefaultClass, $container->get($metadataServiceId)); } - public function testProcessWithExtExifKeepsExifReader() + public function testProcessWithExtExifKeepsExifReader(): void { [$metadataServiceId, $metadataExifClass] = static::getReaderParamAndDefaultAndExifValues(); @@ -59,7 +60,7 @@ public function testProcessWithExtExifKeepsExifReader() $this->assertInstanceOf($metadataExifClass, $container->get($metadataServiceId)); } - public function testDoesNotOverrideCustomReaderWhenExifNotAvailable() + public function testDoesNotOverrideCustomReaderWhenExifNotAvailable(): void { [$metadataServiceId] = static::getReaderParamAndDefaultAndExifValues(); @@ -72,13 +73,7 @@ public function testDoesNotOverrideCustomReaderWhenExifNotAvailable() $this->assertInstanceOf('stdClass', $container->get($metadataServiceId)); } - /** - * @param \ReflectionClass $r - * @param string $p - * - * @return string - */ - private static function getVisibilityRestrictedStaticProperty(\ReflectionClass $r, $p) + private static function getVisibilityRestrictedStaticProperty(\ReflectionClass $r, string $p): string { $property = $r->getProperty($p); $property->setAccessible(true); @@ -91,7 +86,7 @@ private static function getVisibilityRestrictedStaticProperty(\ReflectionClass $ * * @return mixed[] */ - private static function getReaderParamAndDefaultAndExifValues() + private static function getReaderParamAndDefaultAndExifValues(): array { $r = new \ReflectionClass(MetadataReaderCompilerPass::class); @@ -103,11 +98,9 @@ private static function getReaderParamAndDefaultAndExifValues() } /** - * @param bool $isExifExtensionLoaded - * - * @return \PHPUnit_Framework_MockObject_MockObject|MetadataReaderCompilerPass + * @return MockObject|MetadataReaderCompilerPass */ - private function getMetadataReaderCompilerPass($isExifExtensionLoaded) + private function getMetadataReaderCompilerPass(bool $isExifExtensionLoaded) { $mock = $this->getMockBuilder(MetadataReaderCompilerPass::class) ->setMethods(['isExifExtensionLoaded']) diff --git a/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php b/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php index 9f5ba3252..839788fb7 100644 --- a/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php @@ -19,7 +19,7 @@ */ class PostProcessorsCompilerPassTest extends AbstractCompilerPassTestCase { - public function testProcess() + public function testProcess(): void { [$d, $m] = $this->getPostProcessorsCompilerPassContainerDefinitions(); @@ -32,7 +32,7 @@ public function testProcess() $this->assertDefinitionMethodCallCount(1, $m); } - public function testProcessLogging() + public function testProcessLogging(): void { $this->assertContainerLogMethodCalledForCompilerPass( new PostProcessorsCompilerPass(), diff --git a/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php b/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php index 015ff377a..d65de88e8 100644 --- a/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php @@ -19,7 +19,7 @@ */ class ResolversCompilerPassTest extends AbstractCompilerPassTestCase { - public function testProcess() + public function testProcess(): void { [$d, $m] = $this->getResolversCompilerPassContainerDefinitions(); @@ -32,7 +32,7 @@ public function testProcess() $this->assertDefinitionMethodCallCount(1, $m); } - public function testProcessLogging() + public function testProcessLogging(): void { $this->assertContainerLogMethodCalledForCompilerPass( new ResolversCompilerPass(), diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 70c481b73..49edba3b4 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -27,28 +27,28 @@ */ class ConfigurationTest extends TestCase { - public function testImplementsConfigurationInterface() + public function testImplementsConfigurationInterface(): void { $rc = new \ReflectionClass(Configuration::class); $this->assertTrue($rc->implementsInterface(ConfigurationInterface::class)); } - public function testTemplatingSupportIsEnabledByDefault() + public function testTemplatingSupportIsEnabledByDefault(): void { $config = $this->processConfiguration(new Configuration([], []), []); $this->assertTrue($config['templating']); } - public function testCouldBeConstructedWithResolversAndLoadersFactoriesAsArguments() + public function testCouldBeConstructedWithResolversAndLoadersFactoriesAsArguments(): void { $config = new Configuration([], []); $this->assertInstanceOf(Configuration::class, $config); } - public function testInjectLoaderFactoryConfig() + public function testInjectLoaderFactoryConfig(): void { $config = $this->processConfiguration( new Configuration( @@ -78,7 +78,7 @@ public function testInjectLoaderFactoryConfig() $this->assertSame('theValue', $config['loaders']['aLoader']['foo']['foo_option']); } - public function testAllowToUseLoaderFactorySeveralTimes() + public function testAllowToUseLoaderFactorySeveralTimes(): void { $config = $this->processConfiguration( new Configuration( @@ -111,7 +111,7 @@ public function testAllowToUseLoaderFactorySeveralTimes() $this->assertArrayHasKey('anotherLoader', $config['loaders']); } - public function testSetFilesystemLoaderAsDefaultLoaderIfNotDefined() + public function testSetFilesystemLoaderAsDefaultLoaderIfNotDefined(): void { $config = $this->processConfiguration( new Configuration( @@ -133,7 +133,7 @@ public function testSetFilesystemLoaderAsDefaultLoaderIfNotDefined() $this->assertArrayHasKey('filesystem', $config['loaders']['default']); } - public function testSetFilesystemLoaderAsDefaultLoaderIfNull() + public function testSetFilesystemLoaderAsDefaultLoaderIfNull(): void { $config = $this->processConfiguration( new Configuration( @@ -154,7 +154,7 @@ public function testSetFilesystemLoaderAsDefaultLoaderIfNull() $this->assertArrayHasKey('filesystem', $config['loaders']['default']); } - public function testThrowIfLoadersNotArray() + public function testThrowIfLoadersNotArray(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Loaders has to be array'); @@ -174,7 +174,7 @@ public function testThrowIfLoadersNotArray() ); } - public function testSetFilesystemLoaderAsDefaultIfLoadersSectionNotDefined() + public function testSetFilesystemLoaderAsDefaultIfLoadersSectionNotDefined(): void { $config = $this->processConfiguration( new Configuration( @@ -193,7 +193,7 @@ public function testSetFilesystemLoaderAsDefaultIfLoadersSectionNotDefined() $this->assertArrayHasKey('filesystem', $config['loaders']['default']); } - public function testSetWebPathResolversAsDefaultIfResolversSectionNotDefined() + public function testSetWebPathResolversAsDefaultIfResolversSectionNotDefined(): void { $config = $this->processConfiguration( new Configuration( @@ -212,7 +212,7 @@ public function testSetWebPathResolversAsDefaultIfResolversSectionNotDefined() $this->assertArrayHasKey('web_path', $config['resolvers']['default']); } - public function testShouldNotOverwriteDefaultLoaderIfDefined() + public function testShouldNotOverwriteDefaultLoaderIfDefined(): void { $config = $this->processConfiguration( new Configuration( @@ -240,7 +240,7 @@ public function testShouldNotOverwriteDefaultLoaderIfDefined() $this->assertArrayHasKey('foo', $config['loaders']['default']); } - public function testInjectResolverFactoryConfig() + public function testInjectResolverFactoryConfig(): void { $config = $this->processConfiguration( new Configuration( @@ -269,7 +269,7 @@ public function testInjectResolverFactoryConfig() $this->assertSame('theValue', $config['resolvers']['aResolver']['bar']['bar_option']); } - public function testAllowToUseResolverFactorySeveralTimes() + public function testAllowToUseResolverFactorySeveralTimes(): void { $config = $this->processConfiguration( new Configuration( @@ -302,7 +302,7 @@ public function testAllowToUseResolverFactorySeveralTimes() $this->assertArrayHasKey('anotherResolver', $config['resolvers']); } - public function testSetWebPathAsDefaultResolverIfNotDefined() + public function testSetWebPathAsDefaultResolverIfNotDefined(): void { $config = $this->processConfiguration( new Configuration( @@ -323,7 +323,7 @@ public function testSetWebPathAsDefaultResolverIfNotDefined() $this->assertArrayHasKey('web_path', $config['resolvers']['default']); } - public function testSetWebPathAsDefaultResolverIfNull() + public function testSetWebPathAsDefaultResolverIfNull(): void { $config = $this->processConfiguration( new Configuration( @@ -343,7 +343,7 @@ public function testSetWebPathAsDefaultResolverIfNull() $this->assertArrayHasKey('web_path', $config['resolvers']['default']); } - public function testThrowsIfResolversNotArray() + public function testThrowsIfResolversNotArray(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Resolvers has to be array'); @@ -366,7 +366,7 @@ public function testThrowsIfResolversNotArray() $this->assertArrayHasKey('web_path', $config['resolvers']['default']); } - public function testShouldNotOverwriteDefaultResolverIfDefined() + public function testShouldNotOverwriteDefaultResolverIfDefined(): void { $config = $this->processConfiguration( new Configuration( @@ -394,7 +394,7 @@ public function testShouldNotOverwriteDefaultResolverIfDefined() $this->assertArrayHasKey('bar', $config['resolvers']['default']); } - public function testNewFilterQualitySettings() + public function testNewFilterQualitySettings(): void { $config = $this->processConfiguration( new Configuration( @@ -427,13 +427,7 @@ public function testNewFilterQualitySettings() $this->assertSame(PNG_ALL_FILTERS, $config['filter_sets']['test']['png_compression_filter']); } - /** - * @param ConfigurationInterface $configuration - * @param array $configs - * - * @return array - */ - protected function processConfiguration(ConfigurationInterface $configuration, array $configs) + protected function processConfiguration(ConfigurationInterface $configuration, array $configs): array { $processor = new Processor(); @@ -447,12 +441,12 @@ public function create(ContainerBuilder $container, $loaderName, array $config) { } - public function getName() + public function getName(): string { return 'foo'; } - public function addConfiguration(ArrayNodeDefinition $builder) + public function addConfiguration(ArrayNodeDefinition $builder): void { $builder ->children() @@ -467,12 +461,12 @@ public function create(ContainerBuilder $container, $resolverName, array $config { } - public function getName() + public function getName(): string { return 'bar'; } - public function addConfiguration(ArrayNodeDefinition $builder) + public function addConfiguration(ArrayNodeDefinition $builder): void { $builder ->children() diff --git a/Tests/DependencyInjection/Factory/FactoryTestCase.php b/Tests/DependencyInjection/Factory/FactoryTestCase.php index 62f53f895..b6837b28b 100644 --- a/Tests/DependencyInjection/Factory/FactoryTestCase.php +++ b/Tests/DependencyInjection/Factory/FactoryTestCase.php @@ -17,10 +17,7 @@ abstract class FactoryTestCase extends TestCase { - /** - * @param Definition $definition - */ - protected function assertInstanceOfChildDefinition(Definition $definition) + protected function assertInstanceOfChildDefinition(Definition $definition): void { $this->assertInstanceOf(ChildDefinition::class, $definition); } diff --git a/Tests/DependencyInjection/Factory/Loader/ChainLoaderFactoryTest.php b/Tests/DependencyInjection/Factory/Loader/ChainLoaderFactoryTest.php index a3ebac216..b0c942fb3 100644 --- a/Tests/DependencyInjection/Factory/Loader/ChainLoaderFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Loader/ChainLoaderFactoryTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; /** * @covers \Liip\ImagineBundle\DependencyInjection\Factory\Loader\ChainLoaderFactory @@ -56,7 +57,7 @@ public function testCreateLoaderDefinition(): void $this->assertSame('liip_imagine.binary.loader.prototype.chain', $loaderDefinition->getParent()); foreach ($loaderDefinition->getArgument(0) as $reference) { - $this->assertInstanceOf('\Symfony\Component\DependencyInjection\Reference', $reference); + $this->assertInstanceOf(Reference::class, $reference); } } @@ -83,12 +84,6 @@ public function testProcessOptionsOnAddConfiguration(): void $this->assertSame(['foo', 'bar'], $config['loaders']); } - /** - * @param TreeBuilder $treeBuilder - * @param array $configs - * - * @return array - */ private function processConfigTree(TreeBuilder $treeBuilder, array $configs): array { return (new Processor())->process($treeBuilder->buildTree(), $configs); diff --git a/Tests/DependencyInjection/Factory/Loader/FileSystemLoaderFactoryTest.php b/Tests/DependencyInjection/Factory/Loader/FileSystemLoaderFactoryTest.php index ee95e50b1..13f6e648d 100644 --- a/Tests/DependencyInjection/Factory/Loader/FileSystemLoaderFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Loader/FileSystemLoaderFactoryTest.php @@ -26,24 +26,24 @@ */ class FileSystemLoaderFactoryTest extends FactoryTestCase { - public function testImplementsLoaderFactoryInterface() + public function testImplementsLoaderFactoryInterface(): void { $this->assertInstanceOf(LoaderFactoryInterface::class, new FileSystemLoaderFactory()); } - public function testCouldBeConstructedWithoutAnyArguments() + public function testCouldBeConstructedWithoutAnyArguments(): void { $this->assertInstanceOf(FileSystemLoaderFactory::class, new FileSystemLoaderFactory()); } - public function testReturnExpectedName() + public function testReturnExpectedName(): void { $loader = new FileSystemLoaderFactory(); $this->assertSame('filesystem', $loader->getName()); } - public function testCreateLoaderDefinitionOnCreate() + public function testCreateLoaderDefinitionOnCreate(): void { $container = new ContainerBuilder(); @@ -70,7 +70,7 @@ public function testCreateLoaderDefinitionOnCreate() $this->assertFalse($loaderDefinition->getArgument(2)->getArgument(1)); } - public function testCreateLoaderDefinitionWithUnresolvableRoots() + public function testCreateLoaderDefinitionWithUnresolvableRoots(): void { $container = new ContainerBuilder(); @@ -97,7 +97,7 @@ public function testCreateLoaderDefinitionWithUnresolvableRoots() $this->assertTrue($loaderDefinition->getArgument(2)->getArgument(1)); } - public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadata() + public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadata(): void { $fooBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/FooBundle'); $barBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/BarBundle'); @@ -133,7 +133,7 @@ public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadat $this->assertSame($expected, $container->getDefinition('liip_imagine.binary.loader.the_loader_name')->getArgument(2)->getArgument(0)); } - public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadataAndBlacklisting() + public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadataAndBlacklisting(): void { $fooBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/FooBundle'); $barBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/BarBundle'); @@ -170,7 +170,7 @@ public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadat $this->assertSame($expected, $container->getDefinition('liip_imagine.binary.loader.the_loader_name')->getArgument(2)->getArgument(0)); } - public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadataAndWhitelisting() + public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadataAndWhitelisting(): void { $fooBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/FooBundle'); $barBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/BarBundle'); @@ -207,7 +207,7 @@ public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingMetadat $this->assertSame($expected, $container->getDefinition('liip_imagine.binary.loader.the_loader_name')->getArgument(2)->getArgument(0)); } - public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingNamedObj() + public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingNamedObj(): void { $fooBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/FooBundle'); $barBundleRootPath = realpath(__DIR__.'/../../../Functional/Fixtures/BarBundle'); @@ -239,7 +239,7 @@ public function testCreateLoaderDefinitionOnCreateWithBundlesEnabledUsingNamedOb $this->assertSame($expected, $container->getDefinition('liip_imagine.binary.loader.the_loader_name')->getArgument(2)->getArgument(0)); } - public function testAbleToCreateTwoDistinctLoaders() + public function testAbleToCreateTwoDistinctLoaders(): void { $container = new ContainerBuilder(); @@ -273,7 +273,7 @@ public function testAbleToCreateTwoDistinctLoaders() ); } - public function testThrowsExceptionOnCreateWithBundlesEnabledUsingInvalidNamedObj() + public function testThrowsExceptionOnCreateWithBundlesEnabledUsingInvalidNamedObj(): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Unable to resolve bundle "ThisBundleDoesNotExistPleaseNoOneNameTheirObjectThisInThisScopeOrTheGlobalScopeIMeanAreYouInsane" while auto-registering bundle resource paths'); @@ -294,7 +294,7 @@ public function testThrowsExceptionOnCreateWithBundlesEnabledUsingInvalidNamedOb ]); } - public function testProcessCorrectlyOptionsOnAddConfiguration() + public function testProcessCorrectlyOptionsOnAddConfiguration(): void { $expectedDataRoot = ['theDataRoot']; @@ -316,7 +316,7 @@ public function testProcessCorrectlyOptionsOnAddConfiguration() $this->assertSame($expectedDataRoot, $config['data_root']); } - public function testAddDefaultOptionsIfNotSetOnAddConfiguration() + public function testAddDefaultOptionsIfNotSetOnAddConfiguration(): void { $expectedDataRoot = [SymfonyFramework::getContainerResolvableRootWebPath()]; @@ -336,7 +336,7 @@ public function testAddDefaultOptionsIfNotSetOnAddConfiguration() $this->assertSame($expectedDataRoot, $config['data_root']); } - public function testAddAsScalarExpectingArrayNormalizationOfConfiguration() + public function testAddAsScalarExpectingArrayNormalizationOfConfiguration(): void { $expectedDataRoot = [SymfonyFramework::getContainerResolvableRootWebPath()]; @@ -358,13 +358,7 @@ public function testAddAsScalarExpectingArrayNormalizationOfConfiguration() $this->assertSame($expectedDataRoot, $config['data_root']); } - /** - * @param TreeBuilder $treeBuilder - * @param array $configs - * - * @return array - */ - protected function processConfigTree(TreeBuilder $treeBuilder, array $configs) + protected function processConfigTree(TreeBuilder $treeBuilder, array $configs): array { $processor = new Processor(); diff --git a/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php b/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php index 6dc9fea49..37658faf4 100644 --- a/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php @@ -34,28 +34,28 @@ public function setUp() } } - public function testImplementsLoaderFactoryInterface() + public function testImplementsLoaderFactoryInterface(): void { $rc = new \ReflectionClass(FlysystemLoaderFactory::class); $this->assertTrue($rc->implementsInterface(LoaderFactoryInterface::class)); } - public function testCouldBeConstructedWithoutAnyArguments() + public function testCouldBeConstructedWithoutAnyArguments(): void { $loader = new FlysystemLoaderFactory(); $this->assertInstanceOf(FlysystemLoaderFactory::class, $loader); } - public function testReturnExpectedName() + public function testReturnExpectedName(): void { $loader = new FlysystemLoaderFactory(); $this->assertSame('flysystem', $loader->getName()); } - public function testCreateLoaderDefinitionOnCreate() + public function testCreateLoaderDefinitionOnCreate(): void { $container = new ContainerBuilder(); @@ -72,10 +72,10 @@ public function testCreateLoaderDefinitionOnCreate() $this->assertSame('liip_imagine.binary.loader.prototype.flysystem', $loaderDefinition->getParent()); $reference = $loaderDefinition->getArgument(1); - $this->assertSame('flyfilesystemservice', "$reference"); + $this->assertSame('flyfilesystemservice', (string) $reference); } - public function testThrowIfFileSystemServiceNotSetOnAddConfiguration() + public function testThrowIfFileSystemServiceNotSetOnAddConfiguration(): void { $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The child node "filesystem_service" at path "flysystem" must be configured.'); @@ -91,7 +91,7 @@ public function testThrowIfFileSystemServiceNotSetOnAddConfiguration() $this->processConfigTree($treeBuilder, []); } - public function testProcessCorrectlyOptionsOnAddConfiguration() + public function testProcessCorrectlyOptionsOnAddConfiguration(): void { $expectedService = 'theService'; @@ -113,13 +113,7 @@ public function testProcessCorrectlyOptionsOnAddConfiguration() $this->assertSame($expectedService, $config['filesystem_service']); } - /** - * @param TreeBuilder $treeBuilder - * @param array $configs - * - * @return array - */ - protected function processConfigTree(TreeBuilder $treeBuilder, array $configs) + protected function processConfigTree(TreeBuilder $treeBuilder, array $configs): array { $processor = new Processor(); diff --git a/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php b/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php index 5699db436..665f224bd 100644 --- a/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php @@ -24,28 +24,28 @@ */ class StreamLoaderFactoryTest extends TestCase { - public function testImplementsLoaderFactoryInterface() + public function testImplementsLoaderFactoryInterface(): void { $rc = new \ReflectionClass(StreamLoaderFactory::class); $this->assertTrue($rc->implementsInterface(LoaderFactoryInterface::class)); } - public function testCouldBeConstructedWithoutAnyArguments() + public function testCouldBeConstructedWithoutAnyArguments(): void { $loader = new StreamLoaderFactory(); $this->assertInstanceOf(StreamLoaderFactory::class, $loader); } - public function testReturnExpectedName() + public function testReturnExpectedName(): void { $loader = new StreamLoaderFactory(); $this->assertSame('stream', $loader->getName()); } - public function testCreateLoaderDefinitionOnCreate() + public function testCreateLoaderDefinitionOnCreate(): void { $container = new ContainerBuilder(); @@ -66,7 +66,7 @@ public function testCreateLoaderDefinitionOnCreate() $this->assertSame('theContext', $loaderDefinition->getArgument(1)); } - public function testThrowIfWrapperNotSetOnAddConfiguration() + public function testThrowIfWrapperNotSetOnAddConfiguration(): void { $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The child node "wrapper" at path "stream" must be configured.'); @@ -82,7 +82,7 @@ public function testThrowIfWrapperNotSetOnAddConfiguration() $this->processConfigTree($treeBuilder, []); } - public function testProcessCorrectlyOptionsOnAddConfiguration() + public function testProcessCorrectlyOptionsOnAddConfiguration(): void { $expectedWrapper = 'theWrapper'; $expectedContext = 'theContext'; @@ -109,7 +109,7 @@ public function testProcessCorrectlyOptionsOnAddConfiguration() $this->assertSame($expectedContext, $config['context']); } - public function testAddDefaultOptionsIfNotSetOnAddConfiguration() + public function testAddDefaultOptionsIfNotSetOnAddConfiguration(): void { $treeBuilder = new TreeBuilder('stream'); $rootNode = method_exists(TreeBuilder::class, 'getRootNode') @@ -129,13 +129,7 @@ public function testAddDefaultOptionsIfNotSetOnAddConfiguration() $this->assertNull($config['context']); } - /** - * @param TreeBuilder $treeBuilder - * @param array $configs - * - * @return array - */ - protected function processConfigTree(TreeBuilder $treeBuilder, array $configs) + protected function processConfigTree(TreeBuilder $treeBuilder, array $configs): array { $processor = new Processor(); diff --git a/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php b/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php index 8c558a507..ed71bb28a 100644 --- a/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php @@ -11,6 +11,7 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Factory\Resolver; +use Aws\S3\S3Client; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\ResolverFactoryInterface; use PHPUnit\Framework\TestCase; @@ -25,28 +26,28 @@ */ class AwsS3ResolverFactoryTest extends TestCase { - public function testImplementsResolverFactoryInterface() + public function testImplementsResolverFactoryInterface(): void { $rc = new \ReflectionClass(AwsS3ResolverFactory::class); $this->assertTrue($rc->implementsInterface(ResolverFactoryInterface::class)); } - public function testCouldBeConstructedWithoutAnyArguments() + public function testCouldBeConstructedWithoutAnyArguments(): void { $loader = new AwsS3ResolverFactory(); $this->assertInstanceOf(AwsS3ResolverFactory::class, $loader); } - public function testReturnExpectedName() + public function testReturnExpectedName(): void { $resolver = new AwsS3ResolverFactory(); $this->assertSame('aws_s3', $resolver->getName()); } - public function testCreateResolverDefinitionOnCreate() + public function testCreateResolverDefinitionOnCreate(): void { $container = new ContainerBuilder(); @@ -77,7 +78,7 @@ public function testCreateResolverDefinitionOnCreate() $this->assertSame(['barKey' => 'barVal'], $resolverDefinition->getArgument(4)); } - public function testCreateS3ClientDefinitionOnCreate() + public function testCreateS3ClientDefinitionOnCreate(): void { $container = new ContainerBuilder(); @@ -96,11 +97,11 @@ public function testCreateS3ClientDefinitionOnCreate() $this->assertTrue($container->hasDefinition('liip_imagine.cache.resolver.the_resolver_name.client')); $clientDefinition = $container->getDefinition('liip_imagine.cache.resolver.the_resolver_name.client'); - $this->assertSame('Aws\S3\S3Client', $clientDefinition->getClass()); + $this->assertSame(S3Client::class, $clientDefinition->getClass()); $this->assertSame(['theClientConfigKey' => 'theClientConfigVal'], $clientDefinition->getArgument(0)); } - public function testCreateS3ClientDefinitionWithFactoryOnCreate() + public function testCreateS3ClientDefinitionWithFactoryOnCreate(): void { $container = new ContainerBuilder(); @@ -117,10 +118,10 @@ public function testCreateS3ClientDefinitionWithFactoryOnCreate() ]); $clientDefinition = $container->getDefinition('liip_imagine.cache.resolver.the_resolver_name.client'); - $this->assertSame(['Aws\S3\S3Client', 'factory'], $clientDefinition->getFactory()); + $this->assertSame([S3Client::class, 'factory'], $clientDefinition->getFactory()); } - public function testWrapResolverWithProxyOnCreateWithoutCache() + public function testWrapResolverWithProxyOnCreateWithoutCache(): void { $container = new ContainerBuilder(); @@ -154,7 +155,7 @@ public function testWrapResolverWithProxyOnCreateWithoutCache() $this->assertSame(['foo'], $resolverDefinition->getArgument(1)); } - public function testWrapResolverWithCacheOnCreateWithoutProxy() + public function testWrapResolverWithCacheOnCreateWithoutProxy(): void { $container = new ContainerBuilder(); @@ -189,7 +190,7 @@ public function testWrapResolverWithCacheOnCreateWithoutProxy() $this->assertSame('liip_imagine.cache.resolver.the_resolver_name.cached', (string) $resolverDefinition->getArgument(1)); } - public function testWrapResolverWithProxyAndCacheOnCreate() + public function testWrapResolverWithProxyAndCacheOnCreate(): void { $container = new ContainerBuilder(); @@ -232,7 +233,7 @@ public function testWrapResolverWithProxyAndCacheOnCreate() $this->assertSame('liip_imagine.cache.resolver.the_resolver_name.cached', (string) $resolverDefinition->getArgument(1)); } - public function testWrapResolverWithProxyMatchReplaceStrategyOnCreate() + public function testWrapResolverWithProxyMatchReplaceStrategyOnCreate(): void { $container = new ContainerBuilder(); @@ -264,7 +265,7 @@ public function testWrapResolverWithProxyMatchReplaceStrategyOnCreate() $this->assertSame(['foo' => 'bar'], $cachedResolverDefinition->getArgument(1)); } - public function testSetCachePrefixIfDefined() + public function testSetCachePrefixIfDefined(): void { $container = new ContainerBuilder(); @@ -291,7 +292,7 @@ public function testSetCachePrefixIfDefined() $this->assertSame(['theCachePrefix'], $methodCalls[0][1]); } - public function testThrowBucketNotSetOnAddConfiguration() + public function testThrowBucketNotSetOnAddConfiguration(): void { $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The child node "bucket" at path "aws_s3" must be configured.'); @@ -307,7 +308,7 @@ public function testThrowBucketNotSetOnAddConfiguration() $this->processConfigTree($treeBuilder, []); } - public function testThrowClientConfigNotSetOnAddConfiguration() + public function testThrowClientConfigNotSetOnAddConfiguration(): void { $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('The child node "client_config" at path "aws_s3" must be configured.'); @@ -327,7 +328,7 @@ public function testThrowClientConfigNotSetOnAddConfiguration() ]); } - public function testThrowClientConfigNotArrayOnAddConfiguration() + public function testThrowClientConfigNotArrayOnAddConfiguration(): void { $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); $this->expectExceptionMessage('Invalid type for path "aws_s3.client_config". Expected array, but got string'); @@ -348,7 +349,7 @@ public function testThrowClientConfigNotArrayOnAddConfiguration() ]); } - public function testProcessCorrectlyOptionsOnAddConfiguration() + public function testProcessCorrectlyOptionsOnAddConfiguration(): void { $expectedClientConfig = [ 'theKey' => 'theClientConfigVal', @@ -404,7 +405,7 @@ public function testProcessCorrectlyOptionsOnAddConfiguration() $this->assertSame($expectedCachePrefix, $config['cache_prefix']); } - public function testAddDefaultOptionsIfNotSetOnAddConfiguration() + public function testAddDefaultOptionsIfNotSetOnAddConfiguration(): void { $expectedAcl = 'public-read'; @@ -433,7 +434,7 @@ public function testAddDefaultOptionsIfNotSetOnAddConfiguration() $this->assertNull($config['cache_prefix']); } - public function testSupportAwsV3ClientConfig() + public function testSupportAwsV3ClientConfig(): void { $expectedClientConfig = [ 'credentials' => [ @@ -494,13 +495,7 @@ public function testSupportAwsV3ClientConfig() $this->assertSame($expectedCachePrefix, $config['cache_prefix']); } - /** - * @param TreeBuilder $treeBuilder - * @param array $configs - * - * @return array - */ - protected function processConfigTree(TreeBuilder $treeBuilder, array $configs) + protected function processConfigTree(TreeBuilder $treeBuilder, array $configs): array { $processor = new Processor(); diff --git a/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php b/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php index 47fa00acd..1d71ab813 100644 --- a/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php @@ -34,28 +34,28 @@ public function setUp() } } - public function testImplementsResolverFactoryInterface() + public function testImplementsResolverFactoryInterface(): void { $rc = new \ReflectionClass(FlysystemResolverFactory::class); $this->assertTrue($rc->implementsInterface(ResolverFactoryInterface::class)); } - public function testCouldBeConstructedWithoutAnyArguments() + public function testCouldBeConstructedWithoutAnyArguments(): void { $loader = new FlysystemResolverFactory(); $this->assertInstanceOf(FlysystemResolverFactory::class, $loader); } - public function testReturnExpectedName() + public function testReturnExpectedName(): void { $resolver = new FlysystemResolverFactory(); $this->assertSame('flysystem', $resolver->getName()); } - public function testCreateResolverDefinitionOnCreate() + public function testCreateResolverDefinitionOnCreate(): void { $container = new ContainerBuilder(); @@ -79,7 +79,7 @@ public function testCreateResolverDefinitionOnCreate() $this->assertSame('public', $resolverDefinition->getArgument(4)); } - public function testProcessCorrectlyOptionsOnAddConfiguration() + public function testProcessCorrectlyOptionsOnAddConfiguration(): void { $expectedRootUrl = 'http://images.example.com'; $expectedCachePrefix = 'theCachePrefix'; @@ -116,7 +116,7 @@ public function testProcessCorrectlyOptionsOnAddConfiguration() $this->assertSame($expectedVisibility, $config['visibility']); } - public function testAddDefaultOptionsIfNotSetOnAddConfiguration() + public function testAddDefaultOptionsIfNotSetOnAddConfiguration(): void { $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); @@ -133,13 +133,7 @@ public function testAddDefaultOptionsIfNotSetOnAddConfiguration() ]); } - /** - * @param TreeBuilder $treeBuilder - * @param array $configs - * - * @return array - */ - protected function processConfigTree(TreeBuilder $treeBuilder, array $configs) + protected function processConfigTree(TreeBuilder $treeBuilder, array $configs): array { $processor = new Processor(); diff --git a/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php b/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php index ce966277d..f25391ec3 100644 --- a/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php @@ -25,28 +25,28 @@ */ class WebPathResolverFactoryTest extends TestCase { - public function testImplementsResolverFactoryInterface() + public function testImplementsResolverFactoryInterface(): void { $rc = new \ReflectionClass(WebPathResolverFactory::class); $this->assertTrue($rc->implementsInterface(ResolverFactoryInterface::class)); } - public function testCouldBeConstructedWithoutAnyArguments() + public function testCouldBeConstructedWithoutAnyArguments(): void { $loader = new WebPathResolverFactory(); $this->assertInstanceOf(WebPathResolverFactory::class, $loader); } - public function testReturnExpectedName() + public function testReturnExpectedName(): void { $resolver = new WebPathResolverFactory(); $this->assertSame('web_path', $resolver->getName()); } - public function testCreateResolverDefinitionOnCreate() + public function testCreateResolverDefinitionOnCreate(): void { $container = new ContainerBuilder(); @@ -67,7 +67,7 @@ public function testCreateResolverDefinitionOnCreate() $this->assertSame('theCachePrefix', $resolverDefinition->getArgument(3)); } - public function testProcessCorrectlyOptionsOnAddConfiguration() + public function testProcessCorrectlyOptionsOnAddConfiguration(): void { $expectedWebPath = 'theWebPath'; $expectedCachePrefix = 'theCachePrefix'; @@ -94,7 +94,7 @@ public function testProcessCorrectlyOptionsOnAddConfiguration() $this->assertSame($expectedCachePrefix, $config['cache_prefix']); } - public function testAddDefaultOptionsIfNotSetOnAddConfiguration() + public function testAddDefaultOptionsIfNotSetOnAddConfiguration(): void { $treeBuilder = new TreeBuilder('web_path'); $rootNode = method_exists(TreeBuilder::class, 'getRootNode') @@ -115,13 +115,7 @@ public function testAddDefaultOptionsIfNotSetOnAddConfiguration() $this->assertSame('media/cache', $config['cache_prefix']); } - /** - * @param TreeBuilder $treeBuilder - * @param array $configs - * - * @return array - */ - protected function processConfigTree(TreeBuilder $treeBuilder, array $configs) + protected function processConfigTree(TreeBuilder $treeBuilder, array $configs): array { $processor = new Processor(); diff --git a/Tests/DependencyInjection/LiipImagineExtensionTest.php b/Tests/DependencyInjection/LiipImagineExtensionTest.php index 9afceb160..48050268f 100644 --- a/Tests/DependencyInjection/LiipImagineExtensionTest.php +++ b/Tests/DependencyInjection/LiipImagineExtensionTest.php @@ -34,7 +34,7 @@ class LiipImagineExtensionTest extends AbstractTest */ protected $containerBuilder; - public function testUserLoadThrowsExceptionUnlessDriverIsValid() + public function testUserLoadThrowsExceptionUnlessDriverIsValid(): void { $this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class); @@ -42,7 +42,7 @@ public function testUserLoadThrowsExceptionUnlessDriverIsValid() $loader->load([['driver' => 'foo']], new ContainerBuilder()); } - public function testLoadFilterSetsDefaults() + public function testLoadFilterSetsDefaults(): void { $this->createConfigurationWithOneEmptyFilterSet(); $filterSets = $this->containerBuilder->getParameter('liip_imagine.filter_sets'); @@ -63,7 +63,7 @@ public function testLoadFilterSetsDefaults() $this->assertNull($emptyFilterSet['default_image']); } - public function testLoadFilterSetsWithDefaults() + public function testLoadFilterSetsWithDefaults(): void { $this->createConfigurationWithDefaultsFilterSets(); $filterSets = $this->containerBuilder->getParameter('liip_imagine.filter_sets'); @@ -111,64 +111,7 @@ public function testLoadFilterSetsWithDefaults() $this->assertArrayHasKey('mozjpeg', $filterSet2['post_processors']); } - protected function createConfigurationWithDefaultsFilterSets() - { - if (!class_exists(Parser::class)) { - $this->markTestSkipped('Requires the symfony/yaml package.'); - } - - $this->createConfiguration($this->getConfigurationWithDefaultsFilterSets()); - } - - protected function createConfigurationWithOneEmptyFilterSet() - { - if (!class_exists(Parser::class)) { - $this->markTestSkipped('Requires the symfony/yaml package.'); - } - - $this->createConfiguration($this->getConfigurationWithOneEmptyFilterSet()); - } - - protected function getConfigurationWithOneEmptyFilterSet() - { - $yaml = <<<'EOF' -filter_sets: - empty_filter_set: ~ -EOF; - $parser = new Parser(); - - return $parser->parse($yaml); - } - - protected function getConfigurationWithDefaultsFilterSets() - { - $yaml = <<<'EOF' -default_filter_set_settings: - jpeg_quality: 70 - quality: 80 - data_loader: 'my_loader' - filters: - thumbnail: { mode: 'inset' } - post_processors: - mozjpeg: {} -filter_sets: - filter_set_1: - jpeg_quality: 80 - quality: 90 - data_loader: 'my_new_loader' - filters: - thumbnail: { size: [483, 350], mode: 'outbound' } - filter_set_2: - filters: - thumbnail: { size: [483, 350] } - fixed: { width: 120, height: 90 } -EOF; - $parser = new Parser(); - - return $parser->parse($yaml); - } - - public function testLoadWithDefaults() + public function testLoadWithDefaults(): void { $this->createEmptyConfiguration(); @@ -186,7 +129,7 @@ public function testLoadWithDefaults() ); } - public function testTemplatingFilterExtensionIsDeprecated() + public function testTemplatingFilterExtensionIsDeprecated(): void { $this->createEmptyConfiguration(); @@ -194,7 +137,7 @@ public function testTemplatingFilterExtensionIsDeprecated() $this->assertDefinitionIsDeprecated('liip_imagine.templating.filter_helper', 'The "liip_imagine.templating.filter_helper" service is deprecated since LiipImagineBundle 2.2 and will be removed in 3.0.'); } - public static function provideFactoryData() + public static function provideFactoryData(): array { return [ [ @@ -214,7 +157,7 @@ public static function provideFactoryData() * @param string $service * @param string $factory */ - public function testFactoriesConfiguration($service, $factory) + public function testFactoriesConfiguration($service, $factory): void { $this->createEmptyConfiguration(); $definition = $this->containerBuilder->getDefinition($service); @@ -222,21 +165,11 @@ public function testFactoriesConfiguration($service, $factory) $this->assertSame($factory, $definition->getFactory()); } - protected function createEmptyConfiguration(): void - { - $this->createConfiguration([]); - } - - protected function createFullConfiguration(): void - { - $this->createConfiguration($this->getFullConfig()); - } - /** * @group legacy * @expectedDeprecation Symfony templating integration has been deprecated since LiipImagineBundle 2.2 and will be removed in 3.0. Use Twig and use "false" as "liip_imagine.templating" value instead. */ - public function testHelperIsRegisteredWhenTemplatingIsEnabled() + public function testHelperIsRegisteredWhenTemplatingIsEnabled(): void { $this->createConfiguration([ 'templating' => true, @@ -244,7 +177,7 @@ public function testHelperIsRegisteredWhenTemplatingIsEnabled() $this->assertHasDefinition('liip_imagine.templating.filter_helper'); } - public function testHelperIsNotRegisteredWhenTemplatingIsDisabled() + public function testHelperIsNotRegisteredWhenTemplatingIsDisabled(): void { $this->createConfiguration([ 'templating' => false, @@ -252,6 +185,73 @@ public function testHelperIsNotRegisteredWhenTemplatingIsDisabled() $this->assertHasNotDefinition('liip_imagine.templating.filter_helper'); } + protected function createConfigurationWithDefaultsFilterSets(): void + { + if (!class_exists(Parser::class)) { + $this->markTestSkipped('Requires the symfony/yaml package.'); + } + + $this->createConfiguration($this->getConfigurationWithDefaultsFilterSets()); + } + + protected function createConfigurationWithOneEmptyFilterSet(): void + { + if (!class_exists(Parser::class)) { + $this->markTestSkipped('Requires the symfony/yaml package.'); + } + + $this->createConfiguration($this->getConfigurationWithOneEmptyFilterSet()); + } + + protected function getConfigurationWithOneEmptyFilterSet() + { + $yaml = <<<'EOF' +filter_sets: + empty_filter_set: ~ +EOF; + $parser = new Parser(); + + return $parser->parse($yaml); + } + + protected function getConfigurationWithDefaultsFilterSets() + { + $yaml = <<<'EOF' +default_filter_set_settings: + jpeg_quality: 70 + quality: 80 + data_loader: 'my_loader' + filters: + thumbnail: { mode: 'inset' } + post_processors: + mozjpeg: {} +filter_sets: + filter_set_1: + jpeg_quality: 80 + quality: 90 + data_loader: 'my_new_loader' + filters: + thumbnail: { size: [483, 350], mode: 'outbound' } + filter_set_2: + filters: + thumbnail: { size: [483, 350] } + fixed: { width: 120, height: 90 } +EOF; + $parser = new Parser(); + + return $parser->parse($yaml); + } + + protected function createEmptyConfiguration(): void + { + $this->createConfiguration([]); + } + + protected function createFullConfiguration(): void + { + $this->createConfiguration($this->getFullConfig()); + } + protected function createConfiguration(array $configuration): void { $this->containerBuilder = new ContainerBuilder(); @@ -301,45 +301,27 @@ protected function getFullConfig() return $parser->parse($yaml); } - /** - * @param string $value - * @param string $key - */ - private function assertAlias($value, $key) + private function assertAlias(string $value, string $key): void { $this->assertSame($value, (string) $this->containerBuilder->getAlias($key), sprintf('%s alias is correct', $key)); } - /** - * @param string $value - * @param string $key - */ - private function assertParameter($value, $key) + private function assertParameter(string $value, string $key): void { $this->assertSame($value, $this->containerBuilder->getParameter($key), sprintf('%s parameter is correct', $key)); } - /** - * @param string $id - */ - private function assertHasDefinition($id) + private function assertHasDefinition(string $id): void { $this->assertTrue(($this->containerBuilder->hasDefinition($id) ?: $this->containerBuilder->hasAlias($id))); } - /** - * @param string $id - */ - private function assertHasNotDefinition($id) + private function assertHasNotDefinition(string $id): void { $this->assertFalse(($this->containerBuilder->hasDefinition($id) || $this->containerBuilder->hasAlias($id))); } - /** - * @param Definition $definition - * @param array $arguments - */ - private function assertDICConstructorArguments(Definition $definition, array $arguments) + private function assertDICConstructorArguments(Definition $definition, array $arguments): void { $castArrayElementsToString = function (array $a): array { return array_map(function ($v) { return (string) $v; }, $a); @@ -358,7 +340,7 @@ private function assertDICConstructorArguments(Definition $definition, array $ar ])); } - private function assertDefinitionIsDeprecated(string $id, string $message) + private function assertDefinitionIsDeprecated(string $id, string $message): void { $definition = $this->containerBuilder->getDefinition($id); diff --git a/Tests/Events/CacheResolveEventTest.php b/Tests/Events/CacheResolveEventTest.php index 2d56ddc6d..7ef9f9e5d 100644 --- a/Tests/Events/CacheResolveEventTest.php +++ b/Tests/Events/CacheResolveEventTest.php @@ -23,29 +23,29 @@ protected function setUp() { } - public function testShouldAllowSetPathInConstruct() + public function testShouldAllowSetPathInConstruct(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); - $this->assertAttributeSame('default_path', 'path', $event); + $this->assertSame('default_path', $event->getPath()); } - public function testShouldAllowSetPathByMethod() + public function testShouldAllowSetPathByMethod(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $event->setPath('new_path'); - $this->assertAttributeSame('new_path', 'path', $event); + $this->assertSame('new_path', $event->getPath()); } - public function testShouldAllowGetPathWhichWasSetInConstruct() + public function testShouldAllowGetPathWhichWasSetInConstruct(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $this->assertSame('default_path', $event->getPath()); } - public function testShouldAllowGetPathWhichWasSetByMethod() + public function testShouldAllowGetPathWhichWasSetByMethod(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $event->setPath('new_path'); @@ -53,29 +53,29 @@ public function testShouldAllowGetPathWhichWasSetByMethod() $this->assertSame('new_path', $event->getPath()); } - public function testShouldAllowSetFilterInConstruct() + public function testShouldAllowSetFilterInConstruct(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); - $this->assertAttributeSame('default_filter', 'filter', $event); + $this->assertSame('default_filter', $event->getFilter()); } - public function testShouldAllowSetFilterByMethod() + public function testShouldAllowSetFilterByMethod(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $event->setFilter('new_filter'); - $this->assertAttributeSame('new_filter', 'filter', $event); + $this->assertSame('new_filter', $event->getFilter()); } - public function testShouldAllowGetFilterWhichWasSetInConstruct() + public function testShouldAllowGetFilterWhichWasSetInConstruct(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $this->assertSame('default_filter', $event->getFilter()); } - public function testShouldAllowGetFilterWhichWasSetByMethod() + public function testShouldAllowGetFilterWhichWasSetByMethod(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $event->setFilter('new_filter'); @@ -83,29 +83,29 @@ public function testShouldAllowGetFilterWhichWasSetByMethod() $this->assertSame('new_filter', $event->getFilter()); } - public function testShouldAllowSetUrlInConstruct() + public function testShouldAllowSetUrlInConstruct(): void { $event = new CacheResolveEvent('default_path', 'default_filter', 'default_url'); - $this->assertAttributeSame('default_url', 'url', $event); + $this->assertSame('default_url', $event->getUrl()); } - public function testShouldAllowSetUrlByMethod() + public function testShouldAllowSetUrlByMethod(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $event->setUrl('new_url'); - $this->assertAttributeSame('new_url', 'url', $event); + $this->assertSame('new_url', $event->getUrl()); } - public function testShouldAllowGetUrlWhichWasSetInConstruct() + public function testShouldAllowGetUrlWhichWasSetInConstruct(): void { $event = new CacheResolveEvent('default_path', 'default_filter', 'default_url'); $this->assertSame('default_url', $event->getUrl()); } - public function testShouldAllowGetUrlWhichWasSetByMethod() + public function testShouldAllowGetUrlWhichWasSetByMethod(): void { $event = new CacheResolveEvent('default_path', 'default_filter'); $event->setUrl('new_url'); diff --git a/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php b/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php index ae73c83fa..4d85d56ba 100644 --- a/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php +++ b/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php @@ -20,14 +20,14 @@ */ class NotResolvableExceptionTest extends TestCase { - public function testSubClassOfRuntimeException() + public function testSubClassOfRuntimeException(): void { $e = new NotResolvableException(); $this->assertInstanceOf(\RuntimeException::class, $e); } - public function testImplementsExceptionInterface() + public function testImplementsExceptionInterface(): void { $e = new NotResolvableException(); diff --git a/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php b/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php index 8fee76bce..84f7214d9 100644 --- a/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php +++ b/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php @@ -20,14 +20,14 @@ */ class NotStorableExceptionTest extends TestCase { - public function testSubClassOfRuntimeException() + public function testSubClassOfRuntimeException(): void { $e = new NotStorableException(); $this->assertInstanceOf(\RuntimeException::class, $e); } - public function testImplementsExceptionInterface() + public function testImplementsExceptionInterface(): void { $e = new NotStorableException(); diff --git a/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php b/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php index 1678f8025..ef9f8f512 100644 --- a/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php +++ b/Tests/Exception/Imagine/Filter/PostProcessor/InvalidOptionExceptionTest.php @@ -12,7 +12,7 @@ namespace Liip\ImagineBundle\Tests\Exception\Imagine\Filter\PostProcessor; use Liip\ImagineBundle\Exception\Imagine\Filter\PostProcessor\InvalidOptionException; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +use PHPUnit\Framework\TestCase; /** * @covers \Liip\ImagineBundle\Exception\Imagine\Filter\PostProcessor\InvalidOptionException @@ -38,7 +38,7 @@ public function testExceptionMessage(string $message, array $options, string $op { $exception = new InvalidOptionException($message, $options); - $this->assertContains(sprintf('(%s)', $message), $exception->getMessage()); - $this->assertContains(sprintf('[%s]', $optionsText), $exception->getMessage()); + $this->assertStringContainsString(sprintf('(%s)', $message), $exception->getMessage()); + $this->assertStringContainsString(sprintf('[%s]', $optionsText), $exception->getMessage()); } } diff --git a/Tests/Fixtures/Model.php b/Tests/Fixtures/Model.php index 724eeaf70..030ef94d1 100644 --- a/Tests/Fixtures/Model.php +++ b/Tests/Fixtures/Model.php @@ -13,7 +13,7 @@ class Model { - public function get($key) + public function get($key): void { } } diff --git a/Tests/Form/Type/ImageTypeTest.php b/Tests/Form/Type/ImageTypeTest.php index eb9576a28..5657c3156 100644 --- a/Tests/Form/Type/ImageTypeTest.php +++ b/Tests/Form/Type/ImageTypeTest.php @@ -31,14 +31,14 @@ protected function setUp() } } - public function testGetParent() + public function testGetParent(): void { $type = new ImageType(); $this->assertSame(FileType::class, $type->getParent()); } - public function testConfigureOptions() + public function testConfigureOptions(): void { $resolver = new OptionsResolver(); $type = new ImageType(); @@ -54,7 +54,7 @@ public function testConfigureOptions() $this->assertTrue($resolver->isDefined('link_attr')); } - public function testBuildView() + public function testBuildView(): void { $options = [ 'image_path' => 'foo', diff --git a/Tests/Functional/AbstractSetupWebTestCase.php b/Tests/Functional/AbstractSetupWebTestCase.php index 449ad36ef..dfbe6efd7 100644 --- a/Tests/Functional/AbstractSetupWebTestCase.php +++ b/Tests/Functional/AbstractSetupWebTestCase.php @@ -11,7 +11,7 @@ namespace Liip\ImagineBundle\Tests\Functional; -use Symfony\Bundle\FrameworkBundle\Client; +use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Component\Filesystem\Filesystem; /** @@ -20,7 +20,7 @@ class AbstractSetupWebTestCase extends AbstractWebTestCase { /** - * @var Client + * @var KernelBrowser */ protected $client; diff --git a/Tests/Functional/AbstractWebTestCase.php b/Tests/Functional/AbstractWebTestCase.php index 1627e25c4..43be920d9 100644 --- a/Tests/Functional/AbstractWebTestCase.php +++ b/Tests/Functional/AbstractWebTestCase.php @@ -11,6 +11,7 @@ namespace Liip\ImagineBundle\Tests\Functional; +use Liip\ImagineBundle\Tests\Functional\app\AppKernel; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\BrowserKit\Client; @@ -35,36 +36,31 @@ public static function getKernelClass() { require_once __DIR__.'/app/AppKernel.php'; - return 'Liip\ImagineBundle\Tests\Functional\app\AppKernel'; + return AppKernel::class; } /** - * @param string $name - * * @return object */ - protected function getService($name) + protected function getService(string $name) { return static::$kernel->getContainer()->get($name); } /** - * @param string $name - * * @return mixed */ - protected function getParameter($name) + protected function getParameter(string $name) { return static::$kernel->getContainer()->getParameter($name); } /** * @param object $object - * @param string $name * * @return mixed */ - protected function getPrivateProperty($object, $name) + protected function getPrivateProperty($object, string $name) { $r = new \ReflectionObject($object); diff --git a/Tests/Functional/Binary/Loader/ChainLoaderTest.php b/Tests/Functional/Binary/Loader/ChainLoaderTest.php index 914503e66..370aacc0d 100644 --- a/Tests/Functional/Binary/Loader/ChainLoaderTest.php +++ b/Tests/Functional/Binary/Loader/ChainLoaderTest.php @@ -31,8 +31,6 @@ public function testFind(): void } /** - * @param string $name - * * @return ChainLoader|object */ private function getLoader(string $name): ChainLoader diff --git a/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php b/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php index d133ccd72..e068fb498 100644 --- a/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php +++ b/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php @@ -19,7 +19,7 @@ */ class FileSystemLoaderTest extends AbstractWebTestCase { - public function testMultipleLoadersHaveDifferentLocatorInstances() + public function testMultipleLoadersHaveDifferentLocatorInstances(): void { static::createClient(); @@ -41,11 +41,9 @@ public function testMultipleLoadersHaveDifferentLocatorInstances() } /** - * @param string $name - * * @return FileSystemLoader|object */ - private function getLoader($name) + private function getLoader(string $name) { return $this->getService(sprintf('liip_imagine.binary.loader.%s', $name)); } diff --git a/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php b/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php index 00483f1cb..e411537ca 100644 --- a/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php +++ b/Tests/Functional/Binary/Locator/FileSystemLocatorTest.php @@ -20,7 +20,7 @@ */ class FileSystemLocatorTest extends AbstractWebTestCase { - public function testBundleResourcesOnAllLoader() + public function testBundleResourcesOnAllLoader(): void { static::createClient(); @@ -35,7 +35,7 @@ public function testBundleResourcesOnAllLoader() $this->assertBarBundleResourcesExist($locator); } - public function testBundleResourcesOnFooLoader() + public function testBundleResourcesOnFooLoader(): void { static::createClient(); @@ -48,7 +48,7 @@ public function testBundleResourcesOnFooLoader() $this->assertFooBundleResourcesExist($locator); } - public function testBundleResourcesOnBarLoader() + public function testBundleResourcesOnBarLoader(): void { static::createClient(); @@ -61,20 +61,12 @@ public function testBundleResourcesOnBarLoader() $this->assertBarBundleResourcesExist($locator, true); } - /** - * @param string $name - * - * @return FileSystemLocator - */ - private function getFileSystemLoaderLocator($name) + private function getFileSystemLoaderLocator(string $name): FileSystemLocator { return $this->getPrivateProperty($this->getService(sprintf('liip_imagine.binary.loader.%s', $name)), 'locator'); } - /** - * @param LocatorInterface $locator - */ - private function assertFooBundleResourcesExist(LocatorInterface $locator) + private function assertFooBundleResourcesExist(LocatorInterface $locator): void { $this->assertLocatedFileContentsStartsWith($locator, 'file.ext', 'Fixtures/FooBundle'); $this->assertLocatedFileContentsStartsWith($locator, '@LiipFooBundle:file.ext', 'Fixtures/FooBundle'); @@ -82,11 +74,7 @@ private function assertFooBundleResourcesExist(LocatorInterface $locator) $this->assertLocatedFileContentsStartsWith($locator, '@LiipFooBundle:foo-bundle-file.ext', 'Fixtures/FooBundle'); } - /** - * @param LocatorInterface $locator - * @param bool $only - */ - private function assertBarBundleResourcesExist(LocatorInterface $locator, $only = false) + private function assertBarBundleResourcesExist(LocatorInterface $locator, bool $only = false): void { $this->assertLocatedFileContentsStartsWith($locator, 'file.ext', $only ? 'Fixtures/BarBundle' : 'Fixtures/FooBundle'); $this->assertLocatedFileContentsStartsWith($locator, '@LiipBarBundle:file.ext', 'Fixtures/BarBundle'); @@ -94,13 +82,7 @@ private function assertBarBundleResourcesExist(LocatorInterface $locator, $only $this->assertLocatedFileContentsStartsWith($locator, '@LiipBarBundle:bar-bundle-file.ext', 'Fixtures/BarBundle'); } - /** - * @param LocatorInterface $locator - * @param string $filePath - * @param string $expectedContents - * @param string|null $message - */ - private function assertLocatedFileContentsStartsWith(LocatorInterface $locator, $filePath, $expectedContents, $message = '') + private function assertLocatedFileContentsStartsWith(LocatorInterface $locator, string $filePath, string $expectedContents, $message = ''): void { $this->assertStringStartsWith($expectedContents, file_get_contents($locator->locate($filePath)), $message); } diff --git a/Tests/Functional/Command/AbstractCommandTestCase.php b/Tests/Functional/Command/AbstractCommandTestCase.php index 10da012d6..f99d42832 100644 --- a/Tests/Functional/Command/AbstractCommandTestCase.php +++ b/Tests/Functional/Command/AbstractCommandTestCase.php @@ -22,7 +22,8 @@ class AbstractCommandTestCase extends AbstractSetupWebTestCase { protected function executeConsole(string $commandName, array $arguments = [], &$return = null): string { - $application = new Application($this->createClient()->getKernel()); + $kernel = static::createKernel(); + $application = new Application($kernel); $command = $application->find($commandName); $arguments = array_replace(['command' => $command->getName()], $arguments); @@ -81,7 +82,7 @@ protected function assertOutputContainsFailedImages($output, array $images, arra { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertContains(sprintf('%s[%s] (failed)', $i, $f), $output); + $this->assertStringContainsString(sprintf('%s[%s] (failed)', $i, $f), $output); } } } @@ -95,7 +96,7 @@ protected function assertOutputContainsImage($output, $image, $filter, $type): v $filter, $image, ]); - $this->assertContains($expected, $output); + $this->assertStringContainsString($expected, $output); } /** diff --git a/Tests/Functional/Command/RemoveCacheCommandTest.php b/Tests/Functional/Command/RemoveCacheCommandTest.php index 6a283a55c..3953bb114 100644 --- a/Tests/Functional/Command/RemoveCacheCommandTest.php +++ b/Tests/Functional/Command/RemoveCacheCommandTest.php @@ -146,7 +146,7 @@ protected function assertOutputContainsSkippedImages($output, array $images, arr { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertContains(sprintf('%s[%s] (skipped)', $i, $f), $output); + $this->assertStringContainsString(sprintf('%s[%s] (skipped)', $i, $f), $output); } } } @@ -155,7 +155,7 @@ protected function assertOutputContainsRemovedImages($output, array $images, arr { foreach ($images as $i) { foreach ($filters as $f) { - $this->assertContains(sprintf('%s[%s] (removed)', $i, $f), $output); + $this->assertStringContainsString(sprintf('%s[%s] (removed)', $i, $f), $output); } } } @@ -166,11 +166,11 @@ protected function assertOutputContainsRemovedImages($output, array $images, arr */ protected function assertOutputContainsSummary(string $output, array $images, array $filters, int $failures = 0): void { - $this->assertContains(sprintf('Completed %d removal', (count($images) * count($filters)) - $failures), $output); - $this->assertContains(sprintf('%d image', count($images)), $output); - $this->assertContains(sprintf('%d filter', count($filters)), $output); + $this->assertStringContainsString(sprintf('Completed %d removal', (\count($images) * \count($filters)) - $failures), $output); + $this->assertStringContainsString(sprintf('%d image', \count($images)), $output); + $this->assertStringContainsString(sprintf('%d filter', \count($filters)), $output); if (0 !== $failures) { - $this->assertContains(sprintf('%d failure', $failures), $output); + $this->assertStringContainsString(sprintf('%d failure', $failures), $output); } } @@ -180,11 +180,11 @@ protected function assertOutputContainsSummary(string $output, array $images, ar */ protected function assertOutputNotContainsSummary(string $output, array $images, array $filters, int $failures = 0): void { - $this->assertNotContains(sprintf('Completed %d removal', (count($images) * count($filters)) - $failures), $output); - $this->assertNotContains(sprintf('%d image', count($images)), $output); - $this->assertNotContains(sprintf('%d filter', count($filters)), $output); + $this->assertStringNotContainsString(sprintf('Completed %d removal', (\count($images) * \count($filters)) - $failures), $output); + $this->assertStringNotContainsString(sprintf('%d image', \count($images)), $output); + $this->assertStringNotContainsString(sprintf('%d filter', \count($filters)), $output); if (0 !== $failures) { - $this->assertNotContains(sprintf('%d failure', $failures), $output); + $this->assertStringNotContainsString(sprintf('%d failure', $failures), $output); } } @@ -197,7 +197,7 @@ private function executeRemoveCacheCommand(array $paths, array $filters = [], ar { $options = array_merge(['path' => $paths], $additionalOptions); - if (0 < count($filters)) { + if (0 < \count($filters)) { $options['--filter'] = $filters; } diff --git a/Tests/Functional/Command/ResolveCacheCommandTest.php b/Tests/Functional/Command/ResolveCacheCommandTest.php index 26f0c6d6a..96e96aeb7 100644 --- a/Tests/Functional/Command/ResolveCacheCommandTest.php +++ b/Tests/Functional/Command/ResolveCacheCommandTest.php @@ -172,14 +172,14 @@ public function testScriptReadableOption(): void $output = $this->executeResolveCacheCommand($images, $filters, ['--as-script' => false]); - $this->assertContains('liip/imagine-bundle', $output); + $this->assertStringContainsString('liip/imagine-bundle', $output); $this->assertOutputContainsFailedImages($output, $images, $filters); $this->assertOutputContainsSummary($output, $images, $filters, 2); $output = $this->executeResolveCacheCommand($images, $filters, ['--as-script' => true]); $this->assertImagesNotExist($images, $filters); - $this->assertNotContains('liip/imagine-bundle', $output); + $this->assertStringNotContainsString('liip/imagine-bundle', $output); $this->assertOutputContainsFailedImages($output, $images, $filters); $this->assertOutputNotContainsSummary($output, $images, $filters, 2); @@ -192,11 +192,11 @@ public function testScriptReadableOption(): void */ protected function assertOutputContainsSummary(string $output, array $images, array $filters, int $failures = 0): void { - $this->assertContains(sprintf('Completed %d resolution', (count($images) * count($filters)) - $failures), $output); - $this->assertContains(sprintf('%d image', count($images)), $output); - $this->assertContains(sprintf('%d filter', count($filters)), $output); + $this->assertStringContainsString(sprintf('Completed %d resolution', (\count($images) * \count($filters)) - $failures), $output); + $this->assertStringContainsString(sprintf('%d image', \count($images)), $output); + $this->assertStringContainsString(sprintf('%d filter', \count($filters)), $output); if (0 !== $failures) { - $this->assertContains(sprintf('%d failure', $failures), $output); + $this->assertStringContainsString(sprintf('%d failure', $failures), $output); } } @@ -206,11 +206,11 @@ protected function assertOutputContainsSummary(string $output, array $images, ar */ protected function assertOutputNotContainsSummary(string $output, array $images, array $filters, int $failures = 0): void { - $this->assertNotContains(sprintf('Completed %d resolution', (count($images) * count($filters)) - $failures), $output); - $this->assertNotContains(sprintf('%d image', count($images)), $output); - $this->assertNotContains(sprintf('%d filter', count($filters)), $output); + $this->assertStringNotContainsString(sprintf('Completed %d resolution', (\count($images) * \count($filters)) - $failures), $output); + $this->assertStringNotContainsString(sprintf('%d image', \count($images)), $output); + $this->assertStringNotContainsString(sprintf('%d filter', \count($filters)), $output); if (0 !== $failures) { - $this->assertNotContains(sprintf('%d failure', $failures), $output); + $this->assertStringNotContainsString(sprintf('%d failure', $failures), $output); } } @@ -218,15 +218,12 @@ protected function assertOutputNotContainsSummary(string $output, array $images, * @param string[] $paths * @param string[] $filters * @param string[] $additionalOptions - * @param int $return - * - * @return string */ - private function executeResolveCacheCommand(array $paths, array $filters = [], array $additionalOptions = [], &$return = null): string + private function executeResolveCacheCommand(array $paths, array $filters = [], array $additionalOptions = [], int &$return = null): string { $options = array_merge(['path' => $paths], $additionalOptions); - if (0 < count($filters)) { + if (0 < \count($filters)) { $options['--filter'] = $filters; } diff --git a/Tests/Functional/Controller/ImagineControllerTest.php b/Tests/Functional/Controller/ImagineControllerTest.php index faa3a5ae6..af4d2c8c5 100644 --- a/Tests/Functional/Controller/ImagineControllerTest.php +++ b/Tests/Functional/Controller/ImagineControllerTest.php @@ -21,12 +21,12 @@ */ class ImagineControllerTest extends AbstractSetupWebTestCase { - public function testCouldBeGetFromContainer() + public function testCouldBeGetFromContainer(): void { $this->assertInstanceOf(ImagineController::class, self::$kernel->getContainer()->get(ImagineController::class)); } - public function testShouldResolvePopulatingCacheFirst() + public function testShouldResolvePopulatingCacheFirst(): void { //guard $this->assertFileNotExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); @@ -42,7 +42,7 @@ public function testShouldResolvePopulatingCacheFirst() $this->assertFileExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); } - public function testShouldResolveFromCache() + public function testShouldResolveFromCache(): void { $this->filesystem->dumpFile( $this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg', @@ -60,7 +60,7 @@ public function testShouldResolveFromCache() $this->assertFileExists($this->cacheRoot.'/thumbnail_web_path/images/cats.jpeg'); } - public function testThrowBadRequestIfSignInvalidWhileUsingCustomFilters() + public function testThrowBadRequestIfSignInvalidWhileUsingCustomFilters(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class); $this->expectExceptionMessage('Signed url does not pass the sign check for path "images/cats.jpeg" and filter "thumbnail_web_path" and runtime config {"thumbnail":{"size":["50","50"]}}'); @@ -73,7 +73,7 @@ public function testThrowBadRequestIfSignInvalidWhileUsingCustomFilters() ])); } - public function testShouldThrowNotFoundHttpExceptionIfFiltersNotArray() + public function testShouldThrowNotFoundHttpExceptionIfFiltersNotArray(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->expectExceptionMessage('Filters must be an array. Value was "some-string"'); @@ -84,7 +84,7 @@ public function testShouldThrowNotFoundHttpExceptionIfFiltersNotArray() ])); } - public function testShouldThrowNotFoundHttpExceptionIfFileNotExists() + public function testShouldThrowNotFoundHttpExceptionIfFileNotExists(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->expectExceptionMessage('Source image for path "images/shrodinger_cats_which_not_exist.jpeg" could not be found'); @@ -92,14 +92,14 @@ public function testShouldThrowNotFoundHttpExceptionIfFileNotExists() $this->client->request('GET', '/media/cache/resolve/thumbnail_web_path/images/shrodinger_cats_which_not_exist.jpeg'); } - public function testInvalidFilterShouldThrowNotFoundHttpException() + public function testInvalidFilterShouldThrowNotFoundHttpException(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->client->request('GET', '/media/cache/resolve/invalid-filter/images/cats.jpeg'); } - public function testShouldResolveWithCustomFiltersPopulatingCacheFirst() + public function testShouldResolveWithCustomFiltersPopulatingCacheFirst(): void { /** @var Signer $signer */ $signer = self::$kernel->getContainer()->get('liip_imagine.cache.signer'); @@ -132,7 +132,7 @@ public function testShouldResolveWithCustomFiltersPopulatingCacheFirst() $this->assertFileExists($this->cacheRoot.'/'.$expectedCachePath); } - public function testShouldResolveWithCustomFiltersFromCache() + public function testShouldResolveWithCustomFiltersFromCache(): void { /** @var Signer $signer */ $signer = self::$kernel->getContainer()->get('liip_imagine.cache.signer'); @@ -167,7 +167,7 @@ public function testShouldResolveWithCustomFiltersFromCache() $this->assertFileExists($this->cacheRoot.'/'.$expectedCachePath); } - public function testShouldResolvePathWithSpecialCharactersAndWhiteSpaces() + public function testShouldResolvePathWithSpecialCharactersAndWhiteSpaces(): void { $this->filesystem->dumpFile( $this->cacheRoot.'/thumbnail_web_path/images/foo bar.jpeg', diff --git a/Tests/Functional/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php b/Tests/Functional/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php index 03855d9df..d49e6513e 100644 --- a/Tests/Functional/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php +++ b/Tests/Functional/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php @@ -19,7 +19,7 @@ */ class NoCacheWebPathResolverTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainer() + public function testCouldBeGetFromContainer(): void { $this->createClient(); diff --git a/Tests/Functional/Imagine/Cache/SignerTest.php b/Tests/Functional/Imagine/Cache/SignerTest.php index ce8154ae9..051b7edbb 100644 --- a/Tests/Functional/Imagine/Cache/SignerTest.php +++ b/Tests/Functional/Imagine/Cache/SignerTest.php @@ -19,7 +19,7 @@ */ class SignerTest extends AbstractWebTestCase { - public function testGetAsService() + public function testGetAsService(): void { $this->createClient(); diff --git a/Tests/Functional/Imagine/Data/DataManagerTest.php b/Tests/Functional/Imagine/Data/DataManagerTest.php index 9f8abe018..d71975684 100644 --- a/Tests/Functional/Imagine/Data/DataManagerTest.php +++ b/Tests/Functional/Imagine/Data/DataManagerTest.php @@ -19,7 +19,7 @@ */ class DataManagerTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainerAsService() + public function testCouldBeGetFromContainerAsService(): void { $this->createClient(); diff --git a/Tests/Functional/Imagine/Filter/FilterManagerTest.php b/Tests/Functional/Imagine/Filter/FilterManagerTest.php index e10357f75..dbb29594b 100644 --- a/Tests/Functional/Imagine/Filter/FilterManagerTest.php +++ b/Tests/Functional/Imagine/Filter/FilterManagerTest.php @@ -19,7 +19,7 @@ */ class FilterManagerTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainerAsService() + public function testCouldBeGetFromContainerAsService(): void { $this->createClient(); diff --git a/Tests/Functional/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php b/Tests/Functional/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php index 85a4c6453..7f046633c 100644 --- a/Tests/Functional/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php +++ b/Tests/Functional/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php @@ -19,7 +19,7 @@ */ class DownscaleFilterLoaderTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainerAsService() + public function testCouldBeGetFromContainerAsService(): void { $this->createClient(); diff --git a/Tests/Functional/Imagine/Filter/Loader/FlipFilterLoaderTest.php b/Tests/Functional/Imagine/Filter/Loader/FlipFilterLoaderTest.php index 01a605ae7..375d0ccc6 100644 --- a/Tests/Functional/Imagine/Filter/Loader/FlipFilterLoaderTest.php +++ b/Tests/Functional/Imagine/Filter/Loader/FlipFilterLoaderTest.php @@ -11,6 +11,7 @@ namespace Liip\ImagineBundle\Tests\Functional\Imagine\Filter\Loader; +use Liip\ImagineBundle\Imagine\Filter\Loader\FlipFilterLoader; use Liip\ImagineBundle\Tests\Functional\AbstractWebTestCase; /** @@ -18,11 +19,11 @@ */ class FlipFilterLoaderTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainerAsService() + public function testCouldBeGetFromContainerAsService(): void { $this->createClient(); $this->assertInstanceOf( - '\Liip\ImagineBundle\Imagine\Filter\Loader\FlipFilterLoader', + FlipFilterLoader::class, self::$kernel->getContainer()->get('liip_imagine.filter.loader.flip') ); } diff --git a/Tests/Functional/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php b/Tests/Functional/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php index 26a4cd999..68d1e7c51 100644 --- a/Tests/Functional/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php +++ b/Tests/Functional/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php @@ -21,7 +21,7 @@ */ class GrayscaleFilterLoaderTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainerAsService() + public function testCouldBeGetFromContainerAsService(): void { $this->createClient(); diff --git a/Tests/Functional/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php b/Tests/Functional/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php index e73fbcec1..ebe62f84b 100644 --- a/Tests/Functional/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php +++ b/Tests/Functional/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php @@ -19,7 +19,7 @@ */ class InterlaceFilterLoaderTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainerAsService() + public function testCouldBeGetFromContainerAsService(): void { $this->createClient(); diff --git a/Tests/Functional/Imagine/Filter/Loader/ResampleFilterLoaderTest.php b/Tests/Functional/Imagine/Filter/Loader/ResampleFilterLoaderTest.php index ed4c65d08..e2c91e15d 100644 --- a/Tests/Functional/Imagine/Filter/Loader/ResampleFilterLoaderTest.php +++ b/Tests/Functional/Imagine/Filter/Loader/ResampleFilterLoaderTest.php @@ -11,6 +11,7 @@ namespace Liip\ImagineBundle\Tests\Functional\Imagine\Filter\Loader; +use Liip\ImagineBundle\Imagine\Filter\Loader\ResampleFilterLoader; use Liip\ImagineBundle\Tests\Functional\AbstractWebTestCase; /** @@ -18,12 +19,12 @@ */ class ResampleFilterLoaderTest extends AbstractWebTestCase { - public function testContainerHasService() + public function testContainerHasService(): void { $this->createClient(); $this->assertInstanceOf( - '\Liip\ImagineBundle\Imagine\Filter\Loader\ResampleFilterLoader', + ResampleFilterLoader::class, self::$kernel->getContainer()->get('liip_imagine.filter.loader.resample') ); } diff --git a/Tests/Functional/Imagine/Filter/Loader/RotateFilterLoaderTest.php b/Tests/Functional/Imagine/Filter/Loader/RotateFilterLoaderTest.php index 2e6fc0735..044e6a8e5 100644 --- a/Tests/Functional/Imagine/Filter/Loader/RotateFilterLoaderTest.php +++ b/Tests/Functional/Imagine/Filter/Loader/RotateFilterLoaderTest.php @@ -21,7 +21,7 @@ */ class RotateFilterLoaderTest extends AbstractWebTestCase { - public function testCouldBeGetFromContainerAsService() + public function testCouldBeGetFromContainerAsService(): void { $this->createClient(); diff --git a/Tests/Functional/app/AppKernel.php b/Tests/Functional/app/AppKernel.php index f9f835a74..2bdb24023 100644 --- a/Tests/Functional/app/AppKernel.php +++ b/Tests/Functional/app/AppKernel.php @@ -48,8 +48,6 @@ public function getLogDir() } /** - * @param \Symfony\Component\Config\Loader\LoaderInterface $loader - * * @throws \Exception */ public function registerContainerConfiguration(LoaderInterface $loader) diff --git a/Tests/Imagine/Cache/CacheManagerTest.php b/Tests/Imagine/Cache/CacheManagerTest.php index 60edc0513..542bb862f 100644 --- a/Tests/Imagine/Cache/CacheManagerTest.php +++ b/Tests/Imagine/Cache/CacheManagerTest.php @@ -19,6 +19,7 @@ use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; use Liip\ImagineBundle\Tests\Fixtures\CacheManagerAwareResolver; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface; @@ -28,7 +29,7 @@ */ class CacheManagerTest extends AbstractTest { - public function testAddCacheManagerAwareResolver() + public function testAddCacheManagerAwareResolver(): void { $cacheManager = new CacheManager($this->createFilterConfigurationMock(), $this->createRouterInterfaceMock(), new Signer('secret'), $this->createEventDispatcherInterfaceMock()); @@ -41,7 +42,7 @@ public function testAddCacheManagerAwareResolver() $cacheManager->addResolver('thumbnail', $resolver); } - public function testGetBrowserPathWithoutResolver() + public function testGetBrowserPathWithoutResolver(): void { $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Could not find resolver "default" for "thumbnail" filter type'); @@ -61,7 +62,7 @@ public function testGetBrowserPathWithoutResolver() $cacheManager->getBrowserPath('cats.jpeg', 'thumbnail'); } - public function testGetRuntimePath() + public function testGetRuntimePath(): void { $config = $this->createFilterConfigurationMock(); $cacheManager = new CacheManager($config, $this->createRouterInterfaceMock(), new Signer('secret'), $this->createEventDispatcherInterfaceMock()); @@ -75,7 +76,7 @@ public function testGetRuntimePath() $this->assertSame('rc/ILfTutxX/image.jpg', $rcPath); } - public function testDefaultResolverUsedIfNoneSetOnGetBrowserPath() + public function testDefaultResolverUsedIfNoneSetOnGetBrowserPath(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -113,7 +114,7 @@ public function testDefaultResolverUsedIfNoneSetOnGetBrowserPath() $this->assertSame('http://a/path/to/an/image.png', $actualBrowserPath); } - public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBrowserPath() + public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBrowserPath(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -150,7 +151,7 @@ public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBr $this->assertSame('/media/cache/thumbnail/cats.jpeg', $actualBrowserPath); } - public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBrowserPathWithRuntimeConfig() + public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBrowserPathWithRuntimeConfig(): void { $runtimeConfig = [ 'thumbnail' => [ @@ -198,7 +199,7 @@ public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBr * * @param string $path */ - public function testResolveInvalidPath($path) + public function testResolveInvalidPath($path): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); @@ -212,7 +213,7 @@ public function testResolveInvalidPath($path) $cacheManager->resolve($path, 'thumbnail'); } - public function testThrowsIfConcreteResolverNotExists() + public function testThrowsIfConcreteResolverNotExists(): void { $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Could not find resolver "default" for "thumbnail" filter type'); @@ -227,7 +228,7 @@ public function testThrowsIfConcreteResolverNotExists() $this->assertFalse($cacheManager->resolve('cats.jpeg', 'thumbnail')); } - public function testFallbackToDefaultResolver() + public function testFallbackToDefaultResolver(): void { $binary = new Binary('aContent', 'image/png', 'png'); @@ -275,7 +276,7 @@ public function testFallbackToDefaultResolver() $cacheManager->remove('/thumbs/cats.jpeg', 'thumbnail'); } - public function testGenerateUrl() + public function testGenerateUrl(): void { $path = 'thePath'; $expectedUrl = 'theUrl'; @@ -307,7 +308,7 @@ public function testGenerateUrl() ); } - public function testRemoveCacheForPathAndFilterOnRemove() + public function testRemoveCacheForPathAndFilterOnRemove(): void { $expectedPath = 'thePath'; $expectedFilter = 'theFilter'; @@ -333,7 +334,7 @@ public function testRemoveCacheForPathAndFilterOnRemove() $cacheManager->remove($expectedPath, $expectedFilter); } - public function testRemoveCacheForPathAndSomeFiltersOnRemove() + public function testRemoveCacheForPathAndSomeFiltersOnRemove(): void { $expectedPath = 'thePath'; $expectedFilterOne = 'theFilterOne'; @@ -367,7 +368,7 @@ public function testRemoveCacheForPathAndSomeFiltersOnRemove() $cacheManager->remove($expectedPath, [$expectedFilterOne, $expectedFilterTwo]); } - public function testRemoveCacheForSomePathsAndFilterOnRemove() + public function testRemoveCacheForSomePathsAndFilterOnRemove(): void { $expectedPathOne = 'thePathOne'; $expectedPathTwo = 'thePathTwo'; @@ -397,7 +398,7 @@ public function testRemoveCacheForSomePathsAndFilterOnRemove() $cacheManager->remove([$expectedPathOne, $expectedPathTwo], $expectedFilter); } - public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() + public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove(): void { $expectedPathOne = 'thePath'; $expectedPathTwo = 'thePath'; @@ -435,7 +436,7 @@ public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() ); } - public function testRemoveCacheForAllFiltersOnRemove() + public function testRemoveCacheForAllFiltersOnRemove(): void { $expectedFilterOne = 'theFilterOne'; $expectedFilterTwo = 'theFilterTwo'; @@ -475,7 +476,7 @@ public function testRemoveCacheForAllFiltersOnRemove() $cacheManager->remove(); } - public function testRemoveCacheForPathAndAllFiltersOnRemove() + public function testRemoveCacheForPathAndAllFiltersOnRemove(): void { $expectedFilterOne = 'theFilterOne'; $expectedFilterTwo = 'theFilterTwo'; @@ -516,7 +517,7 @@ public function testRemoveCacheForPathAndAllFiltersOnRemove() $cacheManager->remove($expectedPath); } - public function testAggregateFiltersByResolverOnRemove() + public function testAggregateFiltersByResolverOnRemove(): void { $expectedFilterOne = 'theFilterOne'; $expectedFilterTwo = 'theFilterTwo'; @@ -543,7 +544,7 @@ public function testAggregateFiltersByResolverOnRemove() $cacheManager->remove(null, [$expectedFilterOne, $expectedFilterTwo]); } - public function testShouldDispatchCachePreResolveEvent() + public function testShouldDispatchCachePreResolveEvent(): void { $dispatcher = $this->createEventDispatcherInterfaceMock(); $dispatcher @@ -551,7 +552,7 @@ public function testShouldDispatchCachePreResolveEvent() ->method('dispatch') ->with(...$this->getDispatcherArgumentsWithBC($dispatcher, [ new CacheResolveEvent('cats.jpg', 'thumbnail'), - ImagineEvents::PRE_RESOLVE + ImagineEvents::PRE_RESOLVE, ])); $cacheManager = new CacheManager( @@ -565,7 +566,7 @@ public function testShouldDispatchCachePreResolveEvent() $cacheManager->resolve('cats.jpg', 'thumbnail'); } - public function testShouldDispatchCachePostResolveEvent() + public function testShouldDispatchCachePostResolveEvent(): void { $dispatcher = $this->createEventDispatcherInterfaceMock(); $dispatcher @@ -573,7 +574,7 @@ public function testShouldDispatchCachePostResolveEvent() ->method('dispatch') ->with(...$this->getDispatcherArgumentsWithBC($dispatcher, [ new CacheResolveEvent('cats.jpg', 'thumbnail'), - ImagineEvents::POST_RESOLVE + ImagineEvents::POST_RESOLVE, ])); $cacheManager = new CacheManager( @@ -587,7 +588,7 @@ public function testShouldDispatchCachePostResolveEvent() $cacheManager->resolve('cats.jpg', 'thumbnail'); } - public function testShouldAllowToPassChangedDataFromPreResolveEventToResolver() + public function testShouldAllowToPassChangedDataFromPreResolveEventToResolver(): void { $dispatcher = $this->createEventDispatcherInterfaceMock(); $dispatcher @@ -595,9 +596,9 @@ public function testShouldAllowToPassChangedDataFromPreResolveEventToResolver() ->method('dispatch') ->with(...$this->getDispatcherArgumentsWithBC($dispatcher, [ $this->isInstanceOf(CacheResolveEvent::class), - ImagineEvents::PRE_RESOLVE + ImagineEvents::PRE_RESOLVE, ])) - ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function ($event, $name) { + ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function ($event) { $event->setPath('changed_path'); $event->setFilter('changed_filter'); })); @@ -619,13 +620,13 @@ public function testShouldAllowToPassChangedDataFromPreResolveEventToResolver() $cacheManager->resolve('cats.jpg', 'thumbnail'); } - public function testShouldAllowToGetResolverByFilterChangedInPreResolveEvent() + public function testShouldAllowToGetResolverByFilterChangedInPreResolveEvent(): void { $dispatcher = $this->createEventDispatcherInterfaceMock(); $dispatcher ->expects($this->at(0)) ->method('dispatch') - ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function ($event, $name) { + ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function ($event) { $event->setFilter('thumbnail'); })); @@ -648,7 +649,7 @@ public function testShouldAllowToGetResolverByFilterChangedInPreResolveEvent() $cacheManager->resolve('cats.jpg', 'default'); } - public function testShouldAllowToPassChangedDataFromPreResolveEventToPostResolveEvent() + public function testShouldAllowToPassChangedDataFromPreResolveEventToPostResolveEvent(): void { $dispatcher = $this->createEventDispatcherInterfaceMock(); $dispatcher @@ -656,9 +657,9 @@ public function testShouldAllowToPassChangedDataFromPreResolveEventToPostResolve ->method('dispatch') ->with(...$this->getDispatcherArgumentsWithBC($dispatcher, [ $this->isInstanceOf(CacheResolveEvent::class), - ImagineEvents::PRE_RESOLVE + ImagineEvents::PRE_RESOLVE, ])) - ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function ($event, $name) { + ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function (CacheResolveEvent $event) { $event->setPath('changed_path'); $event->setFilter('changed_filter'); })); @@ -668,8 +669,9 @@ public function testShouldAllowToPassChangedDataFromPreResolveEventToPostResolve ->method('dispatch') ->with(...$this->getDispatcherArgumentsWithBC($dispatcher, [$this->logicalAnd( $this->isInstanceOf(CacheResolveEvent::class), - $this->attributeEqualTo('path', 'changed_path'), - $this->attributeEqualTo('filter', 'changed_filter') + $this->callback(function (CacheResolveEvent $event) { + return 'changed_filter' === $event->getFilter() && 'changed_path' === $event->getPath(); + }) ), ImagineEvents::POST_RESOLVE])); $cacheManager = new CacheManager( @@ -683,7 +685,7 @@ public function testShouldAllowToPassChangedDataFromPreResolveEventToPostResolve $cacheManager->resolve('cats.jpg', 'thumbnail'); } - public function testShouldReturnUrlChangedInPostResolveEvent() + public function testShouldReturnUrlChangedInPostResolveEvent(): void { $dispatcher = $this->createEventDispatcherInterfaceMock(); $dispatcher @@ -691,9 +693,9 @@ public function testShouldReturnUrlChangedInPostResolveEvent() ->method('dispatch') ->with(...$this->getDispatcherArgumentsWithBC($dispatcher, [ $this->isInstanceOf(CacheResolveEvent::class), - ImagineEvents::POST_RESOLVE + ImagineEvents::POST_RESOLVE, ])) - ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function ($event, $name) { + ->willReturnCallback($this->getDispatcherCallbackWithBC($dispatcher, function ($event) { $event->setUrl('changed_url'); })); @@ -709,21 +711,17 @@ public function testShouldReturnUrlChangedInPostResolveEvent() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|ResolverInterface + * @return MockObject|ResolverInterface */ private function createCacheManagerAwareResolverMock() { - return $resolver = $this + return $this ->getMockBuilder(CacheManagerAwareResolver::class) ->getMock(); } /** * BC Layer for Symfony < 4.3 - * - * @param EventDispatcherInterface $dispatcher - * @param callable $callable - * @return callable */ private function getDispatcherCallbackWithBC(EventDispatcherInterface $dispatcher, callable $callable): callable { @@ -738,10 +736,6 @@ private function getDispatcherCallbackWithBC(EventDispatcherInterface $dispatche /** * BC Layer for Symfony < 4.3 - * - * @param EventDispatcherInterface $dispatcher - * @param array $arguments - * @return array */ private function getDispatcherArgumentsWithBC(EventDispatcherInterface $dispatcher, array $arguments): array { diff --git a/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php b/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php index 937593034..3e202001c 100644 --- a/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php @@ -15,20 +15,21 @@ use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers \Liip\ImagineBundle\Imagine\Cache\Resolver\AmazonS3Resolver */ class AmazonS3ResolverTest extends AbstractTest { - public function testImplementsResolverInterface() + public function testImplementsResolverInterface(): void { $rc = new \ReflectionClass(AmazonS3Resolver::class); $this->assertTrue($rc->implementsInterface(ResolverInterface::class)); } - public function testNoDoubleSlashesInObjectUrlOnResolve() + public function testNoDoubleSlashesInObjectUrlOnResolve(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -40,7 +41,7 @@ public function testNoDoubleSlashesInObjectUrlOnResolve() $resolver->resolve('/some-folder/path.jpg', 'thumb'); } - public function testObjUrlOptionsPassedToAmazonOnResolve() + public function testObjUrlOptionsPassedToAmazonOnResolve(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -53,7 +54,7 @@ public function testObjUrlOptionsPassedToAmazonOnResolve() $resolver->resolve('/some-folder/path.jpg', 'thumb'); } - public function testThrowsAndLogIfCanNotCreateObjectOnAmazon() + public function testThrowsAndLogIfCanNotCreateObjectOnAmazon(): void { $this->expectException(\Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotStorableException::class); $this->expectExceptionMessage('The object could not be created on Amazon S3'); @@ -76,7 +77,7 @@ public function testThrowsAndLogIfCanNotCreateObjectOnAmazon() $resolver->store($binary, 'foobar.jpg', 'thumb'); } - public function testCreatedObjectOnAmazon() + public function testCreatedObjectOnAmazon(): void { $binary = new Binary('aContent', 'image/jpeg', 'jpeg'); @@ -90,7 +91,7 @@ public function testCreatedObjectOnAmazon() $resolver->store($binary, 'foobar.jpg', 'thumb'); } - public function testIsStoredChecksObjectExistence() + public function testIsStoredChecksObjectExistence(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -103,7 +104,7 @@ public function testIsStoredChecksObjectExistence() $this->assertFalse($resolver->isStored('/some-folder/path.jpg', 'thumb')); } - public function testReturnResolvedImageUrlOnResolve() + public function testReturnResolvedImageUrlOnResolve(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -120,7 +121,7 @@ public function testReturnResolvedImageUrlOnResolve() ); } - public function testDoNothingIfFiltersAndPathsEmptyOnRemove() + public function testDoNothingIfFiltersAndPathsEmptyOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -137,7 +138,7 @@ public function testDoNothingIfFiltersAndPathsEmptyOnRemove() $resolver->remove([], []); } - public function testRemoveCacheForPathAndFilterOnRemove() + public function testRemoveCacheForPathAndFilterOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -155,7 +156,7 @@ public function testRemoveCacheForPathAndFilterOnRemove() $resolver->remove(['some-folder/path.jpg'], ['thumb']); } - public function testRemoveCacheForSomePathsAndFilterOnRemove() + public function testRemoveCacheForSomePathsAndFilterOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -183,7 +184,7 @@ public function testRemoveCacheForSomePathsAndFilterOnRemove() $resolver->remove(['pathOne.jpg', 'pathTwo.jpg'], ['filter']); } - public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() + public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -234,7 +235,7 @@ public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() ); } - public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove() + public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -250,7 +251,7 @@ public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove() $resolver->remove(['path.jpg'], ['filter']); } - public function testLogIfNotDeletedForPathAndFilterOnRemove() + public function testLogIfNotDeletedForPathAndFilterOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -273,7 +274,7 @@ public function testLogIfNotDeletedForPathAndFilterOnRemove() $resolver->remove(['path.jpg'], ['filter']); } - public function testRemoveCacheForFilterOnRemove() + public function testRemoveCacheForFilterOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -286,7 +287,7 @@ public function testRemoveCacheForFilterOnRemove() $resolver->remove([], ['filter']); } - public function testRemoveCacheForSomeFiltersOnRemove() + public function testRemoveCacheForSomeFiltersOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -299,7 +300,7 @@ public function testRemoveCacheForSomeFiltersOnRemove() $resolver->remove([], ['filterOne', 'filterTwo']); } - public function testLogIfBatchNotDeletedForFilterOnRemove() + public function testLogIfBatchNotDeletedForFilterOnRemove(): void { $s3 = $this->createAmazonS3Mock(); $s3 @@ -321,7 +322,7 @@ public function testLogIfBatchNotDeletedForFilterOnRemove() /** * @param bool $ok * - * @return \PHPUnit_Framework_MockObject_MockObject|\CFResponse + * @return MockObject|\CFResponse */ protected function createCFResponseMock($ok = true) { @@ -335,7 +336,7 @@ protected function createCFResponseMock($ok = true) } /** - * @return \PHPUnit_Framework_MockObject_MockObject|\AmazonS3 + * @return MockObject|\AmazonS3 */ protected function createAmazonS3Mock() { diff --git a/Tests/Imagine/Cache/Resolver/AwsS3ResolverTest.php b/Tests/Imagine/Cache/Resolver/AwsS3ResolverTest.php index 9539cd669..9f358a966 100644 --- a/Tests/Imagine/Cache/Resolver/AwsS3ResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/AwsS3ResolverTest.php @@ -17,20 +17,21 @@ use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers \Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver */ class AwsS3ResolverTest extends AbstractTest { - public function testImplementsResolverInterface() + public function testImplementsResolverInterface(): void { $rc = new \ReflectionClass(AwsS3Resolver::class); $this->assertTrue($rc->implementsInterface(ResolverInterface::class)); } - public function testNoDoubleSlashesInObjectUrlOnResolve() + public function testNoDoubleSlashesInObjectUrlOnResolve(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -42,7 +43,7 @@ public function testNoDoubleSlashesInObjectUrlOnResolve() $resolver->resolve('/some-folder/path.jpg', 'thumb'); } - public function testObjUrlOptionsPassedToS3ClintOnResolve() + public function testObjUrlOptionsPassedToS3ClintOnResolve(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -55,7 +56,7 @@ public function testObjUrlOptionsPassedToS3ClintOnResolve() $resolver->resolve('/some-folder/path.jpg', 'thumb'); } - public function testLogNotCreatedObjects() + public function testLogNotCreatedObjects(): void { $this->expectException(\Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotStorableException::class); $this->expectExceptionMessage('The object could not be created on Amazon S3'); @@ -78,7 +79,7 @@ public function testLogNotCreatedObjects() $resolver->store($binary, 'foobar.jpg', 'thumb'); } - public function testCreateObjectOnAmazon() + public function testCreateObjectOnAmazon(): void { $binary = new Binary('aContent', 'image/jpeg', 'jpeg'); @@ -92,7 +93,7 @@ public function testCreateObjectOnAmazon() $resolver->store($binary, 'thumb/foobar.jpg', 'thumb'); } - public function testObjectOptionsPassedToS3ClintOnCreate() + public function testObjectOptionsPassedToS3ClintOnCreate(): void { $binary = new Binary('aContent', 'image/jpeg', 'jpeg'); @@ -114,7 +115,7 @@ public function testObjectOptionsPassedToS3ClintOnCreate() $resolver->store($binary, 'images/foobar.jpg', 'filter'); } - public function testIsStoredChecksObjectExistence() + public function testIsStoredChecksObjectExistence(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -127,7 +128,7 @@ public function testIsStoredChecksObjectExistence() $this->assertFalse($resolver->isStored('/some-folder/path.jpg', 'thumb')); } - public function testReturnResolvedImageUrlOnResolve() + public function testReturnResolvedImageUrlOnResolve(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -144,7 +145,7 @@ public function testReturnResolvedImageUrlOnResolve() ); } - public function testDoNothingIfFiltersAndPathsEmptyOnRemove() + public function testDoNothingIfFiltersAndPathsEmptyOnRemove(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -161,7 +162,7 @@ public function testDoNothingIfFiltersAndPathsEmptyOnRemove() $resolver->remove([], []); } - public function testRemoveCacheForPathAndFilterOnRemove() + public function testRemoveCacheForPathAndFilterOnRemove(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -182,7 +183,7 @@ public function testRemoveCacheForPathAndFilterOnRemove() $resolver->remove(['some-folder/path.jpg'], ['thumb']); } - public function testRemoveCacheForSomePathsAndFilterOnRemove() + public function testRemoveCacheForSomePathsAndFilterOnRemove(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -219,7 +220,7 @@ public function testRemoveCacheForSomePathsAndFilterOnRemove() ); } - public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() + public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -282,7 +283,7 @@ public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() ); } - public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove() + public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -298,7 +299,7 @@ public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove() $resolver->remove(['some-folder/path.jpg'], ['thumb']); } - public function testCatchAndLogExceptionsForPathAndFilterOnRemove() + public function testCatchAndLogExceptionsForPathAndFilterOnRemove(): void { $s3 = $this->getS3ClientMock(); $s3 @@ -321,7 +322,7 @@ public function testCatchAndLogExceptionsForPathAndFilterOnRemove() $resolver->remove(['some-folder/path.jpg'], ['thumb']); } - public function testRemoveCacheForFilterOnRemove() + public function testRemoveCacheForFilterOnRemove(): void { $expectedBucket = 'images.example.com'; $expectedFilter = 'theFilter'; @@ -336,7 +337,7 @@ public function testRemoveCacheForFilterOnRemove() $resolver->remove([], [$expectedFilter]); } - public function testRemoveCacheForSomeFiltersOnRemove() + public function testRemoveCacheForSomeFiltersOnRemove(): void { $expectedBucket = 'images.example.com'; $expectedFilterOne = 'theFilterOne'; @@ -352,7 +353,7 @@ public function testRemoveCacheForSomeFiltersOnRemove() $resolver->remove([], [$expectedFilterOne, $expectedFilterTwo]); } - public function testCatchAndLogExceptionForFilterOnRemove() + public function testCatchAndLogExceptionForFilterOnRemove(): void { $expectedBucket = 'images.example.com'; $expectedFilter = 'theFilter'; @@ -374,7 +375,7 @@ public function testCatchAndLogExceptionForFilterOnRemove() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|Model + * @return MockObject|Model */ protected function getS3ResponseMock() { @@ -382,7 +383,7 @@ protected function getS3ResponseMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|\Aws\S3\S3Client + * @return MockObject|\Aws\S3\S3Client */ protected function getS3ClientMock() { diff --git a/Tests/Imagine/Cache/Resolver/CacheResolverTest.php b/Tests/Imagine/Cache/Resolver/CacheResolverTest.php index fe22a0d58..0c540fb23 100644 --- a/Tests/Imagine/Cache/Resolver/CacheResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/CacheResolverTest.php @@ -35,7 +35,7 @@ protected function setUp() parent::setUp(); } - public function testResolveIsSavedToCache() + public function testResolveIsSavedToCache(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -53,7 +53,7 @@ public function testResolveIsSavedToCache() $this->assertSame($this->webPath, $cacheResolver->resolve($this->path, $this->filter)); } - public function testNotCallInternalResolverIfCachedOnIsStored() + public function testNotCallInternalResolverIfCachedOnIsStored(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -74,7 +74,7 @@ public function testNotCallInternalResolverIfCachedOnIsStored() $this->assertTrue($cacheResolver->isStored($this->path, $this->filter)); } - public function testCallInternalResolverIfNotCachedOnIsStored() + public function testCallInternalResolverIfNotCachedOnIsStored(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -88,7 +88,7 @@ public function testCallInternalResolverIfNotCachedOnIsStored() $this->assertTrue($cacheResolver->isStored($this->path, $this->filter)); } - public function testStoreIsForwardedToResolver() + public function testStoreIsForwardedToResolver(): void { $binary = new Binary('aContent', 'image/jpeg', 'jpg'); @@ -105,7 +105,7 @@ public function testStoreIsForwardedToResolver() $this->assertNull($cacheResolver->store($binary, $this->webPath, $this->filter)); } - public function testSavesToCacheIfInternalResolverReturnUrlOnResolve() + public function testSavesToCacheIfInternalResolverReturnUrlOnResolve(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -124,7 +124,7 @@ public function testSavesToCacheIfInternalResolverReturnUrlOnResolve() $cacheResolver->resolve($this->path, $this->filter); } - public function testRemoveSinglePathCacheOnRemove() + public function testRemoveSinglePathCacheOnRemove(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -154,7 +154,7 @@ public function testRemoveSinglePathCacheOnRemove() $this->assertCount(0, $this->getCacheEntries($cache)); } - public function testRemoveAllFilterCacheOnRemove() + public function testRemoveAllFilterCacheOnRemove(): void { $resolver = $this->createCacheResolverInterfaceMock(); $resolver @@ -191,12 +191,8 @@ public function testRemoveAllFilterCacheOnRemove() * version, it may or may not be there depending on doctrine-cache * version. There's no point in checking it anyway since it's a detail * of doctrine cache implementation. - * - * @param ArrayCache $cache - * - * @return array */ - private function getCacheEntries(ArrayCache $cache) + private function getCacheEntries(ArrayCache $cache): array { $cacheEntries = $this->readAttribute($cache, 'data'); unset($cacheEntries['DoctrineNamespaceCacheKey[]']); diff --git a/Tests/Imagine/Cache/Resolver/FlysystemResolverTest.php b/Tests/Imagine/Cache/Resolver/FlysystemResolverTest.php index 827510dad..8c1574e5a 100644 --- a/Tests/Imagine/Cache/Resolver/FlysystemResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/FlysystemResolverTest.php @@ -16,6 +16,7 @@ use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Routing\RequestContext; /** @@ -32,14 +33,14 @@ public function setUp() } } - public function testImplementsResolverInterface() + public function testImplementsResolverInterface(): void { $rc = new \ReflectionClass(FlysystemResolver::class); $this->assertTrue($rc->implementsInterface(ResolverInterface::class)); } - public function testResolveUriForFilter() + public function testResolveUriForFilter(): void { $resolver = new FlysystemResolver($this->createFlySystemMock(), new RequestContext(), 'http://images.example.com'); @@ -49,7 +50,7 @@ public function testResolveUriForFilter() ); } - public function testRemoveObjectsForFilter() + public function testRemoveObjectsForFilter(): void { $expectedFilter = 'theFilter'; $fs = $this->createFlySystemMock(); @@ -62,7 +63,7 @@ public function testRemoveObjectsForFilter() $resolver->remove([], [$expectedFilter]); } - public function testCreateObjectInAdapter() + public function testCreateObjectInAdapter(): void { $binary = new Binary('aContent', 'image/jpeg', 'jpeg'); @@ -77,7 +78,7 @@ public function testCreateObjectInAdapter() $this->assertNull($resolver->store($binary, 'thumb/foobar.jpg', 'thumb')); } - public function testIsStoredChecksObjectExistence() + public function testIsStoredChecksObjectExistence(): void { $fs = $this->createFlySystemMock(); $fs @@ -90,7 +91,7 @@ public function testIsStoredChecksObjectExistence() $this->assertFalse($resolver->isStored('/some-folder/path.jpg', 'thumb')); } - public function testReturnResolvedImageUrlOnResolve() + public function testReturnResolvedImageUrlOnResolve(): void { $fs = $this->createFlySystemMock(); @@ -102,7 +103,7 @@ public function testReturnResolvedImageUrlOnResolve() ); } - public function testResolveWithPrefixCacheEmpty() + public function testResolveWithPrefixCacheEmpty(): void { $resolver = new FlysystemResolver($this->createFlySystemMock(), new RequestContext(), 'http://images.example.com', ''); @@ -112,7 +113,7 @@ public function testResolveWithPrefixCacheEmpty() ); } - public function testRemoveCacheForPathAndFilterOnRemove() + public function testRemoveCacheForPathAndFilterOnRemove(): void { $fs = $this->createFlySystemMock(); $fs @@ -130,7 +131,7 @@ public function testRemoveCacheForPathAndFilterOnRemove() $resolver->remove(['some-folder/path.jpg'], ['thumb']); } - public function testRemoveCacheForSomePathsAndFilterOnRemove() + public function testRemoveCacheForSomePathsAndFilterOnRemove(): void { $fs = $this->createFlySystemMock(); $fs @@ -161,7 +162,7 @@ public function testRemoveCacheForSomePathsAndFilterOnRemove() ); } - public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() + public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove(): void { $fs = $this->createFlySystemMock(); $fs @@ -212,7 +213,7 @@ public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() ); } - public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove() + public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove(): void { $fs = $this->createFlySystemMock(); $fs @@ -228,7 +229,7 @@ public function testDoNothingWhenObjectNotExistForPathAndFilterOnRemove() $resolver->remove(['some-folder/path.jpg'], ['thumb']); } - public function testRemoveCacheForFilterOnRemove() + public function testRemoveCacheForFilterOnRemove(): void { $expectedFilter = 'theFilter'; @@ -242,7 +243,7 @@ public function testRemoveCacheForFilterOnRemove() $resolver->remove([], [$expectedFilter]); } - public function testRemoveCacheForSomeFiltersOnRemove() + public function testRemoveCacheForSomeFiltersOnRemove(): void { $expectedFilterOne = 'theFilterOne'; $expectedFilterTwo = 'theFilterTwo'; @@ -262,7 +263,7 @@ public function testRemoveCacheForSomeFiltersOnRemove() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|Filesystem + * @return MockObject|Filesystem */ protected function createFlySystemMock() { diff --git a/Tests/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php b/Tests/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php index 2ca88f27c..90e8fb974 100644 --- a/Tests/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/NoCacheWebPathResolverTest.php @@ -21,28 +21,28 @@ */ class NoCacheWebPathResolverTest extends AbstractTest { - public function testCouldBeConstructedWithRequestContextAsArgument() + public function testCouldBeConstructedWithRequestContextAsArgument(): void { $resolver = new NoCacheWebPathResolver(new RequestContext()); $this->assertInstanceOf(NoCacheWebPathResolver::class, $resolver); } - public function testComposeSchemaHostAndPathOnResolve() + public function testComposeSchemaHostAndPathOnResolve(): void { $resolver = new NoCacheWebPathResolver(new RequestContext('', 'GET', 'thehost', 'theSchema')); $this->assertSame('theschema://thehost/aPath', $resolver->resolve('aPath', 'aFilter')); } - public function testDoNothingOnStore() + public function testDoNothingOnStore(): void { $resolver = new NoCacheWebPathResolver(new RequestContext()); $this->assertNull($resolver->store(new Binary('aContent', 'image/jpeg', 'jpg'), 'a/path', 'aFilter')); } - public function testDoNothingForPathAndFilterOnRemove() + public function testDoNothingForPathAndFilterOnRemove(): void { $resolver = new NoCacheWebPathResolver(new RequestContext()); $resolver->remove(['a/path'], ['aFilter']); @@ -50,7 +50,7 @@ public function testDoNothingForPathAndFilterOnRemove() $this->assertInstanceOf(NoCacheWebPathResolver::class, $resolver); } - public function testDoNothingForSomePathsAndSomeFiltersOnRemove() + public function testDoNothingForSomePathsAndSomeFiltersOnRemove(): void { $resolver = new NoCacheWebPathResolver(new RequestContext()); $resolver->remove(['foo', 'bar'], ['foo', 'bar']); @@ -58,7 +58,7 @@ public function testDoNothingForSomePathsAndSomeFiltersOnRemove() $this->assertInstanceOf(NoCacheWebPathResolver::class, $resolver); } - public function testDoNothingForEmptyPathAndEmptyFilterOnRemove() + public function testDoNothingForEmptyPathAndEmptyFilterOnRemove(): void { $resolver = new NoCacheWebPathResolver(new RequestContext()); $resolver->remove([], []); diff --git a/Tests/Imagine/Cache/Resolver/ProxyResolverTest.php b/Tests/Imagine/Cache/Resolver/ProxyResolverTest.php index 7c6fca369..99658397b 100644 --- a/Tests/Imagine/Cache/Resolver/ProxyResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/ProxyResolverTest.php @@ -15,6 +15,7 @@ use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers \Liip\ImagineBundle\Imagine\Cache\Resolver\ProxyResolver @@ -22,7 +23,7 @@ class ProxyResolverTest extends AbstractTest { /** - * @var \PHPUnit_Framework_MockObject_MockObject|ResolverInterface + * @var MockObject|ResolverInterface */ private $primaryResolver; @@ -37,7 +38,7 @@ public function setUp() $this->resolver = new ProxyResolver($this->primaryResolver, ['http://images.example.com']); } - public function testProxyCallAndRewriteReturnedUrlOnResolve() + public function testProxyCallAndRewriteReturnedUrlOnResolve(): void { $expectedPath = '/foo/bar/bazz.png'; $expectedFilter = 'test'; @@ -53,7 +54,7 @@ public function testProxyCallAndRewriteReturnedUrlOnResolve() $this->assertSame('http://images.example.com/thumbs/foo/bar/bazz.png', $result); } - public function testProxyCallAndRewriteReturnedUrlEvenSchemesDiffersOnResolve() + public function testProxyCallAndRewriteReturnedUrlEvenSchemesDiffersOnResolve(): void { $expectedPath = '/foo/bar/bazz.png'; $expectedFilter = 'test'; @@ -69,7 +70,7 @@ public function testProxyCallAndRewriteReturnedUrlEvenSchemesDiffersOnResolve() $this->assertSame('http://images.example.com/thumbs/foo/bar/bazz.png', $result); } - public function testProxyCallAndRewriteReturnedUrlWithMatchReplaceOnResolve() + public function testProxyCallAndRewriteReturnedUrlWithMatchReplaceOnResolve(): void { $expectedPath = '/foo/bar/bazz.png'; $expectedFilter = 'test'; @@ -89,7 +90,7 @@ public function testProxyCallAndRewriteReturnedUrlWithMatchReplaceOnResolve() $this->assertSame('http://images.example.com/thumbs/foo/bar/bazz.png', $result); } - public function testProxyCallAndRewriteReturnedUrlWithRegExpOnResolve() + public function testProxyCallAndRewriteReturnedUrlWithRegExpOnResolve(): void { $expectedPath = '/foo/bar/bazz.png'; $expectedFilter = 'test'; @@ -109,7 +110,7 @@ public function testProxyCallAndRewriteReturnedUrlWithRegExpOnResolve() $this->assertSame('http://bar.com/thumbs/foo/bar/bazz.png', $result); } - public function testProxyCallAndReturnedValueOnIsStored() + public function testProxyCallAndReturnedValueOnIsStored(): void { $expectedPath = 'thePath'; $expectedFilter = 'theFilter'; @@ -123,7 +124,7 @@ public function testProxyCallAndReturnedValueOnIsStored() $this->assertTrue($this->resolver->isStored($expectedPath, $expectedFilter)); } - public function testProxyCallOnStore() + public function testProxyCallOnStore(): void { $expectedPath = 'thePath'; $expectedFilter = 'theFilter'; @@ -137,7 +138,7 @@ public function testProxyCallOnStore() $this->resolver->store($expectedBinary, $expectedPath, $expectedFilter); } - public function testProxyCallOnRemove() + public function testProxyCallOnRemove(): void { $expectedPaths = ['thePath']; $expectedFilters = ['theFilter']; diff --git a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php index 0eb27b54a..dba6ce7ef 100644 --- a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php @@ -14,6 +14,7 @@ use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; use Liip\ImagineBundle\Imagine\Cache\Resolver\WebPathResolver; use Liip\ImagineBundle\Model\Binary; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Routing\RequestContext; @@ -52,14 +53,14 @@ public function tearDown() $this->filesystem->remove($this->basePath); } - public function testImplementsResolverInterface() + public function testImplementsResolverInterface(): void { $rc = new \ReflectionClass(WebPathResolver::class); $this->assertTrue($rc->implementsInterface(ResolverInterface::class)); } - public function testCouldBeConstructedWithRequiredArguments() + public function testCouldBeConstructedWithRequiredArguments(): void { $filesystemMock = $this->createFilesystemMock(); $requestContext = new RequestContext(); @@ -72,7 +73,7 @@ public function testCouldBeConstructedWithRequiredArguments() $this->assertAttributeSame($webRoot, 'webRoot', $resolver); } - public function testCouldBeConstructedWithOptionalArguments() + public function testCouldBeConstructedWithOptionalArguments(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -84,7 +85,7 @@ public function testCouldBeConstructedWithOptionalArguments() $this->assertAttributeSame('theCachePrefix', 'cachePrefix', $resolver); } - public function testTrimRightSlashFromWebPathOnConstruct() + public function testTrimRightSlashFromWebPathOnConstruct(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -96,7 +97,7 @@ public function testTrimRightSlashFromWebPathOnConstruct() $this->assertAttributeSame('aWebRoot', 'webRoot', $resolver); } - public function testRemoveDoubleSlashFromWebRootOnConstruct() + public function testRemoveDoubleSlashFromWebRootOnConstruct(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -108,7 +109,7 @@ public function testRemoveDoubleSlashFromWebRootOnConstruct() $this->assertAttributeSame('aWeb/Root', 'webRoot', $resolver); } - public function testTrimRightSlashFromCachePrefixOnConstruct() + public function testTrimRightSlashFromCachePrefixOnConstruct(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -120,7 +121,7 @@ public function testTrimRightSlashFromCachePrefixOnConstruct() $this->assertAttributeSame('aCachePrefix', 'cachePrefix', $resolver); } - public function testRemoveDoubleSlashFromCachePrefixOnConstruct() + public function testRemoveDoubleSlashFromCachePrefixOnConstruct(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -132,7 +133,7 @@ public function testRemoveDoubleSlashFromCachePrefixOnConstruct() $this->assertAttributeSame('aCache/Prefix', 'cachePrefix', $resolver); } - public function testReturnTrueIfFileExistsOnIsStored() + public function testReturnTrueIfFileExistsOnIsStored(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -144,7 +145,7 @@ public function testReturnTrueIfFileExistsOnIsStored() $this->assertTrue($resolver->isStored('existingPath', 'aFilter')); } - public function testReturnFalseIfFileNotExistsOnIsStored() + public function testReturnFalseIfFileNotExistsOnIsStored(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -156,7 +157,7 @@ public function testReturnFalseIfFileNotExistsOnIsStored() $this->assertFalse($resolver->isStored('nonExistingPath', 'aFilter')); } - public function testReturnFalseIfIsNotFile() + public function testReturnFalseIfIsNotFile(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -168,7 +169,7 @@ public function testReturnFalseIfIsNotFile() $this->assertFalse($resolver->isStored('', 'aFilter')); } - public function testComposeSchemaHostAndFileUrlOnResolve() + public function testComposeSchemaHostAndFileUrlOnResolve(): void { $requestContext = new RequestContext(); $requestContext->setScheme('theSchema'); @@ -187,7 +188,7 @@ public function testComposeSchemaHostAndFileUrlOnResolve() ); } - public function testComposeSchemaHostAndBasePathWithPhpFileAndFileUrlOnResolve() + public function testComposeSchemaHostAndBasePathWithPhpFileAndFileUrlOnResolve(): void { $requestContext = new RequestContext(); $requestContext->setScheme('theSchema'); @@ -207,7 +208,7 @@ public function testComposeSchemaHostAndBasePathWithPhpFileAndFileUrlOnResolve() ); } - public function testResolveWithPrefixCacheEmpty() + public function testResolveWithPrefixCacheEmpty(): void { $requestContext = new RequestContext(); $requestContext->setScheme('theSchema'); @@ -227,7 +228,7 @@ public function testResolveWithPrefixCacheEmpty() ); } - public function testComposeSchemaHostAndBasePathWithDirsOnlyAndFileUrlOnResolve() + public function testComposeSchemaHostAndBasePathWithDirsOnlyAndFileUrlOnResolve(): void { $requestContext = new RequestContext(); $requestContext->setScheme('theSchema'); @@ -247,7 +248,7 @@ public function testComposeSchemaHostAndBasePathWithDirsOnlyAndFileUrlOnResolve( ); } - public function testComposeSchemaHostAndBasePathWithBackSplashOnResolve() + public function testComposeSchemaHostAndBasePathWithBackSplashOnResolve(): void { $requestContext = new RequestContext(); $requestContext->setScheme('theSchema'); @@ -267,7 +268,7 @@ public function testComposeSchemaHostAndBasePathWithBackSplashOnResolve() ); } - public function testComposeSchemaHttpAndCustomPortAndFileUrlOnResolve() + public function testComposeSchemaHttpAndCustomPortAndFileUrlOnResolve(): void { $requestContext = new RequestContext(); $requestContext->setScheme('http'); @@ -287,7 +288,7 @@ public function testComposeSchemaHttpAndCustomPortAndFileUrlOnResolve() ); } - public function testComposeSchemaHttpsAndCustomPortAndFileUrlOnResolve() + public function testComposeSchemaHttpsAndCustomPortAndFileUrlOnResolve(): void { $requestContext = new RequestContext(); $requestContext->setScheme('https'); @@ -307,7 +308,7 @@ public function testComposeSchemaHttpsAndCustomPortAndFileUrlOnResolve() ); } - public function testDumpBinaryContentOnStore() + public function testDumpBinaryContentOnStore(): void { $binary = new Binary('theContent', 'aMimeType', 'aFormat'); @@ -327,7 +328,7 @@ public function testDumpBinaryContentOnStore() $this->assertNull($resolver->store($binary, 'aPath', 'aFilter')); } - public function testDoNothingIfFiltersAndPathsEmptyOnRemove() + public function testDoNothingIfFiltersAndPathsEmptyOnRemove(): void { $filesystemMock = $this->createFilesystemMock(); $filesystemMock @@ -344,7 +345,7 @@ public function testDoNothingIfFiltersAndPathsEmptyOnRemove() $resolver->remove([], []); } - public function testRemoveCacheForPathAndFilterOnRemove() + public function testRemoveCacheForPathAndFilterOnRemove(): void { $filesystemMock = $this->createFilesystemMock(); $filesystemMock @@ -362,7 +363,7 @@ public function testRemoveCacheForPathAndFilterOnRemove() $resolver->remove(['aPath'], ['aFilter']); } - public function testRemoveCacheForSomePathsAndFilterOnRemove() + public function testRemoveCacheForSomePathsAndFilterOnRemove(): void { $filesystemMock = $this->createFilesystemMock(); $filesystemMock @@ -384,7 +385,7 @@ public function testRemoveCacheForSomePathsAndFilterOnRemove() $resolver->remove(['aPathOne', 'aPathTwo'], ['aFilter']); } - public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() + public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove(): void { $filesystemMock = $this->createFilesystemMock(); $filesystemMock @@ -417,7 +418,7 @@ public function testRemoveCacheForSomePathsAndSomeFiltersOnRemove() ); } - public function testRemoveCacheForFilterOnRemove() + public function testRemoveCacheForFilterOnRemove(): void { $filesystemMock = $this->createFilesystemMock(); $filesystemMock @@ -437,7 +438,7 @@ public function testRemoveCacheForFilterOnRemove() $resolver->remove([], ['aFilter']); } - public function testRemoveCacheForSomeFiltersOnRemove() + public function testRemoveCacheForSomeFiltersOnRemove(): void { $filesystemMock = $this->createFilesystemMock(); $filesystemMock @@ -458,7 +459,7 @@ public function testRemoveCacheForSomeFiltersOnRemove() $resolver->remove([], ['aFilterOne', 'aFilterTwo']); } - public function testShouldRemoveDoubleSlashInUrl() + public function testShouldRemoveDoubleSlashInUrl(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -476,7 +477,7 @@ public function testShouldRemoveDoubleSlashInUrl() $this->assertSame('aCachePrefix/some_filter/cats.jpg', $result); } - public function testShouldSanitizeSeparatorBetweenSchemeAndAuthorityInUrl() + public function testShouldSanitizeSeparatorBetweenSchemeAndAuthorityInUrl(): void { $resolver = new WebPathResolver( $this->createFilesystemMock(), @@ -495,7 +496,7 @@ public function testShouldSanitizeSeparatorBetweenSchemeAndAuthorityInUrl() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|Filesystem + * @return MockObject|Filesystem */ protected function createFilesystemMock() { diff --git a/Tests/Imagine/Cache/SignerTest.php b/Tests/Imagine/Cache/SignerTest.php index f2f7b8368..aca8ec265 100644 --- a/Tests/Imagine/Cache/SignerTest.php +++ b/Tests/Imagine/Cache/SignerTest.php @@ -20,42 +20,42 @@ */ class SignerTest extends AbstractTest { - public function testImplementsSignerInterface() + public function testImplementsSignerInterface(): void { $rc = new \ReflectionClass(Signer::class); $this->assertTrue($rc->implementsInterface(SignerInterface::class)); } - public function testCouldBeConstructedWithSecret() + public function testCouldBeConstructedWithSecret(): void { $signer = new Signer('aSecret'); $this->assertInstanceOf(Signer::class, $signer); } - public function testShouldReturnShortHashOnSign() + public function testShouldReturnShortHashOnSign(): void { $singer = new Signer('aSecret'); $this->assertSame(8, mb_strlen($singer->sign('aPath'))); } - public function testShouldSingAndSuccessfullyCheckPathWithoutRuntimeConfig() + public function testShouldSingAndSuccessfullyCheckPathWithoutRuntimeConfig(): void { $singer = new Signer('aSecret'); $this->assertTrue($singer->check($singer->sign('aPath'), 'aPath')); } - public function testShouldSingAndSuccessfullyCheckPathWithRuntimeConfig() + public function testShouldSingAndSuccessfullyCheckPathWithRuntimeConfig(): void { $singer = new Signer('aSecret'); $this->assertTrue($singer->check($singer->sign('aPath', ['aConfig']), 'aPath', ['aConfig'])); } - public function testShouldConvertRecursivelyToStringAllRuntimeConfigParameters() + public function testShouldConvertRecursivelyToStringAllRuntimeConfigParameters(): void { $singer = new Signer('aSecret'); diff --git a/Tests/Imagine/Data/DataManagerTest.php b/Tests/Imagine/Data/DataManagerTest.php index 320b32e08..df4d42372 100644 --- a/Tests/Imagine/Data/DataManagerTest.php +++ b/Tests/Imagine/Data/DataManagerTest.php @@ -11,7 +11,6 @@ namespace Liip\ImagineBundle\Tests\Imagine\Data; -use Liip\ImagineBundle\Binary\Loader\FlysystemLoader; use Liip\ImagineBundle\Imagine\Data\DataManager; use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; @@ -22,7 +21,7 @@ */ class DataManagerTest extends AbstractTest { - public function testThrowsIfConstructedWithWrongTypeArguments() + public function testThrowsIfConstructedWithWrongTypeArguments(): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('$extensionGuesser must be an instance of Symfony\Component\Mime\MimeTypesInterface or Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface'); @@ -33,7 +32,7 @@ public function testThrowsIfConstructedWithWrongTypeArguments() new DataManager($mimeTypeGuesser, 'foo', $config, 'default'); } - public function testUseDefaultLoaderUsedIfNoneSet() + public function testUseDefaultLoaderUsedIfNoneSet(): void { $loader = $this->createBinaryLoaderInterfaceMock(); $loader @@ -64,7 +63,7 @@ public function testUseDefaultLoaderUsedIfNoneSet() $dataManager->find('thumbnail', 'cats.jpeg'); } - public function testUseLoaderRegisteredForFilterOnFind() + public function testUseLoaderRegisteredForFilterOnFind(): void { $loader = $this->createBinaryLoaderInterfaceMock(); $loader @@ -95,7 +94,7 @@ public function testUseLoaderRegisteredForFilterOnFind() $dataManager->find('thumbnail', 'cats.jpeg'); } - public function testThrowsIfMimeTypeWasNotGuessedOnFind() + public function testThrowsIfMimeTypeWasNotGuessedOnFind(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('The mime type of image cats.jpeg was not guessed'); @@ -128,7 +127,7 @@ public function testThrowsIfMimeTypeWasNotGuessedOnFind() $dataManager->find('thumbnail', 'cats.jpeg'); } - public function testThrowsIfMimeTypeNotImageOneOnFind() + public function testThrowsIfMimeTypeNotImageOneOnFind(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('The mime type of image cats.jpeg must be image/xxx got text/plain'); @@ -162,7 +161,7 @@ public function testThrowsIfMimeTypeNotImageOneOnFind() $dataManager->find('thumbnail', 'cats.jpeg'); } - public function testThrowsIfLoaderReturnBinaryWithEmtptyMimeTypeOnFind() + public function testThrowsIfLoaderReturnBinaryWithEmtptyMimeTypeOnFind(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('The mime type of image cats.jpeg was not guessed'); @@ -195,7 +194,7 @@ public function testThrowsIfLoaderReturnBinaryWithEmtptyMimeTypeOnFind() $dataManager->find('thumbnail', 'cats.jpeg'); } - public function testThrowsIfLoaderReturnBinaryWithMimeTypeNotImageOneOnFind() + public function testThrowsIfLoaderReturnBinaryWithMimeTypeNotImageOneOnFind(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('The mime type of image cats.jpeg must be image/xxx got text/plain'); @@ -230,7 +229,7 @@ public function testThrowsIfLoaderReturnBinaryWithMimeTypeNotImageOneOnFind() $dataManager->find('thumbnail', 'cats.jpeg'); } - public function testThrowIfLoaderNotRegisteredForGivenFilterOnFind() + public function testThrowIfLoaderNotRegisteredForGivenFilterOnFind(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Could not find data loader "" for "thumbnail" filter type'); @@ -250,7 +249,7 @@ public function testThrowIfLoaderNotRegisteredForGivenFilterOnFind() $dataManager->find('thumbnail', 'cats.jpeg'); } - public function testShouldReturnBinaryWithLoaderContentAndGuessedMimeTypeOnFind() + public function testShouldReturnBinaryWithLoaderContentAndGuessedMimeTypeOnFind(): void { $expectedContent = 'theImageBinaryContent'; $expectedMimeType = 'image/png'; @@ -289,7 +288,7 @@ public function testShouldReturnBinaryWithLoaderContentAndGuessedMimeTypeOnFind( $this->assertSame($expectedMimeType, $binary->getMimeType()); } - public function testShouldReturnBinaryWithLoaderContentAndGuessedFormatOnFind() + public function testShouldReturnBinaryWithLoaderContentAndGuessedFormatOnFind(): void { $content = 'theImageBinaryContent'; $mimeType = 'image/png'; @@ -344,7 +343,7 @@ public function testShouldReturnBinaryWithLoaderContentAndGuessedFormatOnFind() $this->assertSame($expectedFormat, $binary->getFormat()); } - public function testUseDefaultGlobalImageUsedIfImageNotFound() + public function testUseDefaultGlobalImageUsedIfImageNotFound(): void { $loader = $this->createBinaryLoaderInterfaceMock(); @@ -370,7 +369,7 @@ public function testUseDefaultGlobalImageUsedIfImageNotFound() $this->assertSame($defaultImage, $defaultGlobalImage); } - public function testUseDefaultFilterImageUsedIfImageNotFound() + public function testUseDefaultFilterImageUsedIfImageNotFound(): void { $loader = $this->createBinaryLoaderInterfaceMock(); diff --git a/Tests/Imagine/Filter/FilterConfigurationTest.php b/Tests/Imagine/Filter/FilterConfigurationTest.php index c4d9ca755..9ab8fcd58 100644 --- a/Tests/Imagine/Filter/FilterConfigurationTest.php +++ b/Tests/Imagine/Filter/FilterConfigurationTest.php @@ -19,7 +19,7 @@ */ class FilterConfigurationTest extends AbstractTest { - public function testSetAndGetFilter() + public function testSetAndGetFilter(): void { $config = [ 'filters' => [ @@ -37,7 +37,7 @@ public function testSetAndGetFilter() $this->assertSame($config, $filterConfiguration->get('profile_photo')); } - public function testReturnAllFilters() + public function testReturnAllFilters(): void { $filterConfiguration = new FilterConfiguration(); $filterConfiguration->set('foo', ['fooConfig']); @@ -45,7 +45,7 @@ public function testReturnAllFilters() $filters = $filterConfiguration->all(); - $this->assertInternalType('array', $filters); + $this->assertIsArray($filters); $this->assertArrayHasKey('foo', $filters); $this->assertSame(['fooConfig'], $filters['foo']); @@ -54,7 +54,7 @@ public function testReturnAllFilters() $this->assertSame(['barConfig'], $filters['bar']); } - public function testGetUndefinedFilter() + public function testGetUndefinedFilter(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Could not find configuration for a filter: thumbnail'); @@ -63,7 +63,7 @@ public function testGetUndefinedFilter() $filterConfiguration->get('thumbnail'); } - public function testShouldGetSameConfigSetBefore() + public function testShouldGetSameConfigSetBefore(): void { $config = [ 'quality' => 85, @@ -83,14 +83,14 @@ public function testShouldGetSameConfigSetBefore() $this->assertSame($config, $filterConfiguration->get('profile_photo')); } - public function testGetConfigSetViaConstructor() + public function testGetConfigSetViaConstructor(): void { $filterConfiguration = new FilterConfiguration([ 'profile_photo' => [], 'thumbnail' => [], ]); - $this->assertInternalType('array', $filterConfiguration->get('profile_photo')); - $this->assertInternalType('array', $filterConfiguration->get('thumbnail')); + $this->assertIsArray($filterConfiguration->get('profile_photo')); + $this->assertIsArray($filterConfiguration->get('thumbnail')); } } diff --git a/Tests/Imagine/Filter/FilterManagerTest.php b/Tests/Imagine/Filter/FilterManagerTest.php index 608c91d2d..257bae1d9 100644 --- a/Tests/Imagine/Filter/FilterManagerTest.php +++ b/Tests/Imagine/Filter/FilterManagerTest.php @@ -16,13 +16,14 @@ use Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface; use Liip\ImagineBundle\Model\Binary; use Liip\ImagineBundle\Tests\AbstractTest; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers \Liip\ImagineBundle\Imagine\Filter\FilterManager */ class FilterManagerTest extends AbstractTest { - public function testThrowsIfNoLoadersAddedForFilterOnApplyFilter() + public function testThrowsIfNoLoadersAddedForFilterOnApplyFilter(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Could not find filter(s): "thumbnail"'); @@ -53,7 +54,7 @@ public function testThrowsIfNoLoadersAddedForFilterOnApplyFilter() $filterManager->applyFilter($binary, 'thumbnail'); } - public function testReturnFilteredBinaryWithExpectedContentOnApplyFilter() + public function testReturnFilteredBinaryWithExpectedContentOnApplyFilter(): void { $originalContent = 'aOriginalContent'; $expectedFilteredContent = 'theFilteredContent'; @@ -110,7 +111,7 @@ public function testReturnFilteredBinaryWithExpectedContentOnApplyFilter() $this->assertSame($expectedFilteredContent, $filteredBinary->getContent()); } - public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApplyFilter() + public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApplyFilter(): void { $originalContent = 'aOriginalContent'; $expectedFormat = 'png'; @@ -166,7 +167,7 @@ public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApplyFilter( $this->assertSame($expectedFormat, $filteredBinary->getFormat()); } - public function testReturnFilteredBinaryWithCustomFormatIfSetOnApplyFilter() + public function testReturnFilteredBinaryWithCustomFormatIfSetOnApplyFilter(): void { $originalContent = 'aOriginalContent'; $originalFormat = 'png'; @@ -224,7 +225,7 @@ public function testReturnFilteredBinaryWithCustomFormatIfSetOnApplyFilter() $this->assertSame($expectedFormat, $filteredBinary->getFormat()); } - public function testReturnFilteredBinaryWithMimeTypeOfOriginalBinaryOnApplyFilter() + public function testReturnFilteredBinaryWithMimeTypeOfOriginalBinaryOnApplyFilter(): void { $originalContent = 'aOriginalContent'; $expectedMimeType = 'image/png'; @@ -285,7 +286,7 @@ public function testReturnFilteredBinaryWithMimeTypeOfOriginalBinaryOnApplyFilte $this->assertSame($expectedMimeType, $filteredBinary->getMimeType()); } - public function testReturnFilteredBinaryWithMimeTypeOfCustomFormatIfSetOnApplyFilter() + public function testReturnFilteredBinaryWithMimeTypeOfCustomFormatIfSetOnApplyFilter(): void { $originalContent = 'aOriginalContent'; $originalMimeType = 'image/png'; @@ -351,7 +352,7 @@ public function testReturnFilteredBinaryWithMimeTypeOfCustomFormatIfSetOnApplyFi $this->assertSame($expectedMimeType, $filteredBinary->getMimeType()); } - public function testAltersQualityOnApplyFilter() + public function testAltersQualityOnApplyFilter(): void { $originalContent = 'aOriginalContent'; $expectedQuality = 80; @@ -406,7 +407,7 @@ public function testAltersQualityOnApplyFilter() $this->assertInstanceOf(Binary::class, $filterManager->applyFilter($binary, 'thumbnail')); } - public function testAlters100QualityIfNotSetOnApplyFilter() + public function testAlters100QualityIfNotSetOnApplyFilter(): void { $originalContent = 'aOriginalContent'; $expectedQuality = 100; @@ -460,7 +461,7 @@ public function testAlters100QualityIfNotSetOnApplyFilter() $this->assertInstanceOf(Binary::class, $filterManager->applyFilter($binary, 'thumbnail')); } - public function testMergeRuntimeConfigWithOneFromFilterConfigurationOnApplyFilter() + public function testMergeRuntimeConfigWithOneFromFilterConfigurationOnApplyFilter(): void { $binary = new Binary('aContent', 'image/png', 'png'); @@ -527,7 +528,7 @@ public function testMergeRuntimeConfigWithOneFromFilterConfigurationOnApplyFilte ); } - public function testThrowsIfNoLoadersAddedForFilterOnApply() + public function testThrowsIfNoLoadersAddedForFilterOnApply(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Could not find filter(s): "thumbnail"'); @@ -550,7 +551,7 @@ public function testThrowsIfNoLoadersAddedForFilterOnApply() ]); } - public function testReturnFilteredBinaryWithExpectedContentOnApply() + public function testReturnFilteredBinaryWithExpectedContentOnApply(): void { $originalContent = 'aOriginalContent'; $expectedFilteredContent = 'theFilteredContent'; @@ -600,7 +601,7 @@ public function testReturnFilteredBinaryWithExpectedContentOnApply() $this->assertSame($expectedFilteredContent, $filteredBinary->getContent()); } - public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApply() + public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApply(): void { $originalContent = 'aOriginalContent'; $expectedFormat = 'png'; @@ -649,7 +650,7 @@ public function testReturnFilteredBinaryWithFormatOfOriginalBinaryOnApply() $this->assertSame($expectedFormat, $filteredBinary->getFormat()); } - public function testReturnFilteredBinaryWithCustomFormatIfSetOnApply() + public function testReturnFilteredBinaryWithCustomFormatIfSetOnApply(): void { $originalContent = 'aOriginalContent'; $originalFormat = 'png'; @@ -700,7 +701,7 @@ public function testReturnFilteredBinaryWithCustomFormatIfSetOnApply() $this->assertSame($expectedFormat, $filteredBinary->getFormat()); } - public function testReturnFilteredBinaryWithMimeTypeOfOriginalBinaryOnApply() + public function testReturnFilteredBinaryWithMimeTypeOfOriginalBinaryOnApply(): void { $originalContent = 'aOriginalContent'; $expectedMimeType = 'image/png'; @@ -754,7 +755,7 @@ public function testReturnFilteredBinaryWithMimeTypeOfOriginalBinaryOnApply() $this->assertSame($expectedMimeType, $filteredBinary->getMimeType()); } - public function testReturnFilteredBinaryWithMimeTypeOfCustomFormatIfSetOnApply() + public function testReturnFilteredBinaryWithMimeTypeOfCustomFormatIfSetOnApply(): void { $originalContent = 'aOriginalContent'; $originalMimeType = 'image/png'; @@ -813,7 +814,7 @@ public function testReturnFilteredBinaryWithMimeTypeOfCustomFormatIfSetOnApply() $this->assertSame($expectedMimeType, $filteredBinary->getMimeType()); } - public function testAltersQualityOnApply() + public function testAltersQualityOnApply(): void { $originalContent = 'aOriginalContent'; $expectedQuality = 80; @@ -863,7 +864,7 @@ public function testAltersQualityOnApply() $this->assertInstanceOf(Binary::class, $filteredBinary); } - public function testAlters100QualityIfNotSetOnApply() + public function testAlters100QualityIfNotSetOnApply(): void { $originalContent = 'aOriginalContent'; $expectedQuality = 100; @@ -912,7 +913,7 @@ public function testAlters100QualityIfNotSetOnApply() $this->assertInstanceOf(Binary::class, $filteredBinary); } - public function testApplyPostProcessor() + public function testApplyPostProcessor(): void { $originalContent = 'aContent'; $expectedPostProcessedContent = 'postProcessedContent'; @@ -984,7 +985,7 @@ public function testApplyPostProcessor() $this->assertSame($expectedPostProcessedContent, $filteredBinary->getContent()); } - public function testThrowsIfNoPostProcessorAddedForFilterOnApplyFilter() + public function testThrowsIfNoPostProcessorAddedForFilterOnApplyFilter(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Could not find post processor(s): "foo"'); @@ -1046,7 +1047,7 @@ public function testThrowsIfNoPostProcessorAddedForFilterOnApplyFilter() $filterManager->applyFilter($binary, 'thumbnail'); } - public function testApplyPostProcessorsWhenNotDefined() + public function testApplyPostProcessorsWhenNotDefined(): void { $binary = $this->getMockBuilder(BinaryInterface::class)->getMock(); $filterManager = new FilterManager( @@ -1059,7 +1060,7 @@ public function testApplyPostProcessorsWhenNotDefined() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|LoaderInterface + * @return MockObject|LoaderInterface */ protected function createFilterLoaderInterfaceMock() { diff --git a/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php index 7b1ca5b0a..f1187cb0d 100644 --- a/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php @@ -25,10 +25,8 @@ public function testUseAutorotateFromImagine(): void $image = $this->getImageInterfaceMock(); $image->expects($this->once()) - ->method('metadata') - ; + ->method('metadata'); $loader->load($image); - } } diff --git a/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php index b949e1729..716181e76 100644 --- a/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php @@ -31,7 +31,7 @@ class CropFilterLoaderTest extends AbstractTest * * @dataProvider cropDataProvider */ - public function testLoad($coordinates, $area) + public function testLoad(array $coordinates, array $area): void { $x = $coordinates[0]; $y = $coordinates[1]; @@ -57,7 +57,7 @@ public function testLoad($coordinates, $area) /** * @returns array Array containing coordinate and width/height pairs. */ - public function cropDataProvider() + public function cropDataProvider(): array { return [ [[140, 130], [200, 129]], diff --git a/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php index 3dcd610e6..f4cd6e3b7 100644 --- a/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php @@ -28,7 +28,7 @@ class DownscaleFilterLoaderTest extends AbstractTest * @param Box $resultSize * @param Box $initialSize */ - public function testDontScaleUp($resultSize, $initialSize) + public function testDontScaleUp($resultSize, $initialSize): void { $this->assertLessThanOrEqual($initialSize->getHeight(), $resultSize->getHeight()); $this->assertLessThanOrEqual($initialSize->getWidth(), $resultSize->getWidth()); @@ -39,7 +39,7 @@ public function testDontScaleUp($resultSize, $initialSize) * * @param Box $resultSize */ - public function testFitBoundingBox($resultSize) + public function testFitBoundingBox($resultSize): void { $this->assertLessThanOrEqual(100, $resultSize->getHeight()); $this->assertLessThanOrEqual(90, $resultSize->getWidth()); diff --git a/Tests/Imagine/Filter/Loader/FixedFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/FixedFilterLoaderTest.php index 9fc1f8c0f..bd4e083ca 100644 --- a/Tests/Imagine/Filter/Loader/FixedFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/FixedFilterLoaderTest.php @@ -32,15 +32,11 @@ class FixedFilterLoaderTest extends AbstractTest const DUMMY_IMAGE_HEIGHT = 600; /** - * @param int $width - * @param int $height - * @param Box $expected - * * @covers \Liip\ImagineBundle\Imagine\Filter\Loader\FixedFilterLoader::load * * @dataProvider heightWidthProvider */ - public function testLoad($width, $height, $expected) + public function testLoad(int $width, int $height, Box $expected): void { $loader = new FixedFilterLoader(); @@ -74,13 +70,10 @@ public function testLoad($width, $height, $expected) $options['width'] = $width; $options['height'] = $height; - $result = $loader->load($image, $options); + $loader->load($image, $options); } - /** - * @returns array Array containing width/height pairs and an expected size. - */ - public function heightWidthProvider() + public function heightWidthProvider(): array { return [ [200, 129, new Box(200, 129)], diff --git a/Tests/Imagine/Filter/Loader/FlipFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/FlipFilterLoaderTest.php index cd1b8574c..93b7c6e7d 100644 --- a/Tests/Imagine/Filter/Loader/FlipFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/FlipFilterLoaderTest.php @@ -19,10 +19,7 @@ */ class FlipFilterLoaderTest extends AbstractTest { - /** - * @return array - */ - public static function provideLoadWithAxisXOptionData() + public static function provideLoadWithAxisXOptionData(): array { return [ ['x'], @@ -31,11 +28,9 @@ public static function provideLoadWithAxisXOptionData() } /** - * @param string $axis - * * @dataProvider provideLoadWithAxisXOptionData */ - public function testLoadWithAxisXOption($axis) + public function testLoadWithAxisXOption(string $axis): void { $image = $this->getImageInterfaceMock(); $image->expects($this->once()) @@ -45,10 +40,7 @@ public function testLoadWithAxisXOption($axis) $this->createFlipFilterLoaderInstance()->load($image, ['axis' => $axis]); } - /** - * @return array - */ - public static function provideLoadWithAxisYOptionData() + public static function provideLoadWithAxisYOptionData(): array { return [ ['y'], @@ -57,11 +49,9 @@ public static function provideLoadWithAxisYOptionData() } /** - * @param string $axis - * * @dataProvider provideLoadWithAxisYOptionData */ - public function testLoadWithAxisYOption($axis) + public function testLoadWithAxisYOption(string $axis): void { $image = $this->getImageInterfaceMock(); $image->expects($this->once()) @@ -71,7 +61,7 @@ public function testLoadWithAxisYOption($axis) $this->createFlipFilterLoaderInstance()->load($image, ['axis' => $axis]); } - public function testThrowsOnInvalidOptions() + public function testThrowsOnInvalidOptions(): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('The "axis" option must be set to "x", "horizontal", "y", or "vertical".'); @@ -82,10 +72,7 @@ public function testThrowsOnInvalidOptions() ]); } - /** - * @return FlipFilterLoader - */ - private function createFlipFilterLoaderInstance() + private function createFlipFilterLoaderInstance(): FlipFilterLoader { return new FlipFilterLoader(); } diff --git a/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundDownscaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundDownscaleFilterLoaderTest.php index 14798c627..aeaed327b 100644 --- a/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundDownscaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundDownscaleFilterLoaderTest.php @@ -24,7 +24,7 @@ */ class FloatToIntCastByRoundDownscaleFilterLoaderTest extends AbstractTest { - public function testLoad() + public function testLoad(): void { $loader = new DownscaleFilterLoader(); $imagine = new Imagine(); diff --git a/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundUpscaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundUpscaleFilterLoaderTest.php index ebfb568ff..fdbd41756 100644 --- a/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundUpscaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/FloatToIntCastByRoundUpscaleFilterLoaderTest.php @@ -24,7 +24,7 @@ */ class FloatToIntCastByRoundUpscaleFilterLoaderTest extends AbstractTest { - public function testLoad() + public function testLoad(): void { $loader = new UpscaleFilterLoader(); $imagine = new Imagine(); diff --git a/Tests/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php index 143851819..3f9036538 100644 --- a/Tests/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/GrayscaleFilterLoaderTest.php @@ -25,7 +25,7 @@ */ class GrayscaleFilterLoaderTest extends AbstractTest { - public function testLoadGrayscale() + public function testLoadGrayscale(): void { $loader = new GrayscaleFilterLoader(); $palette = new RGB(); diff --git a/Tests/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php index 94f63f728..c734c1131 100644 --- a/Tests/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/InterlaceFilterLoaderTest.php @@ -20,7 +20,7 @@ */ class InterlaceFilterLoaderTest extends AbstractTest { - public function testLoad() + public function testLoad(): void { $loader = new InterlaceFilterLoader(); diff --git a/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php index 5355e30ed..202c3fc9a 100644 --- a/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php @@ -34,15 +34,11 @@ class PasteFilterLoaderTest extends AbstractTest const DUMMY_IMAGE_HEIGHT = 600; /** - * @param int $x - * @param int $y - * @param Point $expected - * * @covers \Liip\ImagineBundle\Imagine\Filter\Loader\PasteFilterLoader::load * * @dataProvider pasteProvider */ - public function testLoad($x, $y, $expected) + public function testLoad(int $x, int $y, Point $expected): void { $mockImageSize = new Box( self::DUMMY_IMAGE_WIDTH, @@ -69,10 +65,7 @@ public function testLoad($x, $y, $expected) $loader->load($image, $options); } - /** - * @returns array Array containing coordinates to paste. - */ - public function pasteProvider() + public function pasteProvider(): array { return [ [200, 129, new Point(200, 129)], diff --git a/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php index 47b134e54..c82146e93 100644 --- a/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ResampleFilterLoaderTest.php @@ -28,7 +28,7 @@ class ResampleFilterLoaderTest extends AbstractTest * @param string $imgPath * @param float $resolution */ - public function testResample($imgPath, $resolution) + public function testResample($imgPath, $resolution): void { $imgType = static::getSupportedDriver(); $tmpPath = sys_get_temp_dir().DIRECTORY_SEPARATOR.sprintf('liip-imagine-bundle-test-%s-%d.%s', md5($imgPath), time(), pathinfo($imgPath, PATHINFO_EXTENSION)); @@ -50,7 +50,7 @@ public function testResample($imgPath, $resolution) /** * @return array[] */ - public static function provideResampleData() + public static function provideResampleData(): array { $paths = [ realpath(__DIR__.'/../../../Fixtures/assets/cats.png'), @@ -73,10 +73,7 @@ public static function provideResampleData() return $data; } - /** - * @return array - */ - public static function provideOptionsData() + public static function provideOptionsData(): array { return [ [['x' => 500, 'y' => 500, 'unit' => 'ppi']], @@ -89,11 +86,9 @@ public static function provideOptionsData() } /** - * @param array $options - * * @dataProvider provideOptionsData */ - public function testOptions(array $options) + public function testOptions(array $options): void { $image = $this->getImageInterfaceMock(); $image->expects($this->once()) @@ -108,10 +103,7 @@ public function testOptions(array $options) $this->createResampleFilterLoaderInstance($imagine)->load($image, $options); } - /** - * @return array - */ - public static function provideInvalidOptionsData() + public static function provideInvalidOptionsData(): array { return [ [[]], @@ -136,7 +128,7 @@ public static function provideInvalidOptionsData() /** * @dataProvider provideInvalidOptionsData */ - public function testThrowsOnInvalidOptions(array $options) + public function testThrowsOnInvalidOptions(array $options): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid option(s) passed to Liip\\ImagineBundle\\Imagine\\Filter\\Loader\\ResampleFilterLoader::load().'); @@ -145,7 +137,7 @@ public function testThrowsOnInvalidOptions(array $options) $loader->load($this->getImageInterfaceMock(), $options); } - public function testThrowsOnInvalidFilterOption() + public function testThrowsOnInvalidFilterOption(): void { $this->expectException(\Liip\ImagineBundle\Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid value for "filter" option: must be a valid constant resolvable using one of formats "\\Imagine\\Image\\ImageInterface::FILTER_%s", "\\Imagine\\Image\\ImageInterface::%s", or "%s".'); @@ -159,7 +151,7 @@ public function testThrowsOnInvalidFilterOption() ]); } - public function testThrowsOnInvalidTemporaryPathOption() + public function testThrowsOnInvalidTemporaryPathOption(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessageRegExp('{Unable to create temporary file in ".+" base path.}'); @@ -173,7 +165,7 @@ public function testThrowsOnInvalidTemporaryPathOption() ]); } - public function testThrowsOnSaveOrOpenError() + public function testThrowsOnSaveOrOpenError(): void { $this->expectException(\Liip\ImagineBundle\Exception\Imagine\Filter\LoadFilterException::class); @@ -185,24 +177,18 @@ public function testThrowsOnSaveOrOpenError() $this->createResampleFilterLoaderInstance()->load($image, ['x' => 120, 'y' => 120, 'unit' => 'ppi']); } - /** - * @param ImagineInterface $imagine - * - * @return ResampleFilterLoader - */ - private function createResampleFilterLoaderInstance(ImagineInterface $imagine = null) + private function createResampleFilterLoaderInstance(ImagineInterface $imagine = null): ResampleFilterLoader { return new ResampleFilterLoader($imagine ?: $this->createImagineInterfaceMock()); } - /** - * @return string - */ - private static function getSupportedDriver() + private static function getSupportedDriver(): string { - if (class_exists('\Imagick')) { + if (class_exists(\Imagick::class)) { return 'imagick'; - } elseif (class_exists('\Gmagick')) { + } + + if (class_exists(\Gmagick::class)) { return 'gmagick'; } @@ -224,13 +210,7 @@ private function getImagineInstance($driver) } } - /** - * @param string $driver - * @param string $file - * - * @return float[] - */ - private function getImageResolution($driver, $file) + private function getImageResolution(string $driver, string $file): array { switch ($driver) { case 'imagick': diff --git a/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php index f2c511228..4a1496a4d 100644 --- a/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php @@ -23,14 +23,11 @@ class ResizeFilterLoaderTest extends AbstractTest { /** - * @param int $width - * @param int $height - * * @covers \Liip\ImagineBundle\Imagine\Filter\Loader\ResizeFilterLoader::load * * @dataProvider resizeDataProvider */ - public function testLoad($width, $height) + public function testLoad(int $width, int $height): void { $loader = new ResizeFilterLoader(); @@ -46,10 +43,7 @@ public function testLoad($width, $height) $loader->load($image, $options); } - /** - * @returns array Array containing width/height pairs. - */ - public function resizeDataProvider() + public function resizeDataProvider(): array { return [ [140, 130], diff --git a/Tests/Imagine/Filter/Loader/RotateFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/RotateFilterLoaderTest.php index 472b74af5..6917cadf2 100644 --- a/Tests/Imagine/Filter/Loader/RotateFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/RotateFilterLoaderTest.php @@ -21,7 +21,7 @@ */ class RotateFilterLoaderTest extends AbstractTest { - public function testLoadRotate0Degrees() + public function testLoadRotate0Degrees(): void { $loader = new RotateFilterLoader(); @@ -31,7 +31,7 @@ public function testLoadRotate0Degrees() $this->assertSame($image, $result); } - public function testLoadRotate90Degrees() + public function testLoadRotate90Degrees(): void { $loader = new RotateFilterLoader(); diff --git a/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php index 043e48249..ec2cd5836 100644 --- a/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php @@ -46,7 +46,7 @@ class ScaleFilterLoaderTest extends AbstractTest /** * @covers \Liip\ImagineBundle\Imagine\Filter\Loader\ScaleFilterLoader::load */ - public function testItShouldPreserveRatio() + public function testItShouldPreserveRatio(): void { $loader = new ScaleFilterLoader(); $image = $this->getImageInterfaceMock(); @@ -71,7 +71,7 @@ public function testItShouldPreserveRatio() * @param int[] $dimensions * @param Box $expected */ - public function testItShouldUseDimensions($dimensions, $expected) + public function testItShouldUseDimensions($dimensions, $expected): void { $loader = new ScaleFilterLoader(); @@ -91,7 +91,7 @@ public function testItShouldUseDimensions($dimensions, $expected) /** * @covers \Liip\ImagineBundle\Imagine\Filter\Loader\ScaleFilterLoader::load */ - public function itShouldThrowInvalidArgumentException() + public function itShouldThrowInvalidArgumentException(): void { $this->expectException(\InvalidArgumentException::class); @@ -99,10 +99,7 @@ public function itShouldThrowInvalidArgumentException() $scale->load($this->getImageInterfaceMock(), []); } - /** - * @returns array Array containing coordinate and width/height pairs. - */ - public function dimensionsDataProvider() + public function dimensionsDataProvider(): array { return [ [[150, 150], new Box(125, 150)], @@ -117,7 +114,7 @@ public function dimensionsDataProvider() * @param int[] $dimensions * @param Box $expected */ - public function testShouldScale($dimensions, $expected) + public function testShouldScale($dimensions, $expected): void { $loader = new UpscaleFilterLoader(); $image = $this->getUpscaleMockImage(); @@ -133,10 +130,7 @@ public function testShouldScale($dimensions, $expected) $loader->load($image, $options); } - /** - * @returns array Array containing coordinate and width/height pairs. - */ - public function minScaleDataProvider() + public function minScaleDataProvider(): array { return [ [[1000, 600], new Box(1000, 667)], @@ -150,7 +144,7 @@ public function minScaleDataProvider() * @param int[] $dimensions * @param Box $expected */ - public function testShouldNotScale($dimensions, $expected) + public function testShouldNotScale($dimensions, $expected): void { $loader = new UpscaleFilterLoader(); $image = $this->getUpscaleMockImage(); @@ -166,10 +160,7 @@ public function testShouldNotScale($dimensions, $expected) $loader->load($image, $options); } - /** - * @returns array Array containing coordinate and width/height pairs. - */ - public function minNotScaleDataProvider() + public function minNotScaleDataProvider(): array { return [ [[300, 200], new Box(600, 400)], diff --git a/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php index 5dbe0daa5..7305ce7fc 100644 --- a/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php @@ -33,15 +33,11 @@ class ThumbnailFilterLoaderTest extends AbstractTest const DUMMY_IMAGE_HEIGHT = 600; /** - * @param int $width - * @param int $height - * @param Box $expected - * * @covers \Liip\ImagineBundle\Imagine\Filter\Loader\ThumbnailFilterLoader::load * * @dataProvider heightWidthProvider */ - public function testLoad($width, $height, $expected) + public function testLoad(?int $width, ?int $height, Box $expected): void { $loader = new ThumbnailFilterLoader(); @@ -64,10 +60,7 @@ public function testLoad($width, $height, $expected) $loader->load($image, $options); } - /** - * @returns array Array containing width/height pairs and an expected size. - */ - public function heightWidthProvider() + public function heightWidthProvider(): array { return [ [200, 129, new Box(200, 129)], diff --git a/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php b/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php index 32ecfbde3..545c0a6c2 100644 --- a/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php +++ b/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTest.php @@ -139,12 +139,10 @@ public function testIsValidReturn(array $validReturns, array $errorString, bool ->getMock(); $process - ->expects($this->any()) ->method('getExitCode') ->willReturn(0); $process - ->expects($this->any()) ->method('getOutput') ->willReturn('foo bar baz'); @@ -157,7 +155,7 @@ public function testIsValidReturn(array $validReturns, array $errorString, bool protected function getPostProcessorInstance(array $parameters = []): PostProcessorInterface { - if (0 === count($parameters)) { + if (0 === \count($parameters)) { $parameters = [static::getPostProcessAsStdInExecutable()]; } diff --git a/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTestCase.php b/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTestCase.php index e8ee715d4..414f600ab 100644 --- a/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTestCase.php +++ b/Tests/Imagine/Filter/PostProcessor/AbstractPostProcessorTestCase.php @@ -48,11 +48,11 @@ protected function getBinaryInterfaceMock(): BinaryInterface protected function assertTemporaryFile(string $content, string $file, string $context, array $options = []): void { $this->assertFileExists($file); - $this->assertContains($context, $file); + $this->assertStringContainsString($context, $file); $this->assertSame($content, file_get_contents($file)); if (isset($options['temp_dir'])) { - $this->assertContains($options['temp_dir'], $file); + $this->assertStringContainsString($options['temp_dir'], $file); } } diff --git a/Tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php b/Tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php index c13d5ec6c..1caf9e696 100644 --- a/Tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php +++ b/Tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php @@ -149,8 +149,8 @@ public function testProcess(string $content, array $options, string $expected): $process = $this->getPostProcessorInstance(); $result = $process->process(new FileBinary($file, 'image/jpeg', 'jpeg'), $options); - $this->assertContains($expected, $result->getContent()); - $this->assertContains($content, $result->getContent()); + $this->assertStringContainsString($expected, $result->getContent()); + $this->assertStringContainsString($content, $result->getContent()); @unlink($file); } diff --git a/Tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php b/Tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php index 9bb74bc35..3393cc44d 100644 --- a/Tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php +++ b/Tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php @@ -88,8 +88,8 @@ public function testProcess(string $content, array $options, string $expected): $process = $this->getPostProcessorInstance(); $result = $process->process(new FileBinary($file, 'image/jpeg', 'jpeg'), $options); - $this->assertContains($expected, $result->getContent()); - $this->assertContains($content, $result->getContent()); + $this->assertStringContainsString($expected, $result->getContent()); + $this->assertStringContainsString($content, $result->getContent()); @unlink($file); } @@ -119,6 +119,6 @@ public function testProcessWithNonSupportedMimeType(): void protected function getPostProcessorInstance(array $parameters = []): MozJpegPostProcessor { - return new MozJpegPostProcessor($parameters[0] ?? static::getPostProcessAsStdinExecutable()); + return new MozJpegPostProcessor($parameters[0] ?? static::getPostProcessAsStdInExecutable()); } } diff --git a/Tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php b/Tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php index 45aa2ecf0..d1cc817a3 100644 --- a/Tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php +++ b/Tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php @@ -131,7 +131,7 @@ public static function provideProcessData(): array /** * @dataProvider provideProcessData */ - public function testProcess(string $content, array $options, string $expected) + public function testProcess(string $content, array $options, string $expected): void { $file = sys_get_temp_dir().'/test.png'; file_put_contents($file, $content); @@ -139,8 +139,8 @@ public function testProcess(string $content, array $options, string $expected) $process = $this->getPostProcessorInstance(); $result = $process->process(new FileBinary($file, 'image/png', 'png'), $options); - $this->assertContains($expected, $result->getContent()); - $this->assertContains($content, $result->getContent()); + $this->assertStringContainsString($expected, $result->getContent()); + $this->assertStringContainsString($content, $result->getContent()); @unlink($file); } diff --git a/Tests/LiipImagineBundleTest.php b/Tests/LiipImagineBundleTest.php index 49cabb3e5..25a84559e 100644 --- a/Tests/LiipImagineBundleTest.php +++ b/Tests/LiipImagineBundleTest.php @@ -24,6 +24,7 @@ use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory; use Liip\ImagineBundle\DependencyInjection\LiipImagineExtension; use Liip\ImagineBundle\LiipImagineBundle; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -32,12 +33,12 @@ */ class LiipImagineBundleTest extends AbstractTest { - public function testSubClassOfBundle() + public function testSubClassOfBundle(): void { $this->assertInstanceOf(Bundle::class, new LiipImagineBundle()); } - public function testAddLoadersCompilerPassOnBuild() + public function testAddLoadersCompilerPassOnBuild(): void { $containerMock = $this->createContainerBuilderMock(); $containerMock @@ -54,7 +55,7 @@ public function testAddLoadersCompilerPassOnBuild() $bundle->build($containerMock); } - public function testAddFiltersCompilerPassOnBuild() + public function testAddFiltersCompilerPassOnBuild(): void { $containerMock = $this->createContainerBuilderMock(); $containerMock @@ -71,7 +72,7 @@ public function testAddFiltersCompilerPassOnBuild() $bundle->build($containerMock); } - public function testAddPostProcessorsCompilerPassOnBuild() + public function testAddPostProcessorsCompilerPassOnBuild(): void { $containerMock = $this->createContainerBuilderMock(); $containerMock @@ -88,7 +89,7 @@ public function testAddPostProcessorsCompilerPassOnBuild() $bundle->build($containerMock); } - public function testAddResolversCompilerPassOnBuild() + public function testAddResolversCompilerPassOnBuild(): void { $containerMock = $this->createContainerBuilderMock(); $containerMock @@ -105,7 +106,7 @@ public function testAddResolversCompilerPassOnBuild() $bundle->build($containerMock); } - public function testAddWebPathResolverFactoryOnBuild() + public function testAddWebPathResolverFactoryOnBuild(): void { $extensionMock = $this->createLiipImagineExtensionMock(); $extensionMock @@ -124,7 +125,7 @@ public function testAddWebPathResolverFactoryOnBuild() $bundle->build($containerMock); } - public function testAddAwsS3ResolverFactoryOnBuild() + public function testAddAwsS3ResolverFactoryOnBuild(): void { $extensionMock = $this->createLiipImagineExtensionMock(); $extensionMock @@ -143,7 +144,7 @@ public function testAddAwsS3ResolverFactoryOnBuild() $bundle->build($containerMock); } - public function testAddFlysystemResolverFactoryOnBuild() + public function testAddFlysystemResolverFactoryOnBuild(): void { $extensionMock = $this->createLiipImagineExtensionMock(); $extensionMock @@ -162,7 +163,7 @@ public function testAddFlysystemResolverFactoryOnBuild() $bundle->build($containerMock); } - public function testAddChainLoaderFactoryOnBuild() + public function testAddChainLoaderFactoryOnBuild(): void { $extensionMock = $this->createLiipImagineExtensionMock(); $extensionMock @@ -179,7 +180,7 @@ public function testAddChainLoaderFactoryOnBuild() $bundle->build($containerMock); } - public function testAddStreamLoaderFactoryOnBuild() + public function testAddStreamLoaderFactoryOnBuild(): void { $extensionMock = $this->createLiipImagineExtensionMock(); $extensionMock @@ -198,7 +199,7 @@ public function testAddStreamLoaderFactoryOnBuild() $bundle->build($containerMock); } - public function testAddFilesystemLoaderFactoryOnBuild() + public function testAddFilesystemLoaderFactoryOnBuild(): void { $extensionMock = $this->createLiipImagineExtensionMock(); $extensionMock @@ -217,7 +218,7 @@ public function testAddFilesystemLoaderFactoryOnBuild() $bundle->build($containerMock); } - public function testAddFlysystemLoaderFactoryOnBuild() + public function testAddFlysystemLoaderFactoryOnBuild(): void { $extensionMock = $this->createLiipImagineExtensionMock(); $extensionMock @@ -237,7 +238,7 @@ public function testAddFlysystemLoaderFactoryOnBuild() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|ContainerBuilder + * @return MockObject|ContainerBuilder */ protected function createContainerBuilderMock() { @@ -245,7 +246,7 @@ protected function createContainerBuilderMock() } /** - * @return \PHPUnit_Framework_MockObject_MockObject|LiipImagineExtension + * @return MockObject|LiipImagineExtension */ protected function createLiipImagineExtensionMock() { diff --git a/Tests/Model/BinaryTest.php b/Tests/Model/BinaryTest.php index 69d643a82..7bb7526a6 100644 --- a/Tests/Model/BinaryTest.php +++ b/Tests/Model/BinaryTest.php @@ -11,6 +11,7 @@ namespace Liip\ImagineBundle\Tests\Model; +use Liip\ImagineBundle\Binary\BinaryInterface; use Liip\ImagineBundle\Model\Binary; use PHPUnit\Framework\TestCase; @@ -19,28 +20,28 @@ */ class BinaryTest extends TestCase { - public function testImplementsBinaryInterface() + public function testImplementsBinaryInterface(): void { $rc = new \ReflectionClass(Binary::class); - $this->assertTrue($rc->implementsInterface('\Liip\ImagineBundle\Binary\BinaryInterface')); + $this->assertTrue($rc->implementsInterface(BinaryInterface::class)); } - public function testAllowGetContentSetInConstructor() + public function testAllowGetContentSetInConstructor(): void { $image = new Binary('theContent', 'image/png', 'png'); $this->assertSame('theContent', $image->getContent()); } - public function testAllowGetMimeTypeSetInConstructor() + public function testAllowGetMimeTypeSetInConstructor(): void { $image = new Binary('aContent', 'image/png', 'png'); $this->assertSame('image/png', $image->getMimeType()); } - public function testAllowGetFormatSetInConstructor() + public function testAllowGetFormatSetInConstructor(): void { $image = new Binary('aContent', 'image/png', 'png'); diff --git a/Tests/Templating/AbstractFilterTest.php b/Tests/Templating/AbstractFilterTest.php index f27ccf210..634f90f12 100644 --- a/Tests/Templating/AbstractFilterTest.php +++ b/Tests/Templating/AbstractFilterTest.php @@ -18,17 +18,17 @@ abstract class AbstractFilterTest extends AbstractTest { - public function testCanBeConstructed() + public function testCanBeConstructed(): void { $this->createTemplatingMock(); } - public function testInvokeGetNameMethod() + public function testInvokeGetNameMethod(): void { $this->assertSame('liip_imagine', $this->createTemplatingMock()->getName()); } - public function testInvokeFilterMethod() + public function testInvokeFilterMethod(): void { $expectedFilter = 'thumbnail'; $expectedInputPath = 'thePathToTheImage'; @@ -45,8 +45,6 @@ public function testInvokeFilterMethod() } /** - * @param CacheManager|null $manager - * * @return FilterExtension|FilterHelper */ abstract protected function createTemplatingMock(CacheManager $manager = null); diff --git a/Tests/Templating/FilterExtensionTest.php b/Tests/Templating/FilterExtensionTest.php index 75e940459..aef304e85 100644 --- a/Tests/Templating/FilterExtensionTest.php +++ b/Tests/Templating/FilterExtensionTest.php @@ -21,22 +21,17 @@ */ class FilterExtensionTest extends AbstractFilterTest { - public function testAddsFilterMethodToFiltersList() + public function testAddsFilterMethodToFiltersList(): void { $this->assertCount(1, $this->createTemplatingMock()->getFilters()); } - public function testInstanceOfTwigFilter() + public function testInstanceOfTwigFilter(): void { $this->assertInstanceOf(AbstractExtension::class, $this->createTemplatingMock()); } - /** - * @param CacheManager|null $manager - * - * @return FilterExtension - */ - protected function createTemplatingMock(CacheManager $manager = null) + protected function createTemplatingMock(CacheManager $manager = null): FilterExtension { if (!class_exists(AbstractExtension::class)) { $this->markTestSkipped('Requires the twig/twig package.'); diff --git a/Tests/Templating/Helper/FilterHelperTest.php b/Tests/Templating/Helper/FilterHelperTest.php index 4ceefb0dd..17c6ba664 100644 --- a/Tests/Templating/Helper/FilterHelperTest.php +++ b/Tests/Templating/Helper/FilterHelperTest.php @@ -24,17 +24,12 @@ */ class FilterHelperTest extends AbstractFilterTest { - public function testInstanceOfSymfonyHelper() + public function testInstanceOfSymfonyHelper(): void { $this->assertInstanceOf(Helper::class, $this->createTemplatingMock()); } - /** - * @param CacheManager|null $manager - * - * @return FilterHelper - */ - protected function createTemplatingMock(CacheManager $manager = null) + protected function createTemplatingMock(CacheManager $manager = null): FilterHelper { $mock = new FilterHelper($manager ?: $this->createCacheManagerMock()); diff --git a/Tests/Utility/Framework/SymfonyFrameworkTest.php b/Tests/Utility/Framework/SymfonyFrameworkTest.php index a9321672a..a48c2837d 100644 --- a/Tests/Utility/Framework/SymfonyFrameworkTest.php +++ b/Tests/Utility/Framework/SymfonyFrameworkTest.php @@ -20,7 +20,7 @@ */ class SymfonyFrameworkTest extends TestCase { - public function testKernelComparisonForCurrentKernel() + public function testKernelComparisonForCurrentKernel(): void { $major = Kernel::MAJOR_VERSION; $minor = Kernel::MINOR_VERSION; @@ -29,13 +29,13 @@ public function testKernelComparisonForCurrentKernel() $this->assertFalse(SymfonyFramework::isKernelLessThan($major, $minor)); } - public function testIsKernelLessThan() + public function testIsKernelLessThan(): void { $this->assertTrue(SymfonyFramework::isKernelLessThan(100, 100, 100)); $this->assertFalse(SymfonyFramework::isKernelLessThan(1, 1, 1)); } - public function testGetContainerResolvableRootWebPath() + public function testGetContainerResolvableRootWebPath(): void { $path = SymfonyFramework::getContainerResolvableRootWebPath(); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index 7456f8da3..20bd5f6c7 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -23,7 +23,7 @@ } namespace Symfony\Component\ExpressionLanguage { - if (interface_exists('Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface')) { + if (interface_exists(ExpressionFunctionProviderInterface::class)) { return; } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3d00787ca..8360fd847 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,12 +2,11 @@