diff --git a/composer.json b/composer.json index 9ef9872..fa22f8b 100644 --- a/composer.json +++ b/composer.json @@ -11,10 +11,10 @@ ], "require": { "php": ">=7.1", - "phpunit/php-text-template": "^1.2" + "phpunit/php-text-template": "^1.2 || ^2.0" }, "require-dev": { - "phpunit/phpunit": "^7.0 || ^8.0", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", "php-coveralls/php-coveralls": "^2.0", "squizlabs/php_codesniffer": "^3.0", "gskema/phpcs-type-sniff": "^0.13.1", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6b1e4c6..1f97dd3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,28 +1,25 @@ - - - - src/WebThumbnailer/ - tests/WebThumbnailer/ - - - - - tests - - - - - - - - - - - - + + + + src/WebThumbnailer/ + tests/WebThumbnailer/ + + + + + + + + + + tests + + + + + + + + diff --git a/src/WebThumbnailer/Application/CacheManager.php b/src/WebThumbnailer/Application/CacheManager.php index 76a730a..cd59e29 100644 --- a/src/WebThumbnailer/Application/CacheManager.php +++ b/src/WebThumbnailer/Application/CacheManager.php @@ -8,6 +8,7 @@ use WebThumbnailer\Exception\CacheException; use WebThumbnailer\Exception\IOException; use WebThumbnailer\Utils\FileUtils; +use WebThumbnailer\Utils\TemplatePolyfill; /** * Handles file caching using static methods. @@ -176,7 +177,7 @@ protected static function createHtaccessFile(string $path, bool $allowed = false $templateFile = file_exists(FileUtils::RESOURCES_PATH . 'htaccess' . $apacheVersion . '_template') ? FileUtils::RESOURCES_PATH . 'htaccess' . $apacheVersion . '_template' : FileUtils::RESOURCES_PATH . 'htaccess_template'; - $template = new \Text_Template($templateFile); + $template = TemplatePolyfill::get($templateFile); $template->setVar([ 'new_all' => $allowed ? 'granted' : 'denied', 'old_allow' => $allowed ? 'all' : 'none', diff --git a/src/WebThumbnailer/Utils/TemplatePolyfill.php b/src/WebThumbnailer/Utils/TemplatePolyfill.php new file mode 100644 index 0000000..f4806af --- /dev/null +++ b/src/WebThumbnailer/Utils/TemplatePolyfill.php @@ -0,0 +1,18 @@ +expectExceptionMessageMatches($regularExpression); + } else { + parent::expectExceptionMessageRegExp($regularExpression); + } + } +} diff --git a/tests/WebThumbnailer/Utils/DataUtilsTest.php b/tests/WebThumbnailer/Utils/DataUtilsTest.php index 5825d81..b1522e9 100644 --- a/tests/WebThumbnailer/Utils/DataUtilsTest.php +++ b/tests/WebThumbnailer/Utils/DataUtilsTest.php @@ -2,7 +2,7 @@ namespace WebThumbnailer\Utils; -use PHPUnit\Framework\TestCase; +use WebThumbnailer\TestCase; /** * Class DataUtilsTest diff --git a/tests/WebThumbnailer/Utils/FileUtilsTests.php b/tests/WebThumbnailer/Utils/FileUtilsTests.php index 9e70830..e12fafa 100644 --- a/tests/WebThumbnailer/Utils/FileUtilsTests.php +++ b/tests/WebThumbnailer/Utils/FileUtilsTests.php @@ -2,7 +2,7 @@ namespace WebThumbnailer\Utils; -use PHPUnit\Framework\TestCase; +use WebThumbnailer\TestCase; /** * Class FileUtilsTests diff --git a/tests/WebThumbnailer/Utils/FinderUtilsTest.php b/tests/WebThumbnailer/Utils/FinderUtilsTest.php index dbd3d4d..3de568f 100644 --- a/tests/WebThumbnailer/Utils/FinderUtilsTest.php +++ b/tests/WebThumbnailer/Utils/FinderUtilsTest.php @@ -2,7 +2,7 @@ namespace WebThumbnailer\Utils; -use PHPUnit\Framework\TestCase; +use WebThumbnailer\TestCase; /** * Class FinderUtilsTest diff --git a/tests/WebThumbnailer/Utils/ImageUtilsTest.php b/tests/WebThumbnailer/Utils/ImageUtilsTest.php index cbe6238..30a4307 100644 --- a/tests/WebThumbnailer/Utils/ImageUtilsTest.php +++ b/tests/WebThumbnailer/Utils/ImageUtilsTest.php @@ -2,8 +2,8 @@ namespace WebThumbnailer\Utils; -use PHPUnit\Framework\TestCase; use WebThumbnailer\Exception\NotAnImageException; +use WebThumbnailer\TestCase; /** * Class ImageUtilsTest diff --git a/tests/WebThumbnailer/Utils/UrlUtilsTest.php b/tests/WebThumbnailer/Utils/UrlUtilsTest.php index 735c93a..1579904 100644 --- a/tests/WebThumbnailer/Utils/UrlUtilsTest.php +++ b/tests/WebThumbnailer/Utils/UrlUtilsTest.php @@ -2,7 +2,7 @@ namespace WebThumbnailer\Utils; -use PHPUnit\Framework\TestCase; +use WebThumbnailer\TestCase; /** * Class UrlUtilsTest diff --git a/tests/WebThumbnailer/WebThumbnailerTest.php b/tests/WebThumbnailer/WebThumbnailerTest.php index 6b13db7..0eb7c16 100644 --- a/tests/WebThumbnailer/WebThumbnailerTest.php +++ b/tests/WebThumbnailer/WebThumbnailerTest.php @@ -94,7 +94,7 @@ public function testDirectImageWithoutExtension() */ public function testOpenGraphImage() { - $image = 'default/le-monde.png'; + $image = 'default/le-monde.jpg'; $this->regenerate($image); $expected = self::$regenerated . $image; $url = self::LOCAL_SERVER . 'default/le-monde.html'; diff --git a/tests/WebThumbnailer/resources/expected-thumbs/default/le-monde.jpg b/tests/WebThumbnailer/resources/expected-thumbs/default/le-monde.jpg new file mode 100644 index 0000000..c99e227 Binary files /dev/null and b/tests/WebThumbnailer/resources/expected-thumbs/default/le-monde.jpg differ