From d289c625324b234f0e5dfb2e61c13401b926f81e Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 28 Jan 2019 10:52:05 +0100 Subject: [PATCH] Fixed config file being deleted by mistake by build script --- .phpstorm.meta.php | 4 ++-- composer.json | 3 ++- config/autoload/url-shortener.global.php | 4 ++-- .../{phpwkhtmltopdf.global.php => wkhtmltopdf.global.php} | 4 ++-- module/Common/src/Exception/PreviewGenerationException.php | 2 +- module/Common/src/Image/ImageFactory.php | 2 +- module/Common/src/Service/PreviewGenerator.php | 3 +-- module/Common/test/Image/ImageFactoryTest.php | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) rename config/autoload/{phpwkhtmltopdf.global.php => wkhtmltopdf.global.php} (57%) diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index 5dc306bc..9ed9edd8 100644 --- a/.phpstorm.meta.php +++ b/.phpstorm.meta.php @@ -2,7 +2,7 @@ namespace PHPSTORM_META; use Psr\Container\ContainerInterface; -use Zend\ServiceManager\ServiceManager; +use Zend\ServiceManager\ServiceLocatorInterface; /** * PhpStorm Container Interop code completion @@ -17,7 +17,7 @@ $STATIC_METHOD_TYPES = [ ContainerInterface::get('') => [ '' == '@', ], - ServiceManager::build('') => [ + ServiceLocatorInterface::build('') => [ '' == '@', ], ]; diff --git a/composer.json b/composer.json index 0c8af151..c946eda2 100644 --- a/composer.json +++ b/composer.json @@ -105,7 +105,8 @@ "test": [ "@test:unit", - "@test:db" + "@test:db", + "@test:api" ], "test:ci": [ "@test:unit:ci", diff --git a/config/autoload/url-shortener.global.php b/config/autoload/url-shortener.global.php index 5b941ee4..1e50106f 100644 --- a/config/autoload/url-shortener.global.php +++ b/config/autoload/url-shortener.global.php @@ -1,7 +1,7 @@ env('SHORTENED_URL_SCHEMA', 'http'), 'hostname' => env('SHORTENED_URL_HOSTNAME'), ], - 'shortcode_chars' => env('SHORTCODE_CHARS', UrlShortener::DEFAULT_CHARS), + 'shortcode_chars' => env('SHORTCODE_CHARS', UrlShortenerOptions::DEFAULT_CHARS), 'validate_url' => true, 'not_found_short_url' => [ 'enable_redirection' => false, diff --git a/config/autoload/phpwkhtmltopdf.global.php b/config/autoload/wkhtmltopdf.global.php similarity index 57% rename from config/autoload/phpwkhtmltopdf.global.php rename to config/autoload/wkhtmltopdf.global.php index 326b846f..6fa6df30 100644 --- a/config/autoload/phpwkhtmltopdf.global.php +++ b/config/autoload/wkhtmltopdf.global.php @@ -3,9 +3,9 @@ declare(strict_types=1); return [ - 'phpwkhtmltopdf' => [ + 'wkhtmltopdf' => [ 'images' => [ - 'binary' => 'bin/wkhtmltoimage', + 'binary' => __DIR__ . '/../../bin/wkhtmltoimage', 'type' => 'jpg', ], ], diff --git a/module/Common/src/Exception/PreviewGenerationException.php b/module/Common/src/Exception/PreviewGenerationException.php index ef9ccfc3..b7534de5 100644 --- a/module/Common/src/Exception/PreviewGenerationException.php +++ b/module/Common/src/Exception/PreviewGenerationException.php @@ -7,7 +7,7 @@ use function sprintf; class PreviewGenerationException extends RuntimeException { - public static function fromImageError($error) + public static function fromImageError(string $error): self { return new self(sprintf('Error generating a preview image with error: %s', $error)); } diff --git a/module/Common/src/Image/ImageFactory.php b/module/Common/src/Image/ImageFactory.php index 0629ce2c..ed1c5d4d 100644 --- a/module/Common/src/Image/ImageFactory.php +++ b/module/Common/src/Image/ImageFactory.php @@ -26,7 +26,7 @@ class ImageFactory implements FactoryInterface */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { - $config = $container->get('config')['phpwkhtmltopdf']; + $config = $container->get('config')['wkhtmltopdf']; $image = new Image($config['images'] ?? null); if ($options['url'] ?? null) { diff --git a/module/Common/src/Service/PreviewGenerator.php b/module/Common/src/Service/PreviewGenerator.php index 3d8206b5..6b6156f8 100644 --- a/module/Common/src/Service/PreviewGenerator.php +++ b/module/Common/src/Service/PreviewGenerator.php @@ -19,7 +19,7 @@ class PreviewGenerator implements PreviewGeneratorInterface /** @var Filesystem */ private $filesystem; - public function __construct(ImageBuilderInterface $imageBuilder, Filesystem $filesystem, $location) + public function __construct(ImageBuilderInterface $imageBuilder, Filesystem $filesystem, string $location) { $this->location = $location; $this->imageBuilder = $imageBuilder; @@ -33,7 +33,6 @@ class PreviewGenerator implements PreviewGeneratorInterface */ public function generatePreview(string $url): string { - /** @var Image $image */ $image = $this->imageBuilder->build(Image::class, ['url' => $url]); // If the file already exists, return its path diff --git a/module/Common/test/Image/ImageFactoryTest.php b/module/Common/test/Image/ImageFactoryTest.php index ad2de87c..cef305b2 100644 --- a/module/Common/test/Image/ImageFactoryTest.php +++ b/module/Common/test/Image/ImageFactoryTest.php @@ -26,7 +26,7 @@ class ImageFactoryTest extends TestCase { /** @var Image $image */ $image = $this->factory->__invoke(new ServiceManager(['services' => [ - 'config' => ['phpwkhtmltopdf' => []], + 'config' => ['wkhtmltopdf' => []], ]]), ''); $this->assertInstanceOf(Image::class, $image); @@ -45,7 +45,7 @@ class ImageFactoryTest extends TestCase /** @var Image $image */ $image = $this->factory->__invoke(new ServiceManager(['services' => [ - 'config' => ['phpwkhtmltopdf' => []], + 'config' => ['wkhtmltopdf' => []], ]]), '', ['url' => $expectedPage]); $this->assertInstanceOf(Image::class, $image);