Skip to content

Commit

Permalink
Support PHP 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
craig410 committed Oct 1, 2024
1 parent cd78555 commit 1579032
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 48 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Unreleased

### v2.1.0 (2024-10-01)

* Support PHP 8.3

### v2.0.2 (2024-02-07)

* Support ingenerator/php-utils:^2.0
Expand Down
4 changes: 2 additions & 2 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
timeout: 180s
steps:
- id: 'build:composer'
name: 'eu.gcr.io/ingenerator-ci/ingenerator-php:8.2'
name: 'eu.gcr.io/ingenerator-ci/ingenerator-php:8.3'
entrypoint: 'composer'
args:
- 'install'
- '--no-interaction'
- id: 'test:unit'
name: 'eu.gcr.io/ingenerator-ci/ingenerator-php:8.2'
name: 'eu.gcr.io/ingenerator-ci/ingenerator-php:8.3'
dir: '/workspace'
entrypoint: './vendor/bin/phpunit'
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
}
],
"require": {
"php": "~8.2.0",
"php": "~8.3.0",
"ext-ffi": "*",
"ingenerator/php-utils": "^1.17 || ^2.0",
"jcupitt/vips": "^2.1",
"symfony/process": "^5.4 || ^6.0 || ^7.0"
"symfony/process": "^7.0"
},
"require-dev": {
"johnkary/phpunit-speedtrap": "^3.3",
"phpunit/phpunit": "^9.5",
"ergebnis/phpunit-slow-test-detector": "^2.6",
"phpunit/phpunit": "^11.0",
"symfony/filesystem": "^7.0"
},
"autoload": {
Expand All @@ -28,13 +28,13 @@
},
"autoload-dev": {
"psr-4": {
"test\\unit\\Ingenerator\\ImageProcessing\\": "test"
"test\\": "test/"
}
},
"config": {
"platform": {
"php": "8.2",
"ext-ffi": "8.2"
"php": "8.3",
"ext-ffi": "8.3"
},
"preferred-install": "dist",
"sort-packages": true
Expand Down
40 changes: 19 additions & 21 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="test/phpunit-bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
convertDeprecationsToExceptions="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
failOnDeprecation="true"
failOnNotice="true"
failOnWarning="true"
failOnRisky="true"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
<testsuites>
<testsuite name="unit">
<directory>test/unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
<arguments>
<array>
<element key="slowThreshold">
<integer>200</integer>
</element>
<element key="reportLength">
<integer>20</integer>
</element>
</array>
</arguments>
</listener>
</listeners>
<extensions>
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
<parameter name="maximum-count" value="20"/>
<parameter name="maximum-duration" value="200"/>
</bootstrap>
</extensions>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* @author Craig Gosman <craig@ingenerator.com>
*/

namespace test\unit\Ingenerator\ImageProcessing\Processor;
namespace test\unit\Processor;

use Ingenerator\ImageProcessing\Processor\ImageProcessorInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Ingenerator\ImageProcessing\Processor\ImageCompare;
use Symfony\Component\Filesystem\Filesystem;
Expand All @@ -16,14 +17,14 @@
use const PATHINFO_EXTENSION;
use const PATHINFO_FILENAME;

abstract class BaseImageProcessorTest extends TestCase
abstract class BaseImageProcessorTestCases extends TestCase
{
private const RESOURCE_DIR = __DIR__.'/../../resources/';
private const OUTPUT_DIR = __DIR__.'/../../output/';

abstract protected function newSubject(): ImageProcessorInterface;

public function providerImageSize(): array
public static function providerImageSize(): array
{
return [
[self::RESOURCE_DIR.'crop_400.jpg', FALSE, [400, 400]],
Expand All @@ -35,26 +36,22 @@ public function providerImageSize(): array
];
}

/**
* @dataProvider providerImageSize
*/
#[DataProvider('providerImageSize')]
public function test_get_image_size(string $source_path, bool $auto_rotate, array $expect): void
{
$subject = $this->newSubject();
$this->assertSame($expect, $subject::getImageSize($source_path, $auto_rotate));
}

public function providerCreatePlaceholder(): array
public static function providerCreatePlaceholder(): array
{
return [
'JPEG placeholder' => [600, 400, self::RESOURCE_DIR.'placeholder.jpg'],
'PNG placeholder' => [200, 200, self::RESOURCE_DIR.'placeholder.png'],
];
}

/**
* @dataProvider providerCreatePlaceholder
*/
#[DataProvider('providerCreatePlaceholder')]
public function test_create_placeholder($width, $height, $path_expected_result): void
{
$subject = $this->newSubject();
Expand All @@ -69,7 +66,7 @@ public function test_create_placeholder($width, $height, $path_expected_result):
$this->assertTrue(ImageCompare::isSame($path_expected_result, $output_file));
}

public function providerThumbnailOperations(): array
public static function providerThumbnailOperations(): array
{
return [
'Scale down proportionately' => [
Expand Down Expand Up @@ -185,9 +182,7 @@ public function providerThumbnailOperations(): array
];
}

/**
* @dataProvider providerThumbnailOperations
*/
#[DataProvider('providerThumbnailOperations')]
public function test_thumbnail(string $source_image, array $operations, string $path_expected_result): void
{
$operations = array_merge(
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Processor/CLIImageProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* @author Craig Gosman <craig@ingenerator.com>
*/

namespace test\unit\Ingenerator\ImageProcessing\Processor;
namespace test\unit\Processor;

use Ingenerator\ImageProcessing\Processor\CLIImageProcessor;

class CLIImageProcessorTest extends BaseImageProcessorTest
class CLIImageProcessorTest extends BaseImageProcessorTestCases
{
protected function newSubject(): CLIImageProcessor
{
Expand Down
4 changes: 2 additions & 2 deletions test/unit/Processor/ImageOperationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* @author Craig Gosman <craig@ingenerator.com>
*/

namespace test\unit\Ingenerator\ImageProcessing\Processor;
namespace test\unit\Processor;

use Ingenerator\ImageProcessing\Processor\ImageOperations;

class ImageOperationsTest extends BaseImageProcessorTest
class ImageOperationsTest extends BaseImageProcessorTestCases
{
protected function newSubject(): ImageOperations
{
Expand Down

0 comments on commit 1579032

Please sign in to comment.