From 5507499f956364b8e96ac02ec5710b4b6e0ec666 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Wed, 3 Aug 2022 17:34:33 -0400 Subject: [PATCH 1/5] Add glide test --- .gitignore | 1 + tests/GlideTest.php | 51 +++++++++++++++++++++++++ tests/ImageFileInspectorTest.php | 2 +- tests/fixtures/{ => source}/square.jpg | Bin 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/GlideTest.php rename tests/fixtures/{ => source}/square.jpg (100%) diff --git a/.gitignore b/.gitignore index ad25bce..13b5319 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.swp /__tmp__ +/tests/fixtures/__cache__ /vendor /composer.lock /.php_cs.cache diff --git a/tests/GlideTest.php b/tests/GlideTest.php new file mode 100644 index 0000000..b160784 --- /dev/null +++ b/tests/GlideTest.php @@ -0,0 +1,51 @@ +sourcePath = __DIR__ . '/fixtures/source'; + + $this->cachePath = __DIR__ . '/fixtures/__cache__'; + + $this->factory = new ImageFactory([ + 'sourcePath' => $this->sourcePath, + 'cachePath' => $this->cachePath, + 'sourceUrlBase' => '/images/source', + 'cacheUrlBase' => '/images/cache', + ]); + + $this->cleanCacheDirectories(); + } + + protected function cleanCacheDirectories() + { + if (file_exists($this->cachePath . '/square.jpg')) { + foreach (glob($this->cachePath . '/square.jpg/*') as $file) { + unlink($file); + } + + rmdir($this->cachePath . '/square.jpg'); + } + } + + public function test_can_transform_source_image() + { + $this->assertFalse(file_exists($this->cachePath . '/square.jpg')); + + $image = $this->factory->image('square.jpg'); + + $this->assertTrue(file_exists($this->cachePath . '/square.jpg')); + $this->assertTrue(file_exists($image->cached()->path())); + } +} diff --git a/tests/ImageFileInspectorTest.php b/tests/ImageFileInspectorTest.php index 2a0c062..7474490 100644 --- a/tests/ImageFileInspectorTest.php +++ b/tests/ImageFileInspectorTest.php @@ -14,7 +14,7 @@ public function test_can_inspect_size() { $inspector = new ImageFileInspector(); - $size = $inspector->getSize(__DIR__ . '/fixtures/square.jpg'); + $size = $inspector->getSize(__DIR__ . '/fixtures/source/square.jpg'); $this->assertEquals(100, $size['width']); $this->assertEquals(100, $size['height']); diff --git a/tests/fixtures/square.jpg b/tests/fixtures/source/square.jpg similarity index 100% rename from tests/fixtures/square.jpg rename to tests/fixtures/source/square.jpg From 53e8328d47f328a1da222fd2abc0c93e49c80897 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Wed, 3 Aug 2022 17:54:47 -0400 Subject: [PATCH 2/5] Update league/glide version constraint --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b8a822a..c35b72a 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": ">=8.0", - "league/glide": "^2.2" + "league/glide": "^1.0|^2.0" }, "require-dev": { "phpunit/phpunit": "^9.5", From 2ee061b9558f8a5c48c2b2a98b336845e7761474 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Wed, 3 Aug 2022 18:06:48 -0400 Subject: [PATCH 3/5] Add glide versions to 'tests' github action --- .github/workflows/tests.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7c68cb0..9afca02 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,6 +14,7 @@ jobs: fail-fast: false matrix: php: ['8.0', '8.1'] + glide: ['1.*', '2.*'] name: P${{ matrix.php }} @@ -30,13 +31,14 @@ jobs: uses: actions/cache@v2 with: path: vendor - key: ${{ runner.os }}-node-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-${{matrix.php}}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-node- + ${{ runner.os }}-${{matrix.php}}-composer- - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer install --prefer-dist --no-progress --no-suggest + run: | + composer require "league/glide:${{ matrix.glide }}" --no-interaction --no-update + composer install --prefer-dist --no-interaction --no-plugins - name: Run test suite run: php vendor/bin/phpunit From 36aacf0a48eb7a27ee33f72ca02f4d0aa45b18bc Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Wed, 3 Aug 2022 18:08:31 -0400 Subject: [PATCH 4/5] Update github action --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9afca02..556f919 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,13 +16,13 @@ jobs: php: ['8.0', '8.1'] glide: ['1.*', '2.*'] - name: P${{ matrix.php }} + name: P${{ matrix.php }} G${{ matrix.glide }} steps: - uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} @@ -31,9 +31,9 @@ jobs: uses: actions/cache@v2 with: path: vendor - key: ${{ runner.os }}-${{matrix.php}}-composer-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.glide }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-${{matrix.php}}-composer- + ${{ runner.os }}-${{ matrix.php }}-${{ matrix.glide }}-composer- - name: Install dependencies run: | From a64bea48f04f2edf5434de9871cc2c171c526e72 Mon Sep 17 00:00:00 2001 From: Patrick Boivin Date: Thu, 4 Aug 2022 16:58:50 -0400 Subject: [PATCH 5/5] Update CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e442f2d..98ac834 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Release Notes +## [v1.0.1](https://github.com/pboivin/flou/compare/v1.0.0...v1.0.1) - 2022-08-04 + +#### Fixed + +- Update glide version constraints to allow installation on a wider range of projects + + ## [v1.0.0](https://github.com/pboivin/flou/compare/v1.0.0-beta...v1.0.0) - 2022-08-01 #### Added