From 4ce19696b6340f3f11bb12a0e89a4e31e0f59a4f Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Thu, 26 Oct 2023 16:25:42 +0300 Subject: [PATCH] Update dependencies for PHP 8.1 and Symfony 6.* (#27) * update deps for php 8.* and symfony 6.* --- .github/workflows/ci.yml | 10 +++++++ composer.json | 42 +++++++++++++++--------------- phpunit.xml.dist | 2 +- tests/BundleInitializationTest.php | 23 ++++++++++++++-- 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4bb08e..cd05566 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,18 @@ jobs: matrix: php-version: - '7.4' + - '8.1' symfony-version: - '4.4.*' - '5.4.*' + - '6.2.*' + exclude: + - php-version: '8.1' + symfony-version: '4.4.*' + - php-version: '8.1' + symfony-version: '5.4.*' + - php-version: '7.4' + symfony-version: '6.2.*' coverage: [ 'none' ] steps: - name: "Checkout" @@ -47,6 +56,7 @@ jobs: php-version: - '7.4' - '8.0' + - '8.1' steps: - name: "Checkout" uses: "actions/checkout@v2" diff --git a/composer.json b/composer.json index d0071cb..b267b75 100644 --- a/composer.json +++ b/composer.json @@ -9,32 +9,32 @@ }], "require": { "php": ">=7.4", - "symfony/framework-bundle" : "^4.0|^5.0", - "symfony/yaml": "^4.0|^5.0" + "symfony/framework-bundle" : "^4.0|^5.0|^6.0", + "symfony/yaml": "^4.0|^5.0|^6.0" }, "require-dev": { "nyholm/symfony-bundle-test": "^2.0", - "phpunit/phpunit": "^8.5", - "symfony/phpunit-bridge": "^5.0", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/event-dispatcher": "^4.4|^5.0", - "symfony/error-handler": "^4.4|^5.0", - "symfony/http-kernel": "^4.4|^5.0", - "symfony/http-foundation": "^4.4|^5.0", - "symfony/deprecation-contracts": "^1.1|^2.0", - "symfony/event-dispatcher-contracts": "^1.1|^2.0", - "symfony/routing": "^4.4|^5.0", - "symfony/finder": "^4.4|^5.0", - "symfony/filesystem": "^4.4|^5.0", + "phpunit/phpunit": "^8.5|^9.5", + "symfony/phpunit-bridge": "^5.0|^6.0", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/event-dispatcher": "^4.4|^5.0|^6.0", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/deprecation-contracts": "^1.1|^2.0|^3", + "symfony/event-dispatcher-contracts": "^1.1|^2.0|^3", + "symfony/routing": "^4.4|^5.0|^6.0", + "symfony/finder": "^4.4|^5.0|^6.0", + "symfony/filesystem": "^4.4|^5.0|^6.0", "symfony/translation-contracts": "^1.1|^2.0", - "symfony/var-exporter": "^4.4|^5.0", - "symfony/var-dumper": "^4.4|^5.0", - "psr/log": "~1.0", + "symfony/var-exporter": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0", + "psr/log": "~1.0|^2|^3", "friendsofphp/php-cs-fixer": "3.4", - "twig/twig": "^v2.14", - "symfony/twig-bundle": "^4.4|^5.0", - "symfony/twig-bridge": "^4.4|^5.0" + "twig/twig": "^v2.14 || ^3.0", + "symfony/twig-bundle": "^4.4|^5.0|^6.0", + "symfony/twig-bridge": "^4.4|^5.0|^6.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 29395f1..cf68f8e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -21,7 +21,7 @@ - + diff --git a/tests/BundleInitializationTest.php b/tests/BundleInitializationTest.php index ca1c960..1c95f41 100644 --- a/tests/BundleInitializationTest.php +++ b/tests/BundleInitializationTest.php @@ -33,7 +33,13 @@ protected static function createKernel(array $options = []): KernelInterface public function testInitBundle(): void { self::bootKernel(); - $container = self::$container; + $symfony = self::getSymfonyVersion(); + + if (version_compare($symfony, '5.0.0') >= 0) { + $container = self::getContainer(); + } else { + $container = self::$container; + } $this->assertTrue($container->has(Stopwatch::class)); $this->assertTrue($container->has('intaro_pinba.stopwatch')); @@ -44,9 +50,22 @@ public function testInitBundle(): void public function testTwigRenderStopwatch(): void { self::bootKernel(); - $container = self::$container; + $symfony = self::getSymfonyVersion(); + + if (version_compare($symfony, '5.0.0') >= 0) { + $container = self::getContainer(); + } else { + $container = self::$container; + } $service = $container->get('twig'); $this->assertInstanceOf(TimedTwigEnvironment::class, $service); } + + private static function getSymfonyVersion() + { + $kernel = self::bootKernel(); + + return $kernel::VERSION; + } }