From f5db9a59609d7f6afb914a9a43b7fad690e066f7 Mon Sep 17 00:00:00 2001 From: Oliver Kossin Date: Wed, 24 Jul 2024 18:30:04 +0200 Subject: [PATCH] Add Symfony 7 support (#390) --- Metadata/DynamicFormMetadataLoader.php | 4 +-- Tests/Functional/Mail/HelperTestCase.php | 2 +- Tests/Functional/Mail/MailerHelperTest.php | 13 ++++++-- .../Event/ProtectedMediaSubscriberTest.php | 12 +++++-- composer.json | 33 +++++++++---------- 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Metadata/DynamicFormMetadataLoader.php b/Metadata/DynamicFormMetadataLoader.php index 122a69d5..e1b0bb7e 100644 --- a/Metadata/DynamicFormMetadataLoader.php +++ b/Metadata/DynamicFormMetadataLoader.php @@ -84,7 +84,7 @@ public function __construct( /** * @param string $cacheDir */ - public function warmUp($cacheDir) + public function warmUp($cacheDir, ?string $buildDir = null): array { $resource = __DIR__ . '/../Resources/config/forms/form_details.xml'; $formMetadataCollection = $this->formXmlLoader->load($resource); @@ -160,7 +160,7 @@ private function loadFieldTypeMetadata(string $typeKey, FormFieldTypeInterface $ return $form; } - public function isOptional() + public function isOptional(): bool { return false; } diff --git a/Tests/Functional/Mail/HelperTestCase.php b/Tests/Functional/Mail/HelperTestCase.php index bf8f8b20..84da9504 100644 --- a/Tests/Functional/Mail/HelperTestCase.php +++ b/Tests/Functional/Mail/HelperTestCase.php @@ -33,7 +33,7 @@ class HelperTestCase extends SuluTestCase protected function setUp(): void { - parent::setUp(); + static::$kernel = null; // requires as Symfony 4.4 does not unset on tearDown $this->client = $this->createWebsiteClient(); $this->purgeDatabase(); diff --git a/Tests/Functional/Mail/MailerHelperTest.php b/Tests/Functional/Mail/MailerHelperTest.php index 83c0cc1b..952989d1 100644 --- a/Tests/Functional/Mail/MailerHelperTest.php +++ b/Tests/Functional/Mail/MailerHelperTest.php @@ -16,10 +16,19 @@ class MailerHelperTest extends HelperTestCase { - protected static $class = MailerKernel::class; + protected function setUp(): void + { + static::$class = MailerKernel::class; + static::$kernel = null; // requires as Symfony 4.4 does not unset on tearDown + + parent::setUp(); + } public function testSendsEmailUsingMailerComponent() { + $this->assertIsObject(static::$kernel); + $this->assertSame(MailerKernel::class, \get_class(static::$kernel)); + $formTranslationRepository = $this->entityManager->getRepository(FormTranslation::class); /** @var FormTranslation $formTranslation */ $formTranslation = $formTranslationRepository->findOneBy(['title' => 'Title', 'locale' => 'de']); @@ -34,7 +43,7 @@ public function testSendsEmailUsingMailerComponent() $this->assertSame(0, $mailCollector->getMessageCount()); } - // 2 messages should be send 1 to admin and 1 to email + // 2 messages should be sent 1 to admin and 1 to email $this->assertEmailCount(2); } } diff --git a/Tests/Unit/Event/ProtectedMediaSubscriberTest.php b/Tests/Unit/Event/ProtectedMediaSubscriberTest.php index e438e7bc..ca65f7ae 100644 --- a/Tests/Unit/Event/ProtectedMediaSubscriberTest.php +++ b/Tests/Unit/Event/ProtectedMediaSubscriberTest.php @@ -87,7 +87,9 @@ public function testOtherRoute(): void $event = new RequestEvent( new Kernel('test', true, SuluKernel::CONTEXT_WEBSITE), $request, - HttpKernelInterface::MASTER_REQUEST + \defined(HttpKernelInterface::class . '::MASTER_REQUEST') + ? HttpKernelInterface::MASTER_REQUEST + : HttpKernelInterface::MAIN_REQUEST ); $this->formatCache->analyzedMediaUrl(Argument::any()) @@ -108,7 +110,9 @@ public function testImageProxyRoute(): void $event = new RequestEvent( new Kernel('test', true, SuluKernel::CONTEXT_WEBSITE), $request, - HttpKernelInterface::MASTER_REQUEST + \defined(HttpKernelInterface::class . '::MASTER_REQUEST') + ? HttpKernelInterface::MASTER_REQUEST + : HttpKernelInterface::MAIN_REQUEST ); $this->formatCache->analyzedMediaUrl(Argument::any()) @@ -136,7 +140,9 @@ public function testDownloadRoute(): void $event = new RequestEvent( new Kernel('test', true, SuluKernel::CONTEXT_WEBSITE), $request, - HttpKernelInterface::MASTER_REQUEST + \defined(HttpKernelInterface::class . '::MASTER_REQUEST') + ? HttpKernelInterface::MASTER_REQUEST + : HttpKernelInterface::MAIN_REQUEST ); $this->mockLoadCollectionKey('sulu_form'); diff --git a/composer.json b/composer.json index 67298f73..edff35e5 100644 --- a/composer.json +++ b/composer.json @@ -18,30 +18,29 @@ ], "require": { "php": "^7.2 || ^8.0", - "doctrine/collections": "^1.0", + "doctrine/collections": "^1.0 || ^2.0", "doctrine/orm": "^2.5.3", "doctrine/persistence": "^1.3 || ^2.0 || ^3.0", "sulu/sulu": "^2.4.1 || ^2.5.0@dev", - "symfony/config": "^4.4 || ^5.0 || ^6.0", - "symfony/console": "^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/config": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/console": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/event-dispatcher-contracts": "^1.0 || ^2.0 || ^3.0", - "symfony/form": "^4.4 || ^5.0 || ^6.0", - "symfony/mailer": "^4.4 || ^5.0 || ^6.0", - "symfony/validator": "^4.4 || ^5.0 || ^6.0", - "symfony/security-csrf": "^4.4 || ^5.0 || ^6.0", - "symfony/translation": "^4.4 || ^5.0 || ^6.0", + "symfony/form": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/mailer": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/validator": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/security-csrf": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/translation": "^4.4 || ^5.0 || ^6.0 || ^7.0", "twig/twig": "^1.41 || ^2.0 || ^3.0" }, "require-dev": { - "dantleech/phpcr-migrations-bundle": "^1.3", "doctrine/data-fixtures": "^1.3.3", "doctrine/doctrine-bundle": "^1.10 || ^2.0", "drewm/mailchimp-api": "^2.2", "excelwebzone/recaptcha-bundle": "^1.4.2", "handcraftedinthealps/zendsearch": "^2.0", - "jackalope/jackalope-doctrine-dbal": "^1.3.2", + "jackalope/jackalope-doctrine-dbal": "^1.3.2 || ^2.0", "jangregor/phpstan-prophecy": "^1.0", "massive/search-bundle": "^2.0", "php-cs-fixer/shim": "^3.0", @@ -52,12 +51,12 @@ "phpstan/phpstan-symfony": "^1.0", "phpunit/phpunit": "^8.0", "sendinblue/api-v3-sdk": "^8.0", - "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0", - "symfony/dotenv": "^4.4 || ^5.0 || ^6.0", - "symfony/mime": "^4.4 || ^5.0 || ^6.0", + "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/dotenv": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/mime": "^4.4 || ^5.0 || ^6.0 || ^7.0", "symfony/monolog-bundle": "^3.1", - "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0", - "symfony/var-dumper": "^4.4 || ^5.0 || ^6.0", + "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/var-dumper": "^4.4 || ^5.0 || ^6.0 || ^7.0", "thecodingmachine/phpstan-strict-rules": "^1.0" }, "replace": {