From a29c6135408527beafc09721df3f4512451e9f6d Mon Sep 17 00:00:00 2001 From: Nicolas Dievart Date: Wed, 31 Jan 2024 11:36:44 +0100 Subject: [PATCH] chore(symfony): Allow installation on Symfony 7 and test on PHP 8.3 (#180) Refs: #179 Co-authored-by: Damien ALEXANDRE --- .github/workflows/ci.yml | 14 +++++++++++-- README.md | 2 +- composer.json | 18 ++++++++--------- phpunit.xml.dist | 1 + src/Bridge/Symfony/ElasticallyBundle.php | 4 +++- src/Messenger/IndexationRequestInterface.php | 4 +++- .../Messenger/MemoryQueuingFunctionalTest.php | 8 ++++---- .../TestControllerFunctionalTest.php | 4 ++-- tests/SearchTest.php | 20 +++++++++++++++---- 9 files changed, 51 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a11ac8..f0256f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,11 @@ jobs: symfony-version: '6.*' composer-flags: '' es-version: '8.2.0' + # PHP 8.3, latest SF 7, ES 8 + - php-version: '8.3' + symfony-version: '7.*' + composer-flags: '' + es-version: '8.2.0' steps: - name: Checkout uses: actions/checkout@v3 @@ -120,16 +125,21 @@ jobs: fail-fast: false matrix: include: - - php-version: '8.1' + - php-version: '8.3' symfony-version: '6.*' composer-flags: '' os-version: 1.3.6 os-image: opensearchproject/opensearch:1.3.6 - - php-version: '8.1' + - php-version: '8.3' symfony-version: '6.*' composer-flags: '' os-version: 2.3.0 os-image: opensearchproject/opensearch:2.3.0 + - php-version: '8.3' + symfony-version: '7.*' + composer-flags: '' + os-version: 2.3.0 + os-image: opensearchproject/opensearch:2.3.0 services: search-server: image: ${{ matrix.os-image }} diff --git a/README.md b/README.md index a6d6454..336ede6 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Main features: - Symfony HttpClient compatible transport (**optional**); - Symfony support (**optional**): - See dedicated [chapter](#usage-in-symfony); - - Tested with Symfony 5.4 to 6; + - Tested with Symfony 5.4 to 7; - Symfony Messenger Handler support (with or without spool); > [!IMPORTANT] diff --git a/composer.json b/composer.json index d425e49..ea6afe3 100644 --- a/composer.json +++ b/composer.json @@ -20,10 +20,10 @@ "phpdocumentor/reflection-docblock": "^4.4|^5.0", "ruflin/elastica": "^7.0", "symfony/deprecation-contracts": "^2.4 || ^3.0", - "symfony/property-access": "^5.4 || ^6.0", - "symfony/property-info": "^5.4 || ^6.0", - "symfony/serializer": "^5.4 || ^6.0", - "symfony/yaml": "^5.4 || ^6.0" + "symfony/property-access": "^5.4 || ^6.0 || ^7.0", + "symfony/property-info": "^5.4 || ^6.0 || ^7.0", + "symfony/serializer": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.17.0", @@ -31,11 +31,11 @@ "jane-php/json-schema-runtime": "^7.4", "phpstan/phpstan": "^1.9", "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/framework-bundle": "^5.4.17 || ^6.0", - "symfony/http-client": "^5.4 || ^6.0", - "symfony/http-foundation": "^5.4 || ^6.0", - "symfony/messenger": "^5.4 || ^6.0", - "symfony/phpunit-bridge": "^6.2.3" + "symfony/framework-bundle": "^5.4.17 || ^6.0 || ^7.0", + "symfony/http-client": "^5.4 || ^6.0 || ^7.0", + "symfony/http-foundation": "^5.4 || ^6.0 || ^7.0", + "symfony/messenger": "^5.4 || ^6.0 || ^7.0", + "symfony/phpunit-bridge": "^6.2.3 || ^7.0" }, "conflict": { "nikic/php-parser": "<4.7" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2e289e5..7334bd0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,6 +12,7 @@ + diff --git a/src/Bridge/Symfony/ElasticallyBundle.php b/src/Bridge/Symfony/ElasticallyBundle.php index 5f65246..ddb48bc 100644 --- a/src/Bridge/Symfony/ElasticallyBundle.php +++ b/src/Bridge/Symfony/ElasticallyBundle.php @@ -13,4 +13,6 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; -class ElasticallyBundle extends Bundle {} +class ElasticallyBundle extends Bundle +{ +} diff --git a/src/Messenger/IndexationRequestInterface.php b/src/Messenger/IndexationRequestInterface.php index 77f21a0..ef944fc 100644 --- a/src/Messenger/IndexationRequestInterface.php +++ b/src/Messenger/IndexationRequestInterface.php @@ -11,4 +11,6 @@ namespace JoliCode\Elastically\Messenger; -interface IndexationRequestInterface {} +interface IndexationRequestInterface +{ +} diff --git a/tests/Messenger/MemoryQueuingFunctionalTest.php b/tests/Messenger/MemoryQueuingFunctionalTest.php index 66d803e..13f2c6c 100644 --- a/tests/Messenger/MemoryQueuingFunctionalTest.php +++ b/tests/Messenger/MemoryQueuingFunctionalTest.php @@ -16,7 +16,7 @@ use JoliCode\Elastically\Messenger\IndexationRequest; use JoliCode\Elastically\Messenger\MultipleIndexationRequest; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Container; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -60,7 +60,7 @@ public function testFrameworkKernelTerminateResend(): void // Simulate Kernel Response $dispatcher->dispatch( - new ResponseEvent(self::$kernel, new Request(), Kernel::MASTER_REQUEST, new Response()), + new ResponseEvent(self::$kernel, new Request(), Kernel::MAIN_REQUEST, new Response()), KernelEvents::RESPONSE ); @@ -94,7 +94,7 @@ public function testFrameworkKernelTerminateWithNoMessage(): void // Simulate Kernel Response $dispatcher->dispatch( - new ResponseEvent(self::$kernel, new Request(), Kernel::MASTER_REQUEST, new Response()), + new ResponseEvent(self::$kernel, new Request(), Kernel::MAIN_REQUEST, new Response()), KernelEvents::RESPONSE ); @@ -105,7 +105,7 @@ public function testFrameworkKernelTerminateWithNoMessage(): void $this->assertCount(0, $transportBulk->getSent()); } - protected static function getContainer(): ContainerInterface + protected static function getContainer(): Container { if (method_exists(KernelTestCase::class, 'getContainer')) { return parent::getContainer(); diff --git a/tests/Messenger/TestControllerFunctionalTest.php b/tests/Messenger/TestControllerFunctionalTest.php index 479d0df..f4cd320 100644 --- a/tests/Messenger/TestControllerFunctionalTest.php +++ b/tests/Messenger/TestControllerFunctionalTest.php @@ -15,7 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Container; use Symfony\Component\Messenger\Transport\InMemoryTransport; final class TestControllerFunctionalTest extends WebTestCase @@ -53,7 +53,7 @@ public function testControllerWithResponse(): void $this->assertSame(200, $client->getResponse()->getStatusCode()); } - protected static function getContainer(): ContainerInterface + protected static function getContainer(): Container { if (method_exists(KernelTestCase::class, 'getContainer')) { return parent::getContainer(); diff --git a/tests/SearchTest.php b/tests/SearchTest.php index bdaba10..819388d 100644 --- a/tests/SearchTest.php +++ b/tests/SearchTest.php @@ -127,13 +127,25 @@ public function testMyOwnSerializer(): void class SearchTestDummySerializer implements SerializerInterface, DenormalizerInterface { - public function denormalize($data, $class, $format = null, array $context = []): mixed {} + public function denormalize($data, $class, $format = null, array $context = []): mixed + { + } - public function supportsDenormalization($data, $type, $format = null, array $context = []): bool {} + public function supportsDenormalization($data, $type, $format = null, array $context = []): bool + { + } - public function serialize(mixed $data, string $format, array $context = []): string {} + public function serialize(mixed $data, string $format, array $context = []): string + { + } - public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed {} + public function deserialize(mixed $data, string $type, string $format, array $context = []): mixed + { + } + + public function getSupportedTypes(?string $format): array + { + } } class SearchTestDto