diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79402d1..0755978 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,16 +8,35 @@ on: jobs: tests: - uses: zenstruck/.github/.github/workflows/php-test.yml@main + name: PHP ${{ matrix.php }}, ${{ matrix.deps }} + runs-on: ubuntu-latest + strategy: + matrix: + php: [8.3, 8.4, 8.5] + deps: [highest] + include: + - php: 8.3 + deps: lowest + steps: + - uses: zenstruck/.github/actions/php-test-symfony@main + with: + php: ${{ matrix.php }} + deps: ${{ matrix.deps }} code-coverage: uses: zenstruck/.github/.github/workflows/php-coverage-codecov.yml@main + with: + php: 8.3 composer-validate: uses: zenstruck/.github/.github/workflows/php-composer-validate.yml@main + with: + php: 8.3 sca: uses: zenstruck/.github/.github/workflows/php-stan.yml@main + with: + php: 8.3 fixcs: name: Run php-cs-fixer diff --git a/composer.json b/composer.json index f3809c5..251b793 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,7 @@ } ], "require": { - "php": ">=8.0", - "symfony/polyfill-php81": "^1.26", + "php": ">=8.3", "zenstruck/temp-file": "^1.0" }, "require-dev": { diff --git a/tests/ImageFileInfoTest.php b/tests/ImageFileInfoTest.php index 110270b..ced65bf 100644 --- a/tests/ImageFileInfoTest.php +++ b/tests/ImageFileInfoTest.php @@ -19,6 +19,8 @@ */ final class ImageFileInfoTest extends TestCase { + use TempDirAssertions; + /** * @test * @dataProvider imageMetadataProvider @@ -28,13 +30,13 @@ public function can_get_metadata(string $file, int $height, int $width, string $ $this->metadataAssertions(ImageFileInfo::wrap($file), $height, $width, $mime, $extension); $this->metadataAssertions($image = ImageFileInfo::from(\file_get_contents($file)), $height, $width, $mime, $extension); - $this->assertSame('/tmp', \dirname($image)); + $this->assertInTempDir($image); $this->metadataAssertions($image = ImageFileInfo::from(\fopen($file, 'r')), $height, $width, $mime, $extension); - $this->assertSame('/tmp', \dirname($image)); + $this->assertInTempDir($image); $this->metadataAssertions($image = ImageFileInfo::from(new \SplFileInfo($file)), $height, $width, $mime, $extension); - $this->assertSame('/tmp', \dirname($image)); + $this->assertInTempDir($image); } public static function imageMetadataProvider(): iterable diff --git a/tests/TempDirAssertions.php b/tests/TempDirAssertions.php new file mode 100644 index 0000000..97db8eb --- /dev/null +++ b/tests/TempDirAssertions.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Zenstruck\Image\Tests; + +/** + * @author Kevin Bond + */ +trait TempDirAssertions +{ + /** + * macOS reports its temp directory unresolved but creates files in the + * resolved one, so both sides have to be normalized before comparing. + */ + protected function assertInTempDir(\SplFileInfo $file): void + { + $this->assertSame(\realpath(\sys_get_temp_dir()), \realpath(\dirname($file))); + } +} diff --git a/tests/Transformer/FilterObjectTransformerTestCase.php b/tests/Transformer/FilterObjectTransformerTestCase.php index 3cdcbb2..09f6619 100644 --- a/tests/Transformer/FilterObjectTransformerTestCase.php +++ b/tests/Transformer/FilterObjectTransformerTestCase.php @@ -32,14 +32,14 @@ public function can_transform_into_temp_image_with_filter_object(): void $this->assertSame(100, $resized->dimensions()->width()); $this->assertSame(120, $resized->dimensions()->height()); $this->assertSame('jpg', $resized->getExtension()); - $this->assertSame('/tmp', \dirname($resized)); + $this->assertInTempDir($resized); $resized = $image->transform($this->filterObject(), ['format' => 'png']); $this->assertSame(100, $resized->dimensions()->width()); $this->assertSame(120, $resized->dimensions()->height()); $this->assertSame('png', $resized->getExtension()); - $this->assertSame('/tmp', \dirname($resized)); + $this->assertInTempDir($resized); } /** diff --git a/tests/TransformerTestCase.php b/tests/TransformerTestCase.php index a93bf47..4fda899 100644 --- a/tests/TransformerTestCase.php +++ b/tests/TransformerTestCase.php @@ -20,6 +20,8 @@ */ abstract class TransformerTestCase extends TestCase { + use TempDirAssertions; + /** * @test */ @@ -32,14 +34,14 @@ public function can_transform_into_temp_image(): void $this->assertSame(100, $resized->dimensions()->width()); $this->assertSame(120, $resized->dimensions()->height()); $this->assertSame('jpg', $resized->getExtension()); - $this->assertSame('/tmp', \dirname($resized)); + $this->assertInTempDir($resized); $resized = $image->transform($this->filterCallback(), ['format' => 'png']); $this->assertSame(100, $resized->dimensions()->width()); $this->assertSame(120, $resized->dimensions()->height()); $this->assertSame('png', $resized->getExtension()); - $this->assertSame('/tmp', \dirname($resized)); + $this->assertInTempDir($resized); } /** @@ -90,14 +92,14 @@ public function can_transform_into_temp_image_with_invokable_object(): void $this->assertSame(100, $resized->dimensions()->width()); $this->assertSame(120, $resized->dimensions()->height()); $this->assertSame('jpg', $resized->getExtension()); - $this->assertSame('/tmp', \dirname($resized)); + $this->assertInTempDir($resized); $resized = $image->transform($this->filterCallback(), ['format' => 'png']); $this->assertSame(100, $resized->dimensions()->width()); $this->assertSame(120, $resized->dimensions()->height()); $this->assertSame('png', $resized->getExtension()); - $this->assertSame('/tmp', \dirname($resized)); + $this->assertInTempDir($resized); } /**