From ddbe408d65095c6e8644713d12a14b5394e9b3c5 Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Fri, 30 Jan 2026 22:35:44 +0100 Subject: [PATCH 1/6] Dependency upgrade --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 9dcc70b..4bf64b5 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,12 @@ "psr-4": { "Padam87\\RasterizeBundle\\": "" } }, "require": { - "php": "^8.0", - "symfony/config": "^5.4|^6.0|^7.0", - "symfony/dependency-injection": "^5.4|^6.0|^7.0", - "symfony/http-kernel": "^5.4|^6.0|^7.0", - "symfony/process": "^5.4|^6.0|^7.0", - "symfony/stopwatch": "^5.4|^6.0|^7.0" + "php": "^8.4", + "symfony/config": "^6.0 || ^7.0 || ^8.0", + "symfony/dependency-injection": "^6.0 || ^7.0 || ^8.0", + "symfony/http-kernel": "^6.0 || ^7.0 || ^8.0", + "symfony/process": "^6.0 || ^7.0 || ^8.0", + "symfony/stopwatch": "^6.0 || ^7.0 || ^8.0" }, "require-dev": { "phpunit/phpunit": "~9.0", From 5c1014c49172216e822807a72f3d58d0a0ae522f Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Fri, 30 Jan 2026 23:51:08 +0100 Subject: [PATCH 2/6] Code upgrades --- ConfigHelper.php | 7 +------ DependencyInjection/Configuration.php | 8 ++------ DependencyInjection/Padam87RasterizeExtension.php | 6 +++--- Rasterizer.php | 11 +++-------- Tests/ConfigHelperTest.php | 7 +++---- Tests/RasterizerTest.php | 5 ++--- 6 files changed, 14 insertions(+), 30 deletions(-) diff --git a/ConfigHelper.php b/ConfigHelper.php index c147137..b9d6086 100644 --- a/ConfigHelper.php +++ b/ConfigHelper.php @@ -7,13 +7,8 @@ class ConfigHelper { - private array $config; - private string $projectDir; - - public function __construct(string $projectDir, array $config) + public function __construct(private string $projectDir, private array $config) { - $this->config = $config; - $this->projectDir = $projectDir; } public function buildProcess(InputStream $input, array $arguments = [], array $env = []): Process diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 13c7a4e..7a1e6e9 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -33,12 +33,8 @@ public function getConfigTreeBuilder(): TreeBuilder ] ) ->beforeNormalization() - ->ifTrue(function ($v) { - return !isset($v['format']); - }) - ->then(function ($v) { - return array_merge(['format' => 'pdf'], $v); - }) + ->ifTrue(fn(array $v) => !isset($v['format'])) + ->then(fn($v) => array_merge(['format' => 'pdf'], $v)) ->end() ->prototype('scalar')->end() ->end() diff --git a/DependencyInjection/Padam87RasterizeExtension.php b/DependencyInjection/Padam87RasterizeExtension.php index d7da324..de2d987 100644 --- a/DependencyInjection/Padam87RasterizeExtension.php +++ b/DependencyInjection/Padam87RasterizeExtension.php @@ -2,10 +2,10 @@ namespace Padam87\RasterizeBundle\DependencyInjection; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\Loader; /** * This is the class that loads and manages your bundle configuration @@ -17,12 +17,12 @@ class Padam87RasterizeExtension extends Extension /** * {@inheritDoc} */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yaml'); $container->setParameter('padam87_rasterize.config', $config); diff --git a/Rasterizer.php b/Rasterizer.php index 34c1496..84c9353 100644 --- a/Rasterizer.php +++ b/Rasterizer.php @@ -7,16 +7,11 @@ class Rasterizer { - protected ConfigHelper $configHelper; - protected ?Stopwatch $stopwatch; - - public function __construct(ConfigHelper $configHelper, Stopwatch $stopwatch = null) + public function __construct(protected ConfigHelper $configHelper, protected ?Stopwatch $stopwatch = null) { - $this->configHelper = $configHelper; - $this->stopwatch = $stopwatch; } - public function rasterize(string $html, array $arguments = [], array $env = [], callable $callback = null): string + public function rasterize(string $html, array $arguments = [], array $env = [], ?callable $callback = null): string { if ($this->stopwatch instanceof Stopwatch) { $this->stopwatch->start('rasterizer'); @@ -26,7 +21,7 @@ public function rasterize(string $html, array $arguments = [], array $env = [], $process = $this->configHelper->buildProcess($input, $arguments, $env); - if ($callback) { + if ($callback !== null) { $callback($process); } diff --git a/Tests/ConfigHelperTest.php b/Tests/ConfigHelperTest.php index 9b2b8fc..647354a 100644 --- a/Tests/ConfigHelperTest.php +++ b/Tests/ConfigHelperTest.php @@ -7,7 +7,6 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Process\InputStream; use Symfony\Component\Process\Process; -use Symfony\Component\Process\ProcessUtils; class ConfigHelperTest extends TestCase { @@ -40,7 +39,7 @@ public function setUp(): void /** * @test */ - public function isTheProcessBuilt() + public function isTheProcessBuilt(): void { $configHelper = new ConfigHelper(__DIR__, $this->config); $process = $configHelper->buildProcess(new InputStream()); @@ -58,7 +57,7 @@ public function isTheProcessBuilt() /** * @test */ - public function attributeMerge() + public function attributeMerge(): void { $configHelper = new ConfigHelper(__DIR__, $this->config); $process = $configHelper->buildProcess(new InputStream(), ['paper' => 'A4']); @@ -72,7 +71,7 @@ public function attributeMerge() /** * @test */ - public function envMerge() + public function envMerge(): void { $configHelper = new ConfigHelper(__DIR__, $this->config); $process = $configHelper->buildProcess(new InputStream(), [], ['MY_ENV' => 'something']); diff --git a/Tests/RasterizerTest.php b/Tests/RasterizerTest.php index d6b4da4..ce291f1 100644 --- a/Tests/RasterizerTest.php +++ b/Tests/RasterizerTest.php @@ -3,7 +3,6 @@ namespace Padam87\RasterizeBundle\Tests; use Mockery as m; -use Mockery\MockInterface; use Padam87\RasterizeBundle\ConfigHelper; use Padam87\RasterizeBundle\Rasterizer; use PHPUnit\Framework\TestCase; @@ -31,7 +30,7 @@ public function setUp(): void /** * @test */ - public function testRasterize() + public function testRasterize(): void { $this->stopwatch->shouldReceive('start')->once(); $this->stopwatch->shouldReceive('stop')->once(); @@ -50,7 +49,7 @@ public function testRasterize() /** * @test */ - public function testCallback() + public function testCallback(): void { $this->stopwatch->shouldReceive('start')->once(); $this->stopwatch->shouldReceive('stop')->once(); From 61dd1664f64de1017911afb8af843d29c3a2d477 Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Fri, 30 Jan 2026 23:51:14 +0100 Subject: [PATCH 3/6] Update ci.yaml --- .github/workflows/ci.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6849e88..08ae473 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,19 +11,15 @@ on: jobs: phpunit: name: "PHPUnit" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-24.04" strategy: matrix: php-version: - - "8.0" - - "8.1" + - "8.4" dependencies: - "highest" - include: - - php-version: "8.0" - dependencies: "lowest" - + - "lowest" steps: - name: "Checkout" uses: "actions/checkout@v2" From af2a7972f1625304f99cc6cad2966350b375da8f Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Fri, 30 Jan 2026 23:55:01 +0100 Subject: [PATCH 4/6] Update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4bf64b5..4be54c8 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,8 @@ "symfony/stopwatch": "^6.0 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "~9.0", - "mockery/mockery": "~1.4" + "phpunit/phpunit": "~12.0", + "mockery/mockery": "~1.6" }, "scripts": { "test": "phpunit" From 57fb94f547c867a419e4c308853875dfc02154a7 Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Fri, 30 Jan 2026 23:59:07 +0100 Subject: [PATCH 5/6] PHPUnit upgrade --- Tests/ConfigHelperTest.php | 13 ++++--------- Tests/RasterizerTest.php | 10 ++++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Tests/ConfigHelperTest.php b/Tests/ConfigHelperTest.php index 647354a..4d8f2b5 100644 --- a/Tests/ConfigHelperTest.php +++ b/Tests/ConfigHelperTest.php @@ -4,6 +4,7 @@ use Padam87\RasterizeBundle\ConfigHelper; use Mockery as m; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Process\InputStream; use Symfony\Component\Process\Process; @@ -36,9 +37,7 @@ public function setUp(): void ]; } - /** - * @test - */ + #[Test] public function isTheProcessBuilt(): void { $configHelper = new ConfigHelper(__DIR__, $this->config); @@ -54,9 +53,7 @@ public function isTheProcessBuilt(): void $this->assertCount(1, $process->getEnv()); } - /** - * @test - */ + #[Test] public function attributeMerge(): void { $configHelper = new ConfigHelper(__DIR__, $this->config); @@ -68,9 +65,7 @@ public function attributeMerge(): void ); } - /** - * @test - */ + #[Test] public function envMerge(): void { $configHelper = new ConfigHelper(__DIR__, $this->config); diff --git a/Tests/RasterizerTest.php b/Tests/RasterizerTest.php index ce291f1..eb98214 100644 --- a/Tests/RasterizerTest.php +++ b/Tests/RasterizerTest.php @@ -5,6 +5,7 @@ use Mockery as m; use Padam87\RasterizeBundle\ConfigHelper; use Padam87\RasterizeBundle\Rasterizer; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; use Symfony\Component\Stopwatch\Stopwatch; @@ -27,9 +28,8 @@ public function setUp(): void $this->process = m::mock(Process::class); } - /** - * @test - */ + + #[Test] public function testRasterize(): void { $this->stopwatch->shouldReceive('start')->once(); @@ -46,9 +46,7 @@ public function testRasterize(): void $this->assertSame('pdfcontent', $rasterizer->rasterize('')); } - /** - * @test - */ + #[Test] public function testCallback(): void { $this->stopwatch->shouldReceive('start')->once(); From e20122b21db3a40d36e05d82d0511c8f26bec42f Mon Sep 17 00:00:00 2001 From: Adam Prager Date: Sat, 31 Jan 2026 02:09:30 +0100 Subject: [PATCH 6/6] Test suite fix --- Tests/ConfigHelperTest.php | 6 ------ Tests/RasterizerTest.php | 38 ++++++++++++++++---------------------- composer.json | 3 +-- phpunit.xml.dist | 31 ++++++++++++++----------------- 4 files changed, 31 insertions(+), 47 deletions(-) diff --git a/Tests/ConfigHelperTest.php b/Tests/ConfigHelperTest.php index 4d8f2b5..2214940 100644 --- a/Tests/ConfigHelperTest.php +++ b/Tests/ConfigHelperTest.php @@ -3,7 +3,6 @@ namespace Padam87\RasterizeBundle\Tests; use Padam87\RasterizeBundle\ConfigHelper; -use Mockery as m; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Symfony\Component\Process\InputStream; @@ -16,11 +15,6 @@ class ConfigHelperTest extends TestCase */ protected $config; - protected function tearDown(): void - { - m::close(); - } - public function setUp(): void { $this->config = [ diff --git a/Tests/RasterizerTest.php b/Tests/RasterizerTest.php index eb98214..e322123 100644 --- a/Tests/RasterizerTest.php +++ b/Tests/RasterizerTest.php @@ -2,7 +2,6 @@ namespace Padam87\RasterizeBundle\Tests; -use Mockery as m; use Padam87\RasterizeBundle\ConfigHelper; use Padam87\RasterizeBundle\Rasterizer; use PHPUnit\Framework\Attributes\Test; @@ -16,30 +15,25 @@ class RasterizerTest extends TestCase private $stopwatch; private $process; - protected function tearDown(): void - { - m::close(); - } - public function setUp(): void { - $this->configHelper = m::mock(ConfigHelper::class); - $this->stopwatch = m::mock(Stopwatch::class); - $this->process = m::mock(Process::class); + $this->configHelper = $this->createMock(ConfigHelper::class); + $this->stopwatch = $this->createMock(Stopwatch::class); + $this->process = $this->createMock(Process::class); } #[Test] public function testRasterize(): void { - $this->stopwatch->shouldReceive('start')->once(); - $this->stopwatch->shouldReceive('stop')->once(); + $this->stopwatch->expects($this->once())->method('start'); + $this->stopwatch->expects($this->once())->method('stop'); - $this->configHelper->shouldReceive('buildProcess')->once()->andReturn($this->process); + $this->configHelper->expects($this->once())->method('buildProcess')->willReturn($this->process); - $this->process->shouldReceive('start'); - $this->process->shouldReceive('wait'); - $this->process->shouldReceive('getOutput')->andReturn('pdfcontent'); + $this->process->expects($this->any())->method('start'); + $this->process->expects($this->any())->method('wait'); + $this->process->expects($this->any())->method('getOutput')->willReturn('pdfcontent'); $rasterizer = new Rasterizer($this->configHelper, $this->stopwatch); @@ -49,15 +43,15 @@ public function testRasterize(): void #[Test] public function testCallback(): void { - $this->stopwatch->shouldReceive('start')->once(); - $this->stopwatch->shouldReceive('stop')->once(); + $this->stopwatch->expects($this->once())->method('start'); + $this->stopwatch->expects($this->once())->method('stop'); - $this->configHelper->shouldReceive('buildProcess')->once()->andReturn($this->process); + $this->configHelper->expects($this->once())->method('buildProcess')->willReturn($this->process); - $this->process->shouldReceive('start'); - $this->process->shouldReceive('wait'); - $this->process->shouldReceive('setTimeout'); - $this->process->shouldReceive('getOutput')->andReturn('pdfcontent'); + $this->process->expects($this->any())->method('start'); + $this->process->expects($this->any())->method('wait'); + $this->process->expects($this->any())->method('setTimeout'); + $this->process->expects($this->any())->method('getOutput')->willReturn('pdfcontent'); $rasterizer = new Rasterizer($this->configHelper, $this->stopwatch); $output = $rasterizer->rasterize('', [], [], function (Process $process) { diff --git a/composer.json b/composer.json index 4be54c8..4194f49 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,7 @@ "symfony/stopwatch": "^6.0 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "~12.0", - "mockery/mockery": "~1.6" + "phpunit/phpunit": "^12.0" }, "scripts": { "test": "phpunit" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8305700..decfc2f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,16 @@ - - - - - ./Tests - - - - - - ConfigHelper.php - Rasterizer.php - - - - - + + + + ./Tests + + + + + Tests + + + + +