From 3f8bc8390d4b3251ae08274520a7e2c06e52aaef Mon Sep 17 00:00:00 2001 From: sorrx Date: Mon, 18 Dec 2023 11:58:10 +0100 Subject: [PATCH] Support Symfony 7 and bump latest testet PHP version to 8.3 --- .github/workflows/test.yml | 26 +++++++++++++------------ composer.json | 12 ++++++------ tests/BundleInitializationTest.php | 31 +++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 027cc88..eeb5699 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,23 +11,25 @@ jobs: strategy: matrix: # Earliest and latest version of each major version - php-versions: ['7.2', '7.4', '8.0', '8.2'] + php-versions: ['7.2', '7.4', '8.0', '8.3'] prefer: ['prefer-stable', 'prefer-lowest'] - symfony-versions: ['^3.4', '^4', '^5', '^6'] + symfony-versions: ['^5.4', '^6', '^7'] include: - - symfony-versions: '^3.4' - symfony-bundle-test-version: '^1.8' + - symfony-versions: '^7' + symfony7-required-yaml-version: '^6 || ^7' exclude: + # Symfony 7 requires at least PHP 8.2 + - php-versions: '7.2' + symfony-versions: '^7' + - php-versions: '7.4' + symfony-versions: '^7' + - php-versions: '8.0' + symfony-versions: '^7' # Symfony 6 requires PHP 8 - php-versions: '7.2' symfony-versions: '^6' - php-versions: '7.4' symfony-versions: '^6' - # Symfony 3.4 with PHP 8 is possible, though we skip it to reduce the number of jobs - - php-versions: '8.0' - symfony-versions: '^3.4' - - php-versions: '8.1' - symfony-versions: '^3.4' name: Test PHP ${{ matrix.php-versions }}, Symfony ${{ matrix.symfony-versions }}, ${{ matrix.prefer }} steps: @@ -53,12 +55,12 @@ jobs: - name: Install dependencies run: | - if [ -n "${{ matrix.symfony-bundle-test-version }}" ]; then - composer require --dev --no-update "nyholm/symfony-bundle-test:${{ matrix.symfony-bundle-test-version }}" - fi for symfony_package in $(jq -r '.require | keys[]' composer.json | grep '^symfony/'); do composer require --no-update "${symfony_package}:${{ matrix.symfony-versions }}" done + if [ -n "${{ matrix.symfony7-required-yaml-version }}" ]; then + composer require --dev --no-update "symfony/yaml:${{ matrix.symfony7-required-yaml-version }}" + fi composer --prefer-dist --${{ matrix.prefer }} update - name: Setup problem matchers for PHPUnit diff --git a/composer.json b/composer.json index efab0bd..de9ffae 100644 --- a/composer.json +++ b/composer.json @@ -17,17 +17,17 @@ "wiki": "https://github.com/shivas/versioning-bundle/wiki" }, "require": { - "php": "^7.2 || ^8", + "php": "^7.2.5 || ^8", "nikolaposa/version": "^4", - "symfony/console": "^3.4 || ^4 || ^5 || ^6", - "symfony/framework-bundle": "^3.4 || ^4 || ^5 || ^6", - "symfony/process": "^3.4 || ^4 || ^5 || ^6" + "symfony/console": "^5.4 || ^6 || ^7", + "symfony/framework-bundle": "^5.4 || ^6 || ^7", + "symfony/process": "^5.4 || ^6 || ^7" }, "require-dev": { "mikey179/vfsstream": "^2", - "nyholm/symfony-bundle-test": "1.x-dev", + "nyholm/symfony-bundle-test": "^3.0", "phpunit/phpunit": "^8.5.27", - "symfony/phpunit-bridge": "^5 || ^6", + "symfony/phpunit-bridge": "^5.4 || ^6 || ^7", "twig/twig": "^2 || ^3" }, "config": { diff --git a/tests/BundleInitializationTest.php b/tests/BundleInitializationTest.php index 4cf731f..b3398d0 100644 --- a/tests/BundleInitializationTest.php +++ b/tests/BundleInitializationTest.php @@ -3,8 +3,7 @@ namespace Shivas\VersioningBundle\Tests; -use Nyholm\BundleTest\BaseBundleTestCase; -use Nyholm\BundleTest\CompilerPass\PublicServicePass; +use Nyholm\BundleTest\TestKernel; use Shivas\VersioningBundle\Formatter\FormatterInterface; use Shivas\VersioningBundle\Formatter\GitDescribeFormatter; use Shivas\VersioningBundle\Provider\GitRepositoryProvider; @@ -17,22 +16,36 @@ use Shivas\VersioningBundle\Twig\VersionExtension; use Shivas\VersioningBundle\Writer\VersionWriter; use Shivas\VersioningBundle\Writer\WriterInterface; +use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\HttpKernel\KernelInterface; /** * @covers \Shivas\VersioningBundle\ShivasVersioningBundle */ -class BundleInitializationTest extends BaseBundleTestCase +class BundleInitializationTest extends KernelTestCase { - protected function setUp(): void + protected static function getKernelClass(): string { - parent::setUp(); - - $this->addCompilerPass(new PublicServicePass('/^Shivas\\\\VersioningBundle\\\\|^shivas_versioning.twig.version$/')); + return TestKernel::class; } - protected function getBundleClass(): string + protected static function createKernel(array $options = []): KernelInterface { - return ShivasVersioningBundle::class; + /** @var TestKernel $kernel */ + $kernel = parent::createKernel($options); + $kernel->addTestBundle(ShivasVersioningBundle::class); + $kernel->addTestCompilerPass(new class implements CompilerPassInterface { + public function process(ContainerBuilder $container): void + { + // Service would be removed because it's unused. + $container->findDefinition('shivas_versioning.twig.version')->setPublic(true); + } + }); + $kernel->handleOptions($options); + + return $kernel; } public function testInitBundle()