From a4df4056b2832881e17b939e83f25406a6cc6414 Mon Sep 17 00:00:00 2001 From: Arto Rozenga <1301007+artoroz@users.noreply.github.com> Date: Fri, 7 Jan 2022 13:34:18 +0100 Subject: [PATCH] Add support for Symfony 6.0 (#239) * Add support for Symfony 6.0 * Fix deprecations from PHPUnit * Don't force PHPUnit version and fix tests for Symfony 6 compatibility * Drop support for php 7.1 and add 8.1 support Co-authored-by: Arto Rozenga --- .github/workflows/test.yaml | 8 ++---- composer.json | 30 +++++++++++------------ phpunit.xml.dist | 6 +---- src/Renderer/CKEditorRenderer.php | 2 +- tests/Installer/CKEditorInstallerTest.php | 4 +-- tests/Renderer/CKEditorRendererTest.php | 6 ++--- 6 files changed, 24 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 24467d87..dc07f8e6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,12 +15,8 @@ jobs: - 7.3 - 7.4 - 8.0 - phpunit: [8.5] + - 8.1 dependencies: [highest] - include: - - php-version: 7.1 - phpunit: 7.5 - dependencies: lowest steps: - name: Checkout @@ -41,4 +37,4 @@ jobs: composer-options: --prefer-dist - name: Run Tests - run: SYMFONY_PHPUNIT_VERSION=${{ matrix.phpunit }} vendor/bin/simple-phpunit + run: vendor/bin/simple-phpunit diff --git a/composer.json b/composer.json index 99b69a2e..3e37a512 100644 --- a/composer.json +++ b/composer.json @@ -20,18 +20,18 @@ "php": "^7.1|^8.0", "ext-zip": "*", "ext-json": "*", - "symfony/asset": "^4.4 || ^5.0", - "symfony/config": "^4.4 || ^5.0", - "symfony/dependency-injection": "^4.4 || ^5.0", - "symfony/expression-language": "^4.4 || ^5.0", - "symfony/form": "^4.4 || ^5.0", - "symfony/framework-bundle": "^4.4 || ^5.0", - "symfony/http-foundation": "^4.4 || ^5.0", - "symfony/http-kernel": "^4.4 || ^5.0", - "symfony/options-resolver": "^4.4 || ^5.0", - "symfony/property-access": "^4.4 || ^5.0", - "symfony/routing": "^4.4 || ^5.0", - "symfony/twig-bundle": "^4.4 || ^5.0", + "symfony/asset": "^4.4 || ^5.0 || ^6.0", + "symfony/config": "^4.4 || ^5.0 || ^6.0", + "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", + "symfony/expression-language": "^4.4 || ^5.0 || ^6.0", + "symfony/form": "^4.4 || ^5.0 || ^6.0", + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/http-foundation": "^4.4 || ^5.0 || ^6.0", + "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", + "symfony/options-resolver": "^4.4 || ^5.0 || ^6.0", + "symfony/property-access": "^4.4 || ^5.0 || ^6.0", + "symfony/routing": "^4.4 || ^5.0 || ^6.0", + "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0", "twig/twig": "^2.4 || ^3.0" }, "conflict": { @@ -41,9 +41,9 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^2.0", "matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.0", - "symfony/console": "^4.4 || ^5.0", - "symfony/phpunit-bridge": "^4.4 || ^5.0", - "symfony/yaml": "^4.4 || ^5.0" + "symfony/console": "^4.4 || ^5.0 || ^6.0", + "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6.0", + "symfony/yaml": "^4.4 || ^5.0 || ^6.0" }, "suggest": { "egeloen/form-extra-bundle": "Allows to load CKEditor asynchronously" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 06457f4a..ef9db803 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,11 +5,7 @@ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.0/phpunit.xsd" colors="true" bootstrap="tests/autoload.php"> - - - - - + ./tests diff --git a/src/Renderer/CKEditorRenderer.php b/src/Renderer/CKEditorRenderer.php index acf90355..33b4ff32 100644 --- a/src/Renderer/CKEditorRenderer.php +++ b/src/Renderer/CKEditorRenderer.php @@ -278,7 +278,7 @@ private function getLanguage(): ?string { $request = $this->requestStack->getCurrentRequest(); - if (null !== $request) { + if (null !== $request && '' !== $request->getLocale()) { return $request->getLocale(); } diff --git a/tests/Installer/CKEditorInstallerTest.php b/tests/Installer/CKEditorInstallerTest.php index 957da333..303d0189 100644 --- a/tests/Installer/CKEditorInstallerTest.php +++ b/tests/Installer/CKEditorInstallerTest.php @@ -84,7 +84,7 @@ public function testInstallWithCustomBuild(): void public function testInstallWithCustomBuildWithInvalidVersion(): void { $this->expectException(\RuntimeException::class); - $this->expectExceptionMessageRegExp('/Specifying version for custom build is not supported/'); + $this->expectExceptionMessageMatches('/Specifying version for custom build is not supported/'); $this->installer->install($options = ['release' => CKEditorInstaller::RELEASE_CUSTOM, 'custom_build_id' => '459c358ccf2e34f083e3c8847d3af23e', 'version' => '4.11.4']); } @@ -92,7 +92,7 @@ public function testInstallWithCustomBuildWithInvalidVersion(): void public function testInstallWithCustomBuildWithMissingId(): void { $this->expectException(\RuntimeException::class); - $this->expectExceptionMessageRegExp('/Custom build ID is not specified/'); + $this->expectExceptionMessageMatches('/Custom build ID is not specified/'); $this->installer->install($options = ['release' => CKEditorInstaller::RELEASE_CUSTOM]); } diff --git a/tests/Renderer/CKEditorRendererTest.php b/tests/Renderer/CKEditorRendererTest.php index 7a7c87d4..2f15d722 100644 --- a/tests/Renderer/CKEditorRendererTest.php +++ b/tests/Renderer/CKEditorRendererTest.php @@ -118,7 +118,7 @@ public function testRenderJsPath(): void public function testRenderWidgetWithLocaleRequest(string $symfonyLocale, string $ckEditorLocale): void { $this->request - ->expects($this->once()) + ->expects($this->exactly(2)) ->method('getLocale') ->will($this->returnValue($symfonyLocale)); @@ -133,7 +133,7 @@ public function testRenderWidgetWithLocaleRequest(string $symfonyLocale, string */ public function testRenderWidgetWithLocaleParameter(string $symfonyLocale, string $ckEditorLocale): void { - $this->request->expects($this->once())->method('getLocale')->will($this->returnValue($symfonyLocale)); + $this->request->expects($this->exactly(2))->method('getLocale')->will($this->returnValue($symfonyLocale)); $this->assertSame( 'CKEDITOR.replace("foo", {"language":"'.$ckEditorLocale.'"});', $this->renderer->renderWidget('foo', []) @@ -156,7 +156,7 @@ public function testRenderWidgetWithoutLocale(): void $this->request ->expects($this->once()) ->method('getLocale') - ->will($this->returnValue(null)); + ->will($this->returnValue('')); $this->assertSame( 'CKEDITOR.replace("foo", []);',