diff --git a/.coveralls.yml b/.coveralls.yml index 64422dd3d..568bbd99f 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,4 +1,3 @@ -service_name: travis-ci -src_dir: . -coverage_clover : var/build/clover.xml -json_path : var/build/coveralls-upload.json +service_name : travis-ci +coverage_clover: var/build/clover.xml +json_path : var/build/upload.json diff --git a/.travis.yml b/.travis.yml index 46bb4915c..0890c1a84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,27 @@ -sudo: false - language: php +sudo: false + cache: + directories: - $HOME/.composer/cache + env: + global: - SYMFONY_DEPRECATIONS_HELPER="weak_vendors" - ENABLE_CODE_COVERAGE="false" + - SIMPLE_PHPUNIT_FLAGS="-v" + matrix: + fast_finish: true + include: + - php: 7.1 - php: 7.1 env: @@ -28,10 +36,11 @@ matrix: - php: 7.2 env: - DEPENDENCIES="symfony/phpunit-bridge:^4" - - COMPOSER_UPDATE_OPTIONS="--no-dev" + - COMPOSER_UPDATE_FLAGS="--no-dev" - php: 7.2 env: - ENABLE_CODE_COVERAGE="true" + - SIMPLE_PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml" - php: 7.2 env: - SYMFONY_VERSION=dev-master @@ -40,28 +49,50 @@ matrix: env: - SYMFONY_VERSION=4.0.* - COMPOSER_FLAGS="--ignore-platform-reqs" + allow_failures: + - env: - ENABLE_CODE_COVERAGE="true" + - SIMPLE_PHPUNIT_FLAGS="-v --coverage-text --coverage-clover var/build/clover.xml" - env: - SYMFONY_VERSION=dev-master - STABILITY=dev - php: nightly + before_install: - - if [[ "$SYMFONY_VERSION" != "" ]]; then travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update $COMPOSER_FLAGS; fi; - - if [[ "$DEPENDENCIES" != "" ]]; then travis_retry composer require ${DEPENDENCIES} --no-update $COMPOSER_FLAGS; fi; - - if [[ "$STABILITY" != "" ]]; then composer config minimum-stability $STABILITY; fi - - if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then phpenv config-rm xdebug.ini || true; fi; - - if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then travis_retry composer require satooshi/php-coveralls:^1.0 --no-update $COMPOSER_FLAGS; fi; + + - if [[ "$SYMFONY_VERSION" != "" ]]; then + travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update $COMPOSER_FLAGS; + fi + - if [[ "$DEPENDENCIES" != "" ]]; then + travis_retry composer require $DEPENDENCIES --no-update $COMPOSER_FLAGS; + fi + - if [[ "$STABILITY" != "" ]]; then + travis_retry composer config minimum-stability $STABILITY; + fi + - if [[ "$ENABLE_CODE_COVERAGE" != "true" ]]; then + phpenv config-rm xdebug.ini || true; + fi + - if [[ "$ENABLE_CODE_COVERAGE" == "true" ]]; then + travis_retry composer require --dev satooshi/php-coveralls:^2.0@dev --no-update $COMPOSER_FLAGS; + fi + install: - - travis_retry composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS $COMPOSER_UPDATE_OPTIONS - - if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then travis_retry composer require --dev satooshi/php-coveralls; fi + + - travis_retry composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS $COMPOSER_UPDATE_FLAGS - ./vendor/bin/simple-phpunit install + script: - - if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then vendor/bin/simple-phpunit --coverage-text --coverage-clover build/logs/clover.xml; else vendor/bin/simple-phpunit -v; fi; + + - ./vendor/bin/simple-phpunit $SIMPLE_PHPUNIT_FLAGS + after_success: - - if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then php vendor/bin/coveralls -v --config .coveralls.yml; fi; + + - if [[ "$ENABLE_CODE_COVERAGE" == "true" ]]; then + ./vendor/bin/php-coveralls -vvv --config .coveralls.yml; + fi; diff --git a/Binary/Loader/LoaderInterface.php b/Binary/Loader/LoaderInterface.php index 621c47275..fc2a9bb05 100644 --- a/Binary/Loader/LoaderInterface.php +++ b/Binary/Loader/LoaderInterface.php @@ -11,6 +11,8 @@ namespace Liip\ImagineBundle\Binary\Loader; +use Liip\ImagineBundle\Binary\BinaryInterface; + interface LoaderInterface { /** @@ -20,7 +22,7 @@ interface LoaderInterface * * @param mixed $path * - * @return \Liip\ImagineBundle\Binary\BinaryInterface|string An image binary content + * @return BinaryInterface|string An image binary content */ public function find($path); } diff --git a/DependencyInjection/Compiler/AbstractCompilerPass.php b/DependencyInjection/Compiler/AbstractCompilerPass.php index 8056ec4db..46cec0c1b 100644 --- a/DependencyInjection/Compiler/AbstractCompilerPass.php +++ b/DependencyInjection/Compiler/AbstractCompilerPass.php @@ -11,7 +11,6 @@ namespace Liip\ImagineBundle\DependencyInjection\Compiler; -use Liip\ImagineBundle\Utility\Framework\SymfonyFramework; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -20,19 +19,12 @@ abstract class AbstractCompilerPass implements CompilerPassInterface /** * @param ContainerBuilder $container * @param string $message - * @param mixed[] $replacements + * @param mixed[] ...$replacements */ - protected function log(ContainerBuilder $container, $message, array $replacements = []) + protected function log(ContainerBuilder $container, string $message, ...$replacements): void { - if (count($replacements) > 0) { - $message = vsprintf($message, $replacements); - } - - if (SymfonyFramework::hasDirectContainerBuilderLogging()) { - $container->log($this, $message); - } else { - $compiler = $container->getCompiler(); - $compiler->addLogMessage($compiler->getLoggingFormatter()->format($this, $message)); - } + $container->log($this, sprintf( + '[liip/imagine-bundle] %s', empty($replacements) ? $message : vsprintf($message, $replacements) + )); } } diff --git a/DependencyInjection/Compiler/FiltersCompilerPass.php b/DependencyInjection/Compiler/FiltersCompilerPass.php index cb2a432c9..6a64cb5a7 100644 --- a/DependencyInjection/Compiler/FiltersCompilerPass.php +++ b/DependencyInjection/Compiler/FiltersCompilerPass.php @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container) foreach ($tags as $id => $tag) { $manager->addMethodCall('addLoader', [$tag[0]['loader'], new Reference($id)]); - $this->log($container, 'Registered imagine-bimdle filter loader: %s', [$id]); + $this->log($container, 'Registered filter loader: %s', $id); } } } diff --git a/DependencyInjection/Compiler/LoadersCompilerPass.php b/DependencyInjection/Compiler/LoadersCompilerPass.php index deaf6bad6..afb74dcdc 100644 --- a/DependencyInjection/Compiler/LoadersCompilerPass.php +++ b/DependencyInjection/Compiler/LoadersCompilerPass.php @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container) foreach ($tags as $id => $tag) { $manager->addMethodCall('addLoader', [$tag[0]['loader'], new Reference($id)]); - $this->log($container, 'Registered imagine-bimdle binary loader: %s', [$id]); + $this->log($container, 'Registered binary loader: %s', $id); } } } diff --git a/DependencyInjection/Compiler/MetadataReaderCompilerPass.php b/DependencyInjection/Compiler/MetadataReaderCompilerPass.php index 73145cfa2..3c0952dca 100644 --- a/DependencyInjection/Compiler/MetadataReaderCompilerPass.php +++ b/DependencyInjection/Compiler/MetadataReaderCompilerPass.php @@ -15,8 +15,7 @@ use Symfony\Component\DependencyInjection\Definition; /** - * Be default, a metadata reader that requires the "exif" PHP extension is used. This compiler pass checks if the - * extension is loaded or not, and switches to a metadata reader (that does not rely on "exif") if not. + * Replaces the default exif-extension-based metadata reader with a degraded one if the exif extensions is not loaded. */ class MetadataReaderCompilerPass extends AbstractCompilerPass { @@ -38,18 +37,14 @@ class MetadataReaderCompilerPass extends AbstractCompilerPass /** * {@inheritdoc} */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$this->isExifExtensionLoaded() && $this->isExifMetadataReaderSet($container)) { $container->setDefinition(self::$metadataReaderServiceId, new Definition(self::$metadataReaderDefaultClass)); - $message = 'Overwrote "%s" service to use "%s" instead of "%s" due to missing "exif" extension ' - .'(installing the "exif" extension is highly recommended; you may experience degraded ' - .'metadata handling without it)'; - $this->log($container, $message, array( - self::$metadataReaderServiceId, - self::$metadataReaderDefaultClass, - self::$metadataReaderExifClass, - )); + $message = 'Replaced the "%s" metadata reader service with "%s" from "%s" due to missing "exif" extension '. + '(as you may experience degraded metadata handling without the exif extension, installation is '. + 'highly recommended)'; + $this->log($container, $message, self::$metadataReaderServiceId, self::$metadataReaderDefaultClass, self::$metadataReaderExifClass); } } @@ -58,7 +53,7 @@ public function process(ContainerBuilder $container) * * @return bool */ - private function isExifMetadataReaderSet(ContainerBuilder $container) + private function isExifMetadataReaderSet(ContainerBuilder $container): bool { return $container->getDefinition(self::$metadataReaderServiceId)->getClass() === self::$metadataReaderExifClass; } @@ -66,7 +61,7 @@ private function isExifMetadataReaderSet(ContainerBuilder $container) /** * @return bool */ - protected function isExifExtensionLoaded() + protected function isExifExtensionLoaded(): bool { return extension_loaded('exif'); } diff --git a/DependencyInjection/Compiler/PostProcessorsCompilerPass.php b/DependencyInjection/Compiler/PostProcessorsCompilerPass.php index 90045434b..7b772aa00 100644 --- a/DependencyInjection/Compiler/PostProcessorsCompilerPass.php +++ b/DependencyInjection/Compiler/PostProcessorsCompilerPass.php @@ -33,7 +33,7 @@ public function process(ContainerBuilder $container) foreach ($tags as $id => $tag) { $manager->addMethodCall('addPostProcessor', [$tag[0]['post_processor'], new Reference($id)]); - $this->log($container, 'Registered imagine-bimdle filter post-processor: %s', [$id]); + $this->log($container, 'Registered filter post-processor: %s', $id); } } } diff --git a/DependencyInjection/Compiler/ResolversCompilerPass.php b/DependencyInjection/Compiler/ResolversCompilerPass.php index 09eed1585..4602e59fb 100644 --- a/DependencyInjection/Compiler/ResolversCompilerPass.php +++ b/DependencyInjection/Compiler/ResolversCompilerPass.php @@ -28,7 +28,7 @@ public function process(ContainerBuilder $container) foreach ($tags as $id => $tag) { $manager->addMethodCall('addResolver', [$tag[0]['resolver'], new Reference($id)]); - $this->log($container, 'Registered imagine-bimdle cache resolver: %s', [$id]); + $this->log($container, 'Registered cache resolver: %s', $id); } } } diff --git a/DependencyInjection/Factory/ChildDefinitionTrait.php b/DependencyInjection/Factory/ChildDefinitionTrait.php deleted file mode 100644 index 33d49c433..000000000 --- a/DependencyInjection/Factory/ChildDefinitionTrait.php +++ /dev/null @@ -1,25 +0,0 @@ -getChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $this->getName())); + return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $this->getName())); } /** diff --git a/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php b/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php index e5d0674ba..768c7e8c9 100644 --- a/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php +++ b/DependencyInjection/Factory/Resolver/AbstractResolverFactory.php @@ -11,14 +11,10 @@ namespace Liip\ImagineBundle\DependencyInjection\Factory\Resolver; -use Liip\ImagineBundle\DependencyInjection\Factory\ChildDefinitionTrait; use Symfony\Component\DependencyInjection\ChildDefinition; -use Symfony\Component\DependencyInjection\DefinitionDecorator; abstract class AbstractResolverFactory implements ResolverFactoryInterface { - use ChildDefinitionTrait; - /** * @var string */ @@ -27,10 +23,10 @@ abstract class AbstractResolverFactory implements ResolverFactoryInterface /** * @param string|null $name * - * @return ChildDefinition|DefinitionDecorator + * @return ChildDefinition */ final protected function getChildResolverDefinition($name = null) { - return $this->getChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); + return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $name ?: $this->getName())); } } diff --git a/DependencyInjection/LiipImagineExtension.php b/DependencyInjection/LiipImagineExtension.php index ebb0d88b2..365907cd0 100644 --- a/DependencyInjection/LiipImagineExtension.php +++ b/DependencyInjection/LiipImagineExtension.php @@ -59,6 +59,9 @@ public function getConfiguration(array $config, ContainerBuilder $container) /** * @see \Symfony\Component\DependencyInjection\Extension.ExtensionInterface::load() + * + * @param array $configs + * @param ContainerBuilder $container */ public function load(array $configs, ContainerBuilder $container) { diff --git a/Form/Type/ImageType.php b/Form/Type/ImageType.php index 5015de0b4..65aa8a5c1 100644 --- a/Form/Type/ImageType.php +++ b/Form/Type/ImageType.php @@ -16,7 +16,6 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * ImageType. @@ -56,14 +55,6 @@ public function configureOptions(OptionsResolver $resolver) ]); } - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $this->configureOptions($resolver); - } - /** * {@inheritdoc} */ @@ -71,12 +62,4 @@ public function getParent() { return FileType::class; } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'liip_imagine_image'; - } } diff --git a/Imagine/Cache/CacheManagerAwareTrait.php b/Imagine/Cache/CacheManagerAwareTrait.php index f67baceb0..d656531a8 100644 --- a/Imagine/Cache/CacheManagerAwareTrait.php +++ b/Imagine/Cache/CacheManagerAwareTrait.php @@ -18,6 +18,9 @@ trait CacheManagerAwareTrait */ protected $cacheManager; + /** + * @param CacheManager $cacheManager + */ public function setCacheManager(CacheManager $cacheManager) { $this->cacheManager = $cacheManager; diff --git a/Imagine/Cache/Resolver/AmazonS3Resolver.php b/Imagine/Cache/Resolver/AmazonS3Resolver.php index 36be4ba97..3933bb806 100644 --- a/Imagine/Cache/Resolver/AmazonS3Resolver.php +++ b/Imagine/Cache/Resolver/AmazonS3Resolver.php @@ -194,6 +194,8 @@ protected function getObjectUrl($path) * * @param string $objectPath * + * @throws \S3_Exception + * * @return bool */ protected function objectExists($objectPath) diff --git a/Imagine/Cache/Resolver/AwsS3Resolver.php b/Imagine/Cache/Resolver/AwsS3Resolver.php index f30a95046..d4a7c62f1 100644 --- a/Imagine/Cache/Resolver/AwsS3Resolver.php +++ b/Imagine/Cache/Resolver/AwsS3Resolver.php @@ -192,12 +192,12 @@ public function remove(array $paths, array $filters) * * If the option is already set, it will be overwritten. * - * @see Aws\S3\S3Client::getObjectUrl() for available options + * @see \Aws\S3\S3Client::getObjectUrl() for available options * * @param string $key The name of the option * @param mixed $value The value to be set * - * @return AmazonS3Resolver $this + * @return $this */ public function setGetOption($key, $value) { @@ -211,12 +211,12 @@ public function setGetOption($key, $value) * * If the option is already set, it will be overwritten. * - * @see Aws\S3\S3Client::putObject() for available options + * @see \Aws\S3\S3Client::putObject() for available options * * @param string $key The name of the option * @param mixed $value The value to be set * - * @return AmazonS3Resolver $this + * @return $this */ public function setPutOption($key, $value) { diff --git a/Imagine/Cache/Resolver/NoCacheWebPathResolver.php b/Imagine/Cache/Resolver/NoCacheWebPathResolver.php index a10ccfe47..f26b20374 100644 --- a/Imagine/Cache/Resolver/NoCacheWebPathResolver.php +++ b/Imagine/Cache/Resolver/NoCacheWebPathResolver.php @@ -16,6 +16,11 @@ class NoCacheWebPathResolver implements ResolverInterface { + /** + * @var RequestContext + */ + private $requestContext; + /** * @param RequestContext $requestContext */ diff --git a/Imagine/Data/DataManager.php b/Imagine/Data/DataManager.php index 889b1d7d8..baac78233 100644 --- a/Imagine/Data/DataManager.php +++ b/Imagine/Data/DataManager.php @@ -116,7 +116,7 @@ public function getLoader($filter) * * @throws \LogicException * - * @return \Liip\ImagineBundle\Binary\BinaryInterface + * @return BinaryInterface */ public function find($filter, $path) { diff --git a/Imagine/Filter/FilterConfiguration.php b/Imagine/Filter/FilterConfiguration.php index 7d586de98..7bedd89ad 100644 --- a/Imagine/Filter/FilterConfiguration.php +++ b/Imagine/Filter/FilterConfiguration.php @@ -51,8 +51,6 @@ public function get($filter) * * @param string $filter * @param array $config - * - * @return array */ public function set($filter, array $config) { diff --git a/Imagine/Filter/FilterManager.php b/Imagine/Filter/FilterManager.php index 38eaaafa0..c4da14ad9 100644 --- a/Imagine/Filter/FilterManager.php +++ b/Imagine/Filter/FilterManager.php @@ -98,18 +98,15 @@ public function getFilterConfiguration() * * @throws \InvalidArgumentException * - * @return Binary + * @return BinaryInterface */ public function apply(BinaryInterface $binary, array $config) { - $config = array_replace( - [ - 'filters' => [], - 'quality' => 100, - 'animated' => false, - ], - $config - ); + $config = array_replace([ + 'filters' => [], + 'quality' => 100, + 'animated' => false, + ], $config); if ($binary instanceof FileBinaryInterface) { $image = $this->imagine->open($binary->getPath()); diff --git a/Imagine/Filter/Loader/AutoRotateFilterLoader.php b/Imagine/Filter/Loader/AutoRotateFilterLoader.php index ead205691..794aef99f 100644 --- a/Imagine/Filter/Loader/AutoRotateFilterLoader.php +++ b/Imagine/Filter/Loader/AutoRotateFilterLoader.php @@ -30,7 +30,7 @@ class AutoRotateFilterLoader implements LoaderInterface */ public function load(ImageInterface $image, array $options = []) { - if ($orientation = $this->getOrientation($image)) { + if (null !== $orientation = $this->getOrientation($image)) { if ($orientation < 1 || $orientation > 8) { return $image; } @@ -78,28 +78,21 @@ private function calculateRotation($orientation) /** * @param ImageInterface $image * - * @return int + * @return int|null */ private function getOrientation(ImageInterface $image) { - //>0.6 imagine meta data interface - if (method_exists($image, 'metadata')) { - foreach ($this->orientationKeys as $orientationKey) { - $orientation = $image->metadata()->offsetGet($orientationKey); + foreach ($this->orientationKeys as $orientationKey) { + $orientation = $image->metadata()->offsetGet($orientationKey); - if ($orientation) { - $image->metadata()->offsetSet($orientationKey, '1'); + if ($orientation) { + $image->metadata()->offsetSet($orientationKey, '1'); - return intval($orientation); - } + return intval($orientation); } - } else { - $data = exif_read_data('data://image/jpeg;base64,'.base64_encode($image->get('jpg'))); - - return isset($data['Orientation']) ? $data['Orientation'] : null; } - return; + return null; } /** @@ -111,18 +104,6 @@ private function getOrientation(ImageInterface $image) */ private function isFlipped($orientation) { - switch ($orientation) { - case 1: - case 3: - case 6: - case 8: - return false; - - case 2: - case 4: - case 5: - case 7: - return true; - } + return in_array((int) $orientation, [2, 4, 5, 7]); } } diff --git a/Imagine/Filter/Loader/PasteFilterLoader.php b/Imagine/Filter/Loader/PasteFilterLoader.php index 306bc0f00..e6c5e653f 100644 --- a/Imagine/Filter/Loader/PasteFilterLoader.php +++ b/Imagine/Filter/Loader/PasteFilterLoader.php @@ -34,7 +34,12 @@ public function __construct(ImagineInterface $imagine, $rootPath) } /** - * @see Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface::load() + * @see \Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface::load() + * + * @param ImageInterface $image + * @param array $options + * + * @return ImageInterface|static */ public function load(ImageInterface $image, array $options = []) { diff --git a/Imagine/Filter/Loader/ScaleFilterLoader.php b/Imagine/Filter/Loader/ScaleFilterLoader.php index 4743f0891..bfbf6ac63 100644 --- a/Imagine/Filter/Loader/ScaleFilterLoader.php +++ b/Imagine/Filter/Loader/ScaleFilterLoader.php @@ -56,6 +56,7 @@ public function load(ImageInterface $image, array $options = []) $size = $image->getSize(); $origWidth = $size->getWidth(); $origHeight = $size->getHeight(); + $ratio = 1; if (isset($options[$this->ratioKey])) { $ratio = $this->absoluteRatio ? $options[$this->ratioKey] : $this->calcAbsoluteRatio($options[$this->ratioKey]); diff --git a/Imagine/Filter/Loader/WatermarkFilterLoader.php b/Imagine/Filter/Loader/WatermarkFilterLoader.php index 5d284ddcb..a86aa36b7 100644 --- a/Imagine/Filter/Loader/WatermarkFilterLoader.php +++ b/Imagine/Filter/Loader/WatermarkFilterLoader.php @@ -36,6 +36,11 @@ public function __construct(ImagineInterface $imagine, $rootPath) /** * @see \Liip\ImagineBundle\Imagine\Filter\Loader\LoaderInterface::load() + * + * @param ImageInterface $image + * @param array $options + * + * @return ImageInterface|static */ public function load(ImageInterface $image, array $options = []) { diff --git a/Imagine/Filter/PostProcessor/PngquantPostProcessor.php b/Imagine/Filter/PostProcessor/PngquantPostProcessor.php index 5c696e223..5fbb5b74f 100644 --- a/Imagine/Filter/PostProcessor/PngquantPostProcessor.php +++ b/Imagine/Filter/PostProcessor/PngquantPostProcessor.php @@ -37,6 +37,7 @@ class PngquantPostProcessor implements PostProcessorInterface, ConfigurablePostP * Constructor. * * @param string $pngquantBin Path to the pngquant binary + * @param string $quality */ public function __construct($pngquantBin = '/usr/bin/pngquant', $quality = '80-100') { diff --git a/Model/FileBinary.php b/Model/FileBinary.php index ecbdfa66e..458e2dcb4 100644 --- a/Model/FileBinary.php +++ b/Model/FileBinary.php @@ -31,7 +31,7 @@ class FileBinary implements FileBinaryInterface protected $format; /** - * @param string $content + * @param string $path * @param string $mimeType * @param string $format */ diff --git a/Service/FilterService.php b/Service/FilterService.php index f58c65b84..d81467378 100644 --- a/Service/FilterService.php +++ b/Service/FilterService.php @@ -12,7 +12,6 @@ namespace Liip\ImagineBundle\Service; use Liip\ImagineBundle\Binary\BinaryInterface; -use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException; use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException; use Liip\ImagineBundle\Imagine\Cache\CacheManager; use Liip\ImagineBundle\Imagine\Data\DataManager; diff --git a/Templating/FilterTrait.php b/Templating/FilterTrait.php index 15536ecd7..46bc6967c 100644 --- a/Templating/FilterTrait.php +++ b/Templating/FilterTrait.php @@ -31,9 +31,10 @@ public function __construct(CacheManager $cache) /** * Gets the browser path for the image and filter to apply. * - * @param string $path - * @param string $filter - * @param array $config + * @param string $path + * @param string $filter + * @param array $config + * @param string|null $resolver * * @return string */ diff --git a/Tests/AbstractTest.php b/Tests/AbstractTest.php index 89ab347cc..911df2495 100644 --- a/Tests/AbstractTest.php +++ b/Tests/AbstractTest.php @@ -24,13 +24,14 @@ use Liip\ImagineBundle\Imagine\Filter\FilterManager; use Liip\ImagineBundle\Imagine\Filter\PostProcessor\PostProcessorInterface; use Liip\ImagineBundle\Service\FilterService; +use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface; use Symfony\Component\Routing\RouterInterface; -abstract class AbstractTest extends \PHPUnit\Framework\TestCase +abstract class AbstractTest extends TestCase { /** * @var Filesystem diff --git a/Tests/Async/CacheResolvedTest.php b/Tests/Async/CacheResolvedTest.php index 75eea43d6..cb025c8db 100644 --- a/Tests/Async/CacheResolvedTest.php +++ b/Tests/Async/CacheResolvedTest.php @@ -4,8 +4,9 @@ use Enqueue\Bundle\EnqueueBundle; use Liip\ImagineBundle\Async\CacheResolved; +use PHPUnit\Framework\TestCase; -class CacheResolvedTest extends \PHPUnit\Framework\TestCase +class CacheResolvedTest extends TestCase { public static function setUpBeforeClass() { diff --git a/Tests/Async/ResolveCacheTest.php b/Tests/Async/ResolveCacheTest.php index 8a62e1766..a5bba2dac 100644 --- a/Tests/Async/ResolveCacheTest.php +++ b/Tests/Async/ResolveCacheTest.php @@ -4,8 +4,9 @@ use Enqueue\Bundle\EnqueueBundle; use Liip\ImagineBundle\Async\ResolveCache; +use PHPUnit\Framework\TestCase; -class ResolveCacheTest extends \PHPUnit\Framework\TestCase +class ResolveCacheTest extends TestCase { public static function setUpBeforeClass() { diff --git a/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php b/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php index c9766c44a..ac6fd223e 100644 --- a/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php +++ b/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php @@ -14,11 +14,12 @@ use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectRepository; use Liip\ImagineBundle\Binary\Loader\AbstractDoctrineLoader; +use PHPUnit\Framework\TestCase; /** * @covers \Liip\ImagineBundle\Binary\Loader\AbstractDoctrineLoader */ -class AbstractDoctrineLoaderTest extends \PHPUnit\Framework\TestCase +class AbstractDoctrineLoaderTest extends TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|ObjectRepository diff --git a/Tests/Binary/Loader/FileSystemLoaderTest.php b/Tests/Binary/Loader/FileSystemLoaderTest.php index 3259fe626..93343bb71 100644 --- a/Tests/Binary/Loader/FileSystemLoaderTest.php +++ b/Tests/Binary/Loader/FileSystemLoaderTest.php @@ -16,13 +16,14 @@ use Liip\ImagineBundle\Binary\Locator\FileSystemLocator; use Liip\ImagineBundle\Binary\Locator\LocatorInterface; use Liip\ImagineBundle\Model\FileBinary; +use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; /** * @covers \Liip\ImagineBundle\Binary\Loader\FileSystemLoader */ -class FileSystemLoaderTest extends \PHPUnit\Framework\TestCase +class FileSystemLoaderTest extends TestCase { public function testConstruction() { @@ -143,6 +144,8 @@ public function provideOutsideRootPathsData() * * @expectedException \Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException * @expectedExceptionMessage Source image invalid + * + * @param string $path */ public function testThrowsIfRealPathOutsideRootPath($path) { diff --git a/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php b/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php index 3118ec7a5..88aefa9a9 100644 --- a/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php +++ b/Tests/Binary/Locator/AbstractFileSystemLocatorTest.php @@ -13,8 +13,9 @@ use Liip\ImagineBundle\Binary\Locator\FileSystemLocator; use Liip\ImagineBundle\Binary\Locator\LocatorInterface; +use PHPUnit\Framework\TestCase; -abstract class AbstractFileSystemLocatorTest extends \PHPUnit\Framework\TestCase +abstract class AbstractFileSystemLocatorTest extends TestCase { /** * @param string[]|string $paths @@ -127,6 +128,8 @@ public function provideOutsideRootPathsData() * * @expectedException \Liip\ImagineBundle\Exception\InvalidArgumentException * @expectedExceptionMessage Root image path not resolvable + * + * @param string $path */ public function testThrowsIfRealPathOutsideRootPath($path) { diff --git a/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php b/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php index 1827e4f4d..54c611a54 100644 --- a/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php +++ b/Tests/Binary/Locator/FileSystemInsecureLocatorTest.php @@ -20,6 +20,8 @@ class FileSystemInsecureLocatorTest extends AbstractFileSystemLocatorTest { /** + * @param string|string[] $paths + * * @return LocatorInterface */ protected function getFileSystemLocator($paths) diff --git a/Tests/Binary/Locator/FileSystemLocatorTest.php b/Tests/Binary/Locator/FileSystemLocatorTest.php index c91493627..3262db839 100644 --- a/Tests/Binary/Locator/FileSystemLocatorTest.php +++ b/Tests/Binary/Locator/FileSystemLocatorTest.php @@ -20,6 +20,8 @@ class FileSystemLocatorTest extends AbstractFileSystemLocatorTest { /** + * @param string|string[] $paths + * * @return LocatorInterface */ protected function getFileSystemLocator($paths) diff --git a/Tests/Binary/SimpleMimeTypeGuesserTest.php b/Tests/Binary/SimpleMimeTypeGuesserTest.php index f374f0855..1abed668a 100644 --- a/Tests/Binary/SimpleMimeTypeGuesserTest.php +++ b/Tests/Binary/SimpleMimeTypeGuesserTest.php @@ -13,12 +13,13 @@ use Liip\ImagineBundle\Binary\MimeTypeGuesserInterface; use Liip\ImagineBundle\Binary\SimpleMimeTypeGuesser; +use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser; /** * @covers \Liip\ImagineBundle\Binary\SimpleMimeTypeGuesser */ -class SimpleMimeTypeGuesserTest extends \PHPUnit\Framework\TestCase +class SimpleMimeTypeGuesserTest extends TestCase { /** * @return SimpleMimeTypeGuesser @@ -59,6 +60,8 @@ public static function provideImageData() * * @param string $fileName * @param string $mimeType + * + * @throws \Exception */ public function testGuessMimeType($fileName, $mimeType) { diff --git a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php index a33228848..258e03ffc 100644 --- a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTest.php @@ -12,11 +12,7 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; use Liip\ImagineBundle\DependencyInjection\Compiler\AbstractCompilerPass; -use Liip\ImagineBundle\Utility\Framework\SymfonyFramework; -use Symfony\Component\DependencyInjection\Compiler\Compiler; -use Symfony\Component\DependencyInjection\Compiler\LoggingFormatter; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; + /** * @covers \Liip\ImagineBundle\DependencyInjection\Compiler\AbstractCompilerPass @@ -36,96 +32,18 @@ private function createAbstractCompilerPassMock(array $methods = array()) ->getMock(); } - /** - * @param string[] $methods - * - * @return \PHPUnit_Framework_MockObject_MockObject|ContainerBuilder - */ - private function createContainerBuilderMock(array $methods = array()) - { - return $this - ->getMockBuilder(ContainerBuilder::class) - ->setMethods($methods) - ->getMock(); - } - - /** - * @param string[] $methods - * - * @return \PHPUnit_Framework_MockObject_MockObject|Compiler - */ - private function createCompilerMock(array $methods = array()) - { - return $this - ->getMockBuilder(Compiler::class) - ->setMethods($methods) - ->getMock(); - } - - /** - * @param string[] $methods - * - * @return \PHPUnit_Framework_MockObject_MockObject|Compiler - */ - private function createLoggingFormatterMock(array $methods = array()) - { - return $this - ->getMockBuilder(LoggingFormatter::class) - ->setMethods($methods) - ->getMock(); - } - - /** - * @param string[] $methods - * - * @return \PHPUnit_Framework_MockObject_MockObject|Definition - */ - private function createDefinitionMock(array $methods = array()) - { - return $this - ->getMockBuilder(Definition::class) - ->setMethods($methods) - ->getMock(); - } - public function testCompilerLogging() { $pass = $this->createAbstractCompilerPassMock(); - $message = 'Compiler log: %d %s message'; - $messageReplaces = array(1, 'foo-bar'); - $messageCompiled = vsprintf($message, $messageReplaces); - - if (SymfonyFramework::hasDirectContainerBuilderLogging()) { - $container = $this->createContainerBuilderMock(); - $container - ->expects($this->atLeastOnce()) - ->method('log') - ->with($pass, $messageCompiled); - } else { - $container = $this->createContainerBuilderMock(array('getCompiler')); - $formatter = $this->createLoggingFormatterMock(array('format')); - $formatter - ->expects($this->atLeastOnce()) - ->method('format') - ->with($pass, $messageCompiled); - - $compiler = $this->createCompilerMock(array('addLogMessage', 'getLoggingFormatter')); - $compiler - ->expects($this->atLeastOnce()) - ->method('addLogMessage'); - $compiler - ->expects($this->atLeastOnce()) - ->method('getLoggingFormatter') - ->willReturn($formatter); + $message = 'Compiler log %s with %d substitutions'; + $replace = ['entry', 2]; + $expects = vsprintf('[liip/imagine-bundle] '.$message, $replace); - $container - ->expects($this->atLeastOnce()) - ->method('getCompiler') - ->willReturn($compiler); - } + $container = $this->createContainerBuilderMock(); + $this->expectContainerLogMethodCalledOnce($container, $pass, $expects); $log = $this->getVisibilityRestrictedMethod($pass, 'log'); - $log->invoke($pass, $container, $message, $messageReplaces); + $log->invoke($pass, $container, $message, ...$replace); } } diff --git a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php index 8723fadd5..5af5126c8 100644 --- a/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php +++ b/Tests/DependencyInjection/Compiler/AbstractCompilerPassTestCase.php @@ -11,6 +11,7 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; +use Liip\ImagineBundle\DependencyInjection\Compiler\AbstractCompilerPass; use Liip\ImagineBundle\Tests\AbstractTest; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; @@ -34,7 +35,7 @@ protected function createDefinition(array $tags = array()) } /** - * @param array $definitions + * @param Definition[] $definitions * * @return ContainerBuilder */ @@ -49,6 +50,43 @@ protected function createContainerBuilder(array $definitions = array()) return $container; } + /** + * @param string[] $methods + * @param Definition[] $definitions + * + * @return ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + protected function createContainerBuilderMock(array $methods = array(), array $definitions = array()) + { + $container = $this + ->getMockBuilder(ContainerBuilder::class) + ->setMethods($methods) + ->getMock(); + + foreach ($definitions as $name => $object) { + $container->setDefinition($name, $object); + } + + return $container; + } + + /** + * @param \PHPUnit_Framework_MockObject_MockObject $container + * @param mixed[] ...$expectedArguments + */ + protected function expectContainerLogMethodCalledOnce(\PHPUnit_Framework_MockObject_MockObject $container, ...$expectedArguments): void + { + $expectation = $container + ->expects($this->once()) + ->method('log'); + + if (!empty($expectedArguments)) { + $expectation->with(...$expectedArguments); + } else { + $expectation->withAnyParameters(); + } + } + /** * @param Definition $definition * @param string|null $message @@ -67,4 +105,34 @@ protected function assertDefinitionMethodCallCount($expect, Definition $definiti { $this->assertCount($expect, $definition->getMethodCalls(), $message); } + + /** + * @param AbstractCompilerPass $pass + * @param Definition[]|array[] $definitions + */ + protected function assertContainerLogMethodCalledForCompilerPass(AbstractCompilerPass $pass, array $definitions): void + { + $container = $this->createContainerBuilderMock(['log'], $definitions[0]); + + $this->expectContainerLogMethodCalledOnce($container); + $pass->process($container); + } + + /** + * @param string $definition + * @param string $manager + * @param array $tags + * + * @return Definition[]|array[] + */ + protected function getCompilerPassContainerDefinitions(string $definition, string $manager, array $tags): array + { + $m = $this->createDefinition(); + $l = $this->createDefinition($tags); + + return [[ + $definition => $l, + $manager => $m, + ], $m]; + } } diff --git a/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php b/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php index ec422cb6f..28cdf781e 100644 --- a/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/FiltersCompilerPassTest.php @@ -12,6 +12,7 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; use Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass; +use Symfony\Component\DependencyInjection\Definition; /** * @covers \Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass @@ -20,15 +21,9 @@ class FiltersCompilerPassTest extends AbstractCompilerPassTestCase { public function testProcess() { - $m = $this->createDefinition(); - $l = $this->createDefinition(array('liip_imagine.filter.loader' => array( - 'loader' => 'foobar', - ))); + list($d, $m) = $this->getFiltersCompilerPassContainerDefinitions(); - $container = $this->createContainerBuilder(array( - 'filter.loader.foobar' => $l, - 'liip_imagine.filter.manager' => $m, - )); + $container = $this->createContainerBuilder($d); $pass = new FiltersCompilerPass(); @@ -36,4 +31,24 @@ public function testProcess() $pass->process($container); $this->assertDefinitionMethodCallCount(1, $m); } + + public function testProcessLogging() + { + $this->assertContainerLogMethodCalledForCompilerPass( + new FiltersCompilerPass(), + $this->getFiltersCompilerPassContainerDefinitions() + ); + } + + /** + * @return Definition[]|array[] + */ + private function getFiltersCompilerPassContainerDefinitions(): array + { + return $this->getCompilerPassContainerDefinitions( + 'filter.loader.foobar', + 'liip_imagine.filter.manager', + ['liip_imagine.filter.loader' => ['loader' => 'foobar']] + ); + } } diff --git a/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php b/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php index 30c31ce2c..6eb4ddca5 100644 --- a/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/LoadersCompilerPassTest.php @@ -11,7 +11,9 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; + use Liip\ImagineBundle\DependencyInjection\Compiler\LoadersCompilerPass; +use Symfony\Component\DependencyInjection\Definition; /** * @covers \Liip\ImagineBundle\DependencyInjection\Compiler\LoadersCompilerPass @@ -20,15 +22,9 @@ class LoadersCompilerPassTest extends AbstractCompilerPassTestCase { public function testProcess() { - $m = $this->createDefinition(); - $l = $this->createDefinition(array('liip_imagine.binary.loader' => array( - 'loader' => 'foobar', - ))); + list($d, $m) = $this->getLoadersCompilerPassContainerDefinitions(); - $container = $this->createContainerBuilder(array( - 'binary.loader.foobar' => $l, - 'liip_imagine.data.manager' => $m, - )); + $container = $this->createContainerBuilder($d); $pass = new LoadersCompilerPass(); @@ -36,4 +32,24 @@ public function testProcess() $pass->process($container); $this->assertDefinitionMethodCallCount(1, $m); } + + public function testProcessLogging() + { + $this->assertContainerLogMethodCalledForCompilerPass( + new LoadersCompilerPass(), + $this->getLoadersCompilerPassContainerDefinitions() + ); + } + + /** + * @return Definition[]|array[] + */ + private function getLoadersCompilerPassContainerDefinitions(): array + { + return $this->getCompilerPassContainerDefinitions( + 'binary.loader.foobar', + 'liip_imagine.data.manager', + ['liip_imagine.binary.loader' => ['loader' => 'foobar']] + ); + } } diff --git a/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php b/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php index 52692fbfc..a3de38218 100644 --- a/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/MetadataReaderCompilerPassTest.php @@ -12,14 +12,15 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; use Liip\ImagineBundle\DependencyInjection\Compiler\MetadataReaderCompilerPass; -use stdClass; + +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; /** * @covers \Liip\ImagineBundle\DependencyInjection\Compiler\MetadataReaderCompilerPass */ -class MetadataReaderCompilerPassTest extends \PHPUnit\Framework\TestCase +class MetadataReaderCompilerPassTest extends TestCase { /** * @param \ReflectionClass $r @@ -37,6 +38,8 @@ private static function getVisibilityRestrictedStaticProperty(\ReflectionClass $ /** * @return mixed[] + * + * @throws \ReflectionException */ private static function getReaderParamAndDefaultAndExifValues() { @@ -68,6 +71,18 @@ private function getMetadataReaderCompilerPass($isExifExtensionLoaded) return $mock; } + public function testProcessBasedOnExtensionsInEnvironment() + { + list($metadataServiceId, $metadataExifClass, $metadataDefaultClass) = static::getReaderParamAndDefaultAndExifValues(); + + $container = new ContainerBuilder(); + $container->setDefinition($metadataServiceId, new Definition($metadataExifClass)); + + $pass = new MetadataReaderCompilerPass(); + $pass->process($container); + $this->assertInstanceOf(extension_loaded('exif') ? $metadataExifClass : $metadataDefaultClass, $container->get($metadataServiceId)); + } + public function testProcessWithoutExtExifAddsDefaultReader() { list($metadataServiceId, $metadataExifClass, $metadataDefaultClass) = static::getReaderParamAndDefaultAndExifValues(); diff --git a/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php b/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php index 20a560678..a5f483c84 100644 --- a/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/PostProcessorsCompilerPassTest.php @@ -12,6 +12,7 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; use Liip\ImagineBundle\DependencyInjection\Compiler\PostProcessorsCompilerPass; +use Symfony\Component\DependencyInjection\Definition; /** * @covers \Liip\ImagineBundle\DependencyInjection\Compiler\PostProcessorsCompilerPass @@ -20,15 +21,9 @@ class PostProcessorsCompilerPassTest extends AbstractCompilerPassTestCase { public function testProcess() { - $m = $this->createDefinition(); - $l = $this->createDefinition(array('liip_imagine.filter.post_processor' => array( - 'post_processor' => 'foobar', - ))); + list($d, $m) = $this->getPostProcessorsCompilerPassContainerDefinitions(); - $container = $this->createContainerBuilder(array( - 'post_processor.foobar' => $l, - 'liip_imagine.filter.manager' => $m, - )); + $container = $this->createContainerBuilder($d); $pass = new PostProcessorsCompilerPass(); @@ -36,4 +31,24 @@ public function testProcess() $pass->process($container); $this->assertDefinitionMethodCallCount(1, $m); } + + public function testProcessLogging() + { + $this->assertContainerLogMethodCalledForCompilerPass( + new PostProcessorsCompilerPass(), + $this->getPostProcessorsCompilerPassContainerDefinitions() + ); + } + + /** + * @return Definition[]|array[] + */ + private function getPostProcessorsCompilerPassContainerDefinitions(): array + { + return $this->getCompilerPassContainerDefinitions( + 'post_processor.foobar', + 'liip_imagine.filter.manager', + ['liip_imagine.filter.post_processor' => ['post_processor' => 'foobar']] + ); + } } diff --git a/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php b/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php index e1f5cc524..e4450d4f7 100644 --- a/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php +++ b/Tests/DependencyInjection/Compiler/ResolversCompilerPassTest.php @@ -12,6 +12,7 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler; use Liip\ImagineBundle\DependencyInjection\Compiler\ResolversCompilerPass; +use Symfony\Component\DependencyInjection\Definition; /** * @covers \Liip\ImagineBundle\DependencyInjection\Compiler\ResolversCompilerPass @@ -20,15 +21,9 @@ class ResolversCompilerPassTest extends AbstractCompilerPassTestCase { public function testProcess() { - $m = $this->createDefinition(); - $l = $this->createDefinition(array('liip_imagine.cache.resolver' => array( - 'resolver' => 'foobar', - ))); + list($d, $m) = $this->getResolversCompilerPassContainerDefinitions(); - $container = $this->createContainerBuilder(array( - 'resolver.foobar' => $l, - 'liip_imagine.cache.manager' => $m, - )); + $container = $this->createContainerBuilder($d); $pass = new ResolversCompilerPass(); @@ -36,4 +31,24 @@ public function testProcess() $pass->process($container); $this->assertDefinitionMethodCallCount(1, $m); } + + public function testProcessLogging() + { + $this->assertContainerLogMethodCalledForCompilerPass( + new ResolversCompilerPass(), + $this->getResolversCompilerPassContainerDefinitions() + ); + } + + /** + * @return Definition[]|array[] + */ + private function getResolversCompilerPassContainerDefinitions(): array + { + return $this->getCompilerPassContainerDefinitions( + 'resolver.foobar', + 'liip_imagine.cache.manager', + ['liip_imagine.cache.resolver' => ['resolver' => 'foobar']] + ); + } } diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 3db05d69a..88ee8048a 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -16,6 +16,7 @@ use Liip\ImagineBundle\DependencyInjection\Factory\Loader\LoaderFactoryInterface; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\ResolverFactoryInterface; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory; +use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Processor; @@ -24,7 +25,7 @@ /** * @covers \Liip\ImagineBundle\DependencyInjection\Configuration */ -class ConfigurationTest extends \PHPUnit\Framework\TestCase +class ConfigurationTest extends TestCase { public function testImplementsConfigurationInterface() { diff --git a/Tests/DependencyInjection/Factory/FactoryTestCase.php b/Tests/DependencyInjection/Factory/FactoryTestCase.php index 9a6c20eb4..62f53f895 100644 --- a/Tests/DependencyInjection/Factory/FactoryTestCase.php +++ b/Tests/DependencyInjection/Factory/FactoryTestCase.php @@ -11,10 +11,11 @@ namespace Liip\ImagineBundle\Tests\DependencyInjection\Factory; +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Definition; -abstract class FactoryTestCase extends \PHPUnit\Framework\TestCase +abstract class FactoryTestCase extends TestCase { /** * @param Definition $definition diff --git a/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php b/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php index ace46257c..15e2fdb6f 100644 --- a/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Loader/FlysystemLoaderFactoryTest.php @@ -14,6 +14,7 @@ use League\Flysystem\Filesystem; use Liip\ImagineBundle\DependencyInjection\Factory\Loader\FlysystemLoaderFactory; use Liip\ImagineBundle\DependencyInjection\Factory\Loader\LoaderFactoryInterface; +use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -24,7 +25,7 @@ * * @covers \Liip\ImagineBundle\DependencyInjection\Factory\Loader\FlysystemLoaderFactory */ -class FlysystemLoaderFactoryTest extends \PHPUnit\Framework\TestCase +class FlysystemLoaderFactoryTest extends TestCase { public function setUp() { diff --git a/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php b/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php index 4a6a5b855..4cacc35be 100644 --- a/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Loader/StreamLoaderFactoryTest.php @@ -13,6 +13,7 @@ use Liip\ImagineBundle\DependencyInjection\Factory\Loader\LoaderFactoryInterface; use Liip\ImagineBundle\DependencyInjection\Factory\Loader\StreamLoaderFactory; +use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -21,7 +22,7 @@ /** * @covers \Liip\ImagineBundle\DependencyInjection\Factory\Loader\StreamLoaderFactory */ -class StreamLoaderFactoryTest extends \PHPUnit\Framework\TestCase +class StreamLoaderFactoryTest extends TestCase { public function testImplementsLoaderFactoryInterface() { diff --git a/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php b/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php index 7e07d7864..dbea0a7fd 100644 --- a/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php @@ -13,6 +13,7 @@ use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\ResolverFactoryInterface; +use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -22,7 +23,7 @@ /** * @covers \Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory */ -class AwsS3ResolverFactoryTest extends \PHPUnit\Framework\TestCase +class AwsS3ResolverFactoryTest extends TestCase { public function testImplementsResolverFactoryInterface() { diff --git a/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php b/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php index b923b9030..07f21041e 100644 --- a/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Resolver/FlysystemResolverFactoryTest.php @@ -14,6 +14,7 @@ use League\Flysystem\Filesystem; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\FlysystemResolverFactory; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\ResolverFactoryInterface; +use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -22,7 +23,7 @@ /** * @covers \Liip\ImagineBundle\DependencyInjection\Factory\Resolver\FlysystemResolverFactory */ -class FlysystemResolverFactoryTest extends \PHPUnit\Framework\TestCase +class FlysystemResolverFactoryTest extends TestCase { public function setUp() { @@ -124,7 +125,7 @@ public function testAddDefaultOptionsIfNotSetOnAddConfiguration() $resolver = new FlysystemResolverFactory(); $resolver->addConfiguration($rootNode); - $config = $this->processConfigTree($treeBuilder, array( + $this->processConfigTree($treeBuilder, array( 'flysystem' => array(), )); } diff --git a/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php b/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php index 5312d0690..20b4a0f3e 100644 --- a/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php +++ b/Tests/DependencyInjection/Factory/Resolver/WebPathResolverFactoryTest.php @@ -14,6 +14,7 @@ use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\ResolverFactoryInterface; use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory; use Liip\ImagineBundle\Utility\Framework\SymfonyFramework; +use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -22,7 +23,7 @@ /** * @covers \Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory */ -class WebPathResolverFactoryTest extends \PHPUnit\Framework\TestCase +class WebPathResolverFactoryTest extends TestCase { public function testImplementsResolverFactoryInterface() { diff --git a/Tests/DependencyInjection/LiipImagineExtensionTest.php b/Tests/DependencyInjection/LiipImagineExtensionTest.php index dd3b70432..b6ba665af 100644 --- a/Tests/DependencyInjection/LiipImagineExtensionTest.php +++ b/Tests/DependencyInjection/LiipImagineExtensionTest.php @@ -16,7 +16,7 @@ use Liip\ImagineBundle\DependencyInjection\LiipImagineExtension; use Liip\ImagineBundle\Tests\AbstractTest; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; + use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser; @@ -87,6 +87,9 @@ public static function provideFactoryData() /** * @dataProvider provideFactoryData + * + * @param string $service + * @param string $factory */ public function testFactoriesConfiguration($service, $factory) { diff --git a/Tests/Events/CacheResolveEventTest.php b/Tests/Events/CacheResolveEventTest.php index 89f683e5c..f5b6aca8a 100644 --- a/Tests/Events/CacheResolveEventTest.php +++ b/Tests/Events/CacheResolveEventTest.php @@ -12,11 +12,12 @@ namespace Liip\ImagineBundle\Tests\Events; use Liip\ImagineBundle\Events\CacheResolveEvent; +use PHPUnit\Framework\TestCase; /** * @covers \Liip\ImagineBundle\Events\CacheResolveEvent */ -class CacheResolveEventTest extends \PHPUnit\Framework\TestCase +class CacheResolveEventTest extends TestCase { protected function setUp() { diff --git a/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php b/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php index 2d1bd1f90..ae73c83fa 100644 --- a/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php +++ b/Tests/Exception/Imagine/Cache/Resolver/NotResolvableExceptionTest.php @@ -13,11 +13,12 @@ use Liip\ImagineBundle\Exception\ExceptionInterface; use Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotResolvableException; +use PHPUnit\Framework\TestCase; /** * @covers \Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotResolvableException */ -class NotResolvableExceptionTest extends \PHPUnit\Framework\TestCase +class NotResolvableExceptionTest extends TestCase { public function testSubClassOfRuntimeException() { diff --git a/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php b/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php index 5d58c3c4e..8fee76bce 100644 --- a/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php +++ b/Tests/Exception/Imagine/Cache/Resolver/NotStorableExceptionTest.php @@ -13,11 +13,12 @@ use Liip\ImagineBundle\Exception\ExceptionInterface; use Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotStorableException; +use PHPUnit\Framework\TestCase; /** * @covers \Liip\ImagineBundle\Exception\Imagine\Cache\Resolver\NotStorableException */ -class NotStorableExceptionTest extends \PHPUnit\Framework\TestCase +class NotStorableExceptionTest extends TestCase { public function testSubClassOfRuntimeException() { diff --git a/Tests/Form/Type/ImageTypeTest.php b/Tests/Form/Type/ImageTypeTest.php index 6320c4206..903fc29f4 100644 --- a/Tests/Form/Type/ImageTypeTest.php +++ b/Tests/Form/Type/ImageTypeTest.php @@ -31,13 +31,6 @@ protected function setUp() } } - public function testGetName() - { - $type = new ImageType(); - - $this->assertEquals('liip_imagine_image', $type->getName()); - } - public function testGetParent() { $type = new ImageType(); diff --git a/Tests/Functional/Command/AbstractCommandTestCase.php b/Tests/Functional/Command/AbstractCommandTestCase.php index 3ffc7502a..e4320791d 100644 --- a/Tests/Functional/Command/AbstractCommandTestCase.php +++ b/Tests/Functional/Command/AbstractCommandTestCase.php @@ -12,7 +12,7 @@ namespace Liip\ImagineBundle\Tests\Functional\Command; use Liip\ImagineBundle\Tests\Functional\AbstractSetupWebTestCase; -use Symfony\Component\Console\Application; + use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; diff --git a/Tests/Functional/Command/RemoveCacheTest.php b/Tests/Functional/Command/RemoveCacheTest.php index 5b6a96fd0..b5fc77f02 100644 --- a/Tests/Functional/Command/RemoveCacheTest.php +++ b/Tests/Functional/Command/RemoveCacheTest.php @@ -11,8 +11,6 @@ namespace Liip\ImagineBundle\Tests\Functional\Command; -use Liip\ImagineBundle\Command\RemoveCacheCommand; - /** * @covers \Liip\ImagineBundle\Command\RemoveCacheCommand */ diff --git a/Tests/Functional/Command/ResolveCacheTest.php b/Tests/Functional/Command/ResolveCacheTest.php index 84e27f655..618495574 100644 --- a/Tests/Functional/Command/ResolveCacheTest.php +++ b/Tests/Functional/Command/ResolveCacheTest.php @@ -11,8 +11,6 @@ namespace Liip\ImagineBundle\Tests\Functional\Command; -use Liip\ImagineBundle\Command\ResolveCacheCommand; - /** * @covers \Liip\ImagineBundle\Command\ResolveCacheCommand */ diff --git a/Tests/Functional/app/AppKernel.php b/Tests/Functional/app/AppKernel.php index 441e847ba..5b2fd8ce8 100644 --- a/Tests/Functional/app/AppKernel.php +++ b/Tests/Functional/app/AppKernel.php @@ -49,6 +49,8 @@ public function getLogDir() /** * @param \Symfony\Component\Config\Loader\LoaderInterface $loader + * + * @throws \Exception */ public function registerContainerConfiguration(LoaderInterface $loader) { diff --git a/Tests/Functional/app/config/config.yml b/Tests/Functional/app/config/config.yml index 65b4ae069..172c38d35 100644 --- a/Tests/Functional/app/config/config.yml +++ b/Tests/Functional/app/config/config.yml @@ -5,7 +5,7 @@ parameters: services: logger: - class: "\\Psr\\Log\\NullLogger" + class: \Psr\Log\NullLogger framework: diff --git a/Tests/Imagine/Cache/CacheManagerTest.php b/Tests/Imagine/Cache/CacheManagerTest.php index 4d1e00da9..a62f10839 100644 --- a/Tests/Imagine/Cache/CacheManagerTest.php +++ b/Tests/Imagine/Cache/CacheManagerTest.php @@ -205,6 +205,8 @@ public function testFilterActionUrlGeneratedAndReturnIfResolverReturnNullOnGetBr /** * @dataProvider invalidPathProvider * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * + * @param string $path */ public function testResolveInvalidPath($path) { diff --git a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php index 0adf7a001..206d92a97 100644 --- a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php @@ -14,13 +14,14 @@ use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface; use Liip\ImagineBundle\Imagine\Cache\Resolver\WebPathResolver; use Liip\ImagineBundle\Model\Binary; +use PHPUnit\Framework\TestCase; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Routing\RequestContext; /** * @covers \Liip\ImagineBundle\Imagine\Cache\Resolver\WebPathResolver */ -class WebPathResolverTest extends \PHPUnit\Framework\TestCase +class WebPathResolverTest extends TestCase { /** * @var Filesystem diff --git a/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php index 8c0900c95..aa4da9fe0 100644 --- a/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/AutoRotateFilterLoaderTest.php @@ -24,9 +24,9 @@ class AutoRotateFilterLoaderTest extends AbstractTest /** * Starts a test with expected results. * - * @param $exifValue {String} The exif value to be returned by the metadata mock - * @param $expectCallRotateValue {null|number} The expected rotation value, null if no rotation is expected - * @param $expectCallFlip {Boolean} True if a horizontal flip is expected, false otherwise + * @param string $exifValue The exif value to be returned by the metadata mock + * @param null|int $expectCallRotateValue {null|number} The expected rotation value, null if no rotation is expected + * @param bool $expectCallFlip True if a horizontal flip is expected, false otherwise */ private function loadExif($exifValue, $expectCallRotateValue, $expectCallFlip) { @@ -168,7 +168,11 @@ public static function getInvalidOrientations() return array(array(0, 9, 255, 65535)); } - /** @dataProvider getInvalidOrientations */ + /** + * @dataProvider getInvalidOrientations + * + * @param string $orientation + */ public function testLoadExifInvalid($orientation) { $this->loadExif($orientation, null, false); diff --git a/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php index e3aef20d1..8f1c393e3 100644 --- a/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/CropFilterLoaderTest.php @@ -51,7 +51,7 @@ public function testLoad($coordinates, $area) $options['start'] = $coordinates; $options['size'] = $area; - $result = $loader->load($image, $options); + $loader->load($image, $options); } /** diff --git a/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php index 58955fa46..bbdd94a82 100644 --- a/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php @@ -24,22 +24,29 @@ class DownscaleFilterLoaderTest extends AbstractTest { /** * @dataProvider provideSizes + * + * @param Box $resultSize + * @param Box $initialSize */ - public function testDontScaleUp($initialSize, $resultSize) + public function testDontScaleUp($resultSize, $initialSize) { $this->assertLessThanOrEqual($initialSize->getHeight(), $resultSize->getHeight()); $this->assertLessThanOrEqual($initialSize->getWidth(), $resultSize->getWidth()); } - /** * @dataProvider provideSizes + * + * @param Box $resultSize */ - public function testFitBoundingBox($initialSize, $resultSize) + public function testFitBoundingBox($resultSize) { $this->assertLessThanOrEqual(100, $resultSize->getHeight()); $this->assertLessThanOrEqual(90, $resultSize->getWidth()); } + /** + * @return \Generator|Box[] + */ public function provideSizes() { $loader = new DownscaleFilterLoader(); @@ -59,6 +66,6 @@ public function provideSizes() $loader->load($image, array('max' => array(100, 90))); - yield [$initialSize, $resultSize]; + yield [$resultSize, $initialSize]; } } diff --git a/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php index 746010b05..f48137891 100644 --- a/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/PasteFilterLoaderTest.php @@ -66,7 +66,7 @@ public function testLoad($x, $y, $expected) $options['start'] = array($x, $y); $options['image'] = ''; - $result = $loader->load($image, $options); + $loader->load($image, $options); } /** diff --git a/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php index 77cb4e7b0..a00a8fabe 100644 --- a/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ResizeFilterLoaderTest.php @@ -43,7 +43,7 @@ public function testLoad($width, $height) $options = array(); $options['size'] = array($width, $height); - $result = $loader->load($image, $options); + $loader->load($image, $options); } /** diff --git a/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php index 7164279e4..f46098277 100644 --- a/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ScaleFilterLoaderTest.php @@ -45,10 +45,6 @@ class ScaleFilterLoaderTest extends AbstractTest protected function getUpscaleMockImage() { - $mockImageSize = new Box( - self::UPSCALE_DUMMY_IMAGE_WIDTH, - self::UPSCALE_DUMMY_IMAGE_HEIGHT - ); $mockImage = parent::getImageInterfaceMock(); $mockImage->method('getSize')->willReturn(new Box( self::UPSCALE_DUMMY_IMAGE_WIDTH, @@ -60,10 +56,6 @@ protected function getUpscaleMockImage() protected function getImageInterfaceMock() { - $mockImageSize = new Box( - self::DUMMY_IMAGE_WIDTH, - self::DUMMY_IMAGE_HEIGHT - ); $mockImage = parent::getImageInterfaceMock(); $mockImage->method('getSize')->willReturn(new Box( self::DUMMY_IMAGE_WIDTH, @@ -88,18 +80,18 @@ public function testItShouldPreserveRatio() )) ->willReturn($image); - $result = $loader->load($image, array( + $loader->load($image, array( 'to' => 1.0, )); } /** - * @param int[] $dimension - * @param Box $expected - * * @covers \Liip\ImagineBundle\Imagine\Filter\Loader\ScaleFilterLoader::load * * @dataProvider dimensionsDataProvider + * + * @param int[] $dimensions + * @param Box $expected */ public function testItShouldUseDimensions($dimensions, $expected) { @@ -115,7 +107,7 @@ public function testItShouldUseDimensions($dimensions, $expected) 'dim' => $dimensions, ); - $result = $loader->load($image, $options); + $loader->load($image, $options); } /** @@ -143,6 +135,9 @@ public function dimensionsDataProvider() /** * @dataProvider minScaleDataProvider + * + * @param int[] $dimensions + * @param Box $expected */ public function testShouldScale($dimensions, $expected) { @@ -157,7 +152,7 @@ public function testShouldScale($dimensions, $expected) 'min' => $dimensions, ); - $result = $loader->load($image, $options); + $loader->load($image, $options); } /** @@ -173,6 +168,9 @@ public function minScaleDataProvider() /** * @dataProvider minNotScaleDataProvider + * + * @param int[] $dimensions + * @param Box $expected */ public function testShouldNotScale($dimensions, $expected) { @@ -187,7 +185,7 @@ public function testShouldNotScale($dimensions, $expected) 'min' => $dimensions, ); - $result = $loader->load($image, $options); + $loader->load($image, $options); } /** diff --git a/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php index 8e75ceb7a..63d9c7e2a 100644 --- a/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/ThumbnailFilterLoaderTest.php @@ -61,7 +61,7 @@ public function testLoad($width, $height, $expected) $options['size'] = array($width, $height); $options['allow_upscale'] = true; - $result = $loader->load($image, $options); + $loader->load($image, $options); } /** diff --git a/Tests/Model/BinaryTest.php b/Tests/Model/BinaryTest.php index efe5affa4..c0390bcaf 100644 --- a/Tests/Model/BinaryTest.php +++ b/Tests/Model/BinaryTest.php @@ -12,11 +12,12 @@ namespace Liip\ImagineBundle\Tests\Model; use Liip\ImagineBundle\Model\Binary; +use PHPUnit\Framework\TestCase; /** * @covers \Liip\ImagineBundle\Model\Binary */ -class BinaryTest extends \PHPUnit\Framework\TestCase +class BinaryTest extends TestCase { public function testImplementsBinaryInterface() { diff --git a/Tests/Utility/Framework/SymfonyFrameworkTest.php b/Tests/Utility/Framework/SymfonyFrameworkTest.php index 17174505e..a9321672a 100644 --- a/Tests/Utility/Framework/SymfonyFrameworkTest.php +++ b/Tests/Utility/Framework/SymfonyFrameworkTest.php @@ -11,14 +11,14 @@ namespace Liip\ImagineBundle\Tests\Utility\Framework; -use Liip\ImagineBundle\Tests\Filter\PasteFilterLoaderTest; use Liip\ImagineBundle\Utility\Framework\SymfonyFramework; +use PHPUnit\Framework\TestCase; use Symfony\Component\HttpKernel\Kernel; /** * @covers \Liip\ImagineBundle\Utility\Framework\SymfonyFramework */ -class SymfonyFrameworkTest extends \PHPUnit\Framework\TestCase +class SymfonyFrameworkTest extends TestCase { public function testKernelComparisonForCurrentKernel() { @@ -35,15 +35,6 @@ public function testIsKernelLessThan() $this->assertFalse(SymfonyFramework::isKernelLessThan(1, 1, 1)); } - public function testHasDirectContainerBuilderLogging() - { - if (SymfonyFramework::isKernelGreaterThanOrEqualTo(3, 3)) { - $this->assertTrue(SymfonyFramework::hasDirectContainerBuilderLogging()); - } else { - $this->assertFalse(SymfonyFramework::hasDirectContainerBuilderLogging()); - } - } - public function testGetContainerResolvableRootWebPath() { $path = SymfonyFramework::getContainerResolvableRootWebPath(); diff --git a/Utility/Framework/SymfonyFramework.php b/Utility/Framework/SymfonyFramework.php index 0733d4b91..885712dae 100644 --- a/Utility/Framework/SymfonyFramework.php +++ b/Utility/Framework/SymfonyFramework.php @@ -15,14 +15,6 @@ class SymfonyFramework { - /** - * @return bool - */ - public static function hasDirectContainerBuilderLogging(): bool - { - return method_exists('\Symfony\Component\DependencyInjection\ContainerBuilder', 'log'); - } - /** * @return string */