From 33e79e5db47b932603f0f6e9f9f5478b378f44cc Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 27 Sep 2023 07:09:32 -0300 Subject: [PATCH 1/4] Raise min version to `PHP 7.3`, check compatibility `PHP 8.3`. --- .github/workflows/build.yml | 73 +++++++++++++++---------------------- composer.json | 15 +------- tests/AbstractImageTest.php | 11 +++--- tests/ImageGdTest.php | 2 +- tests/ImageGmagickTest.php | 2 +- tests/ImageImagickTest.php | 2 +- tests/TestCase.php | 2 +- tests/bootstrap.php | 2 - tests/compatibility.php | 50 ------------------------- 9 files changed, 41 insertions(+), 118 deletions(-) delete mode 100644 tests/compatibility.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f904d8c..f4096e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,48 +1,33 @@ -name: build +on: + pull_request: + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'psalm.xml' -on: [push, pull_request] + push: + branches: ['master'] + paths-ignore: + - 'docs/**' + - 'README.md' + - 'CHANGELOG.md' + - '.gitignore' + - '.gitattributes' + - 'infection.json.dist' + - 'psalm.xml' -env: - DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi" +name: build jobs: - phpunit: - name: PHP ${{ matrix.php }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: imagick - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache composer dependencies - uses: actions/cache@v1 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - name: Install dependencies - run: composer update $DEFAULT_COMPOSER_FLAGS - - name: Run unit tests with coverage - run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always - if: matrix.php == '7.1' - - name: Run unit tests without coverage - run: vendor/bin/phpunit --verbose --colors=always - if: matrix.php != '7.1' - - name: Upload code coverage - run: | - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - if: matrix.php == '7.1' - continue-on-error: true # if is fork + phpunit: + uses: yiisoft/actions/.github/workflows/phpunit.yml@master + with: + extensions: imagick, gmagick + os: >- + ['ubuntu-latest'] + php: >- + ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] diff --git a/composer.json b/composer.json index 84d03e3..eb814bb 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,12 @@ } ], "require": { + "php": ">=7.3", "yiisoft/yii2": "~2.0.0", "imagine/imagine": "^1.0" }, "require-dev": { - "cweagans/composer-patches": "^1.7", - "phpunit/phpunit": "4.8.34" + "phpunit/phpunit": "^9.6" }, "autoload": { "psr-4": { @@ -33,16 +33,6 @@ "extra": { "branch-alias": { "dev-master": "2.0.x-dev" - }, - "composer-exit-on-patch-failure": true, - "patches": { - "phpunit/phpunit-mock-objects": { - "Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch" - }, - "phpunit/phpunit": { - "Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch", - "Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch" - } } }, "repositories": [ @@ -53,7 +43,6 @@ ], "config": { "allow-plugins": { - "cweagans/composer-patches": true, "yiisoft/yii2-composer": true } } diff --git a/tests/AbstractImageTest.php b/tests/AbstractImageTest.php index 202b294..e83885d 100644 --- a/tests/AbstractImageTest.php +++ b/tests/AbstractImageTest.php @@ -7,6 +7,7 @@ use yii\imagine\Image; use Imagine\Image\ImageInterface; use Imagine\Image\Point; +use yii\base\InvalidConfigException; abstract class AbstractImageTest extends TestCase { @@ -18,7 +19,7 @@ abstract class AbstractImageTest extends TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { FileHelper::createDirectory(Yii::getAlias('@yiiunit/imagine/runtime')); $this->imageFile = Yii::getAlias('@yiiunit/imagine/data/large.jpg'); @@ -31,7 +32,7 @@ protected function setUp() /** * {@inheritdoc} */ - protected function tearDown() + protected function tearDown(): void { @unlink($this->runtimeTextFile); @unlink($this->runtimeWatermarkFile); @@ -187,13 +188,13 @@ public function providerResize() ]; } - /** - * @expectedException \yii\base\InvalidConfigException - */ public function testShouldThrowExceptionOnDriverInvalidArgument() { Image::setImagine(null); Image::$driver = 'fake-driver'; + + $this->expectException(InvalidConfigException::class); + $this->expectExceptionMessage('Unknown driver: fake-driver'); Image::getImagine(); } diff --git a/tests/ImageGdTest.php b/tests/ImageGdTest.php index 3ba749a..6b19d93 100644 --- a/tests/ImageGdTest.php +++ b/tests/ImageGdTest.php @@ -12,7 +12,7 @@ class ImageGdTest extends AbstractImageTest /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { if (!function_exists('gd_info')) { $this->markTestSkipped('Skipping ImageGdTest, Gd not installed'); diff --git a/tests/ImageGmagickTest.php b/tests/ImageGmagickTest.php index f68aa5b..0db213d 100644 --- a/tests/ImageGmagickTest.php +++ b/tests/ImageGmagickTest.php @@ -12,7 +12,7 @@ class ImageGmagickTest extends AbstractImageTest /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { if (!class_exists('Gmagick')) { $this->markTestSkipped('Skipping ImageGmagickTest, Gmagick is not installed'); diff --git a/tests/ImageImagickTest.php b/tests/ImageImagickTest.php index fec083a..79846b4 100644 --- a/tests/ImageImagickTest.php +++ b/tests/ImageImagickTest.php @@ -12,7 +12,7 @@ class ImageImagickTest extends AbstractImageTest /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { if (!class_exists('Imagick')) { $this->markTestSkipped('Skipping ImageImagickTest, Imagick is not installed'); diff --git a/tests/TestCase.php b/tests/TestCase.php index 8b11b4a..2b61969 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,7 +15,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase * Clean up after test. * By default the application created with [[mockApplication]] will be destroyed. */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); $this->destroyApplication(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d99c8cb..2541676 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -13,5 +13,3 @@ Yii::setAlias('@yiiunit/imagine', __DIR__); Yii::setAlias('@yii/imagine', dirname(__DIR__) . '/src'); - -require_once(__DIR__ . '/compatibility.php'); diff --git a/tests/compatibility.php b/tests/compatibility.php deleted file mode 100644 index 95e4cd1..0000000 --- a/tests/compatibility.php +++ /dev/null @@ -1,50 +0,0 @@ -setExpectedException($exception); - } - - /** - * @param string $message - */ - public function expectExceptionMessage($message) - { - $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase'); - if (in_array('expectExceptionMessage', $parentClassMethods)) { - parent::expectExceptionMessage($message); - return; - } - $this->setExpectedException($this->getExpectedException(), $message); - } - - /** - * @param string $messageRegExp - */ - public function expectExceptionMessageRegExp($messageRegExp) - { - $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase'); - if (in_array('expectExceptionMessageRegExp', $parentClassMethods)) { - parent::expectExceptionMessageRegExp($messageRegExp); - return; - } - $this->setExpectedExceptionRegExp($this->getExpectedException(), $messageRegExp); - } - } - } -} From be7079cda9cf875424f65cb3109a428d5c519fb2 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Wed, 27 Sep 2023 07:16:28 -0300 Subject: [PATCH 2/4] Use extension imagick. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4096e9..bc5a9b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: phpunit: uses: yiisoft/actions/.github/workflows/phpunit.yml@master with: - extensions: imagick, gmagick + extensions: imagick os: >- ['ubuntu-latest'] php: >- From 17d25ce1a9b5e5e05060f2503e7a26f494e6612f Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Fri, 29 Sep 2023 13:07:41 -0300 Subject: [PATCH 3/4] Fix minor corrections. --- .editorconfig | 3 +++ .github/workflows/build.yml | 1 - phpunit.xml.dist | 37 +++++++++++++++++++++++++------------ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.editorconfig b/.editorconfig index 257221d..5e9a93e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,3 +12,6 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc5a9b9..a8c8097 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,6 @@ on: - 'psalm.xml' push: - branches: ['master'] paths-ignore: - 'docs/**' - 'README.md' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a2bff89..1e2b579 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,27 @@ - - - - ./tests - - + + + + + + + + + ./tests + + + + + + ./src + + From c9e6d45d4999b25286a52dbc07cca799d89877c5 Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Fri, 29 Sep 2023 13:09:38 -0300 Subject: [PATCH 4/4] Update `README.md`. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 057a2b2..4e2376c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,12 @@ For license information check the [LICENSE](LICENSE.md)-file. [![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-imagine/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-imagine) [![Total Downloads](https://poser.pugx.org/yiisoft/yii2-imagine/downloads.png)](https://packagist.org/packages/yiisoft/yii2-imagine) [![Build Status](https://github.com/yiisoft/yii2-imagine/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-imagine/actions) +[![codecov](https://codecov.io/gh/yiisoft/yii2-imagine/graph/badge.svg?token=F1oonww6bw)](https://codecov.io/gh/yiisoft/yii2-imagine) +Requirements +------------ + +- PHP 7.3 or higher. Installation ------------