diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 82f2c12..a4cacd9 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [ '8.0', '8.1', '8.2' ] + php-versions: [ '8.1', '8.2', '8.3' ] steps: - uses: shivammathur/setup-php@v2 with: diff --git a/composer.json b/composer.json index 7ff0c23..1125314 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,9 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "api-platform/core": "^2.1 || ^3.0", - "doctrine/orm": "^2.4.5", + "doctrine/orm": "^3.0", "doctrine/doctrine-bundle": "^1.6 || ^2.0", "symfony/translation": "*", "symfony/dependency-injection": "*" diff --git a/src/EventListener/AssignLocaleListener.php b/src/EventListener/AssignLocaleListener.php index 364d7b1..7bfab74 100644 --- a/src/EventListener/AssignLocaleListener.php +++ b/src/EventListener/AssignLocaleListener.php @@ -6,7 +6,6 @@ use Doctrine\Common\EventArgs; use Locastic\ApiPlatformTranslationBundle\Model\TranslatableInterface; -use Locastic\ApiPlatformTranslationBundle\Model\TranslationInterface; use Locastic\ApiPlatformTranslationBundle\Translation\Translator; /** diff --git a/tests/EventListener/AssignLocaleListenerTest.php b/tests/EventListener/AssignLocaleListenerTest.php index e8b0ec4..51d9fba 100644 --- a/tests/EventListener/AssignLocaleListenerTest.php +++ b/tests/EventListener/AssignLocaleListenerTest.php @@ -4,7 +4,7 @@ namespace Locastic\ApiPlatformTranslationBundle\Tests\EventListener; -use Doctrine\ORM\Event\LifecycleEventArgs; +use Doctrine\Persistence\Event\LifecycleEventArgs; use Locastic\ApiPlatformTranslationBundle\EventListener\AssignLocaleListener; use Locastic\ApiPlatformTranslationBundle\Tests\Fixtures\DummyNotTranslatable; use Locastic\ApiPlatformTranslationBundle\Tests\Fixtures\DummyTranslatable; diff --git a/tests/Translation/TranslatorTest.php b/tests/Translation/TranslatorTest.php index 0af0b60..62d68cd 100644 --- a/tests/Translation/TranslatorTest.php +++ b/tests/Translation/TranslatorTest.php @@ -86,19 +86,13 @@ public function testLoadCurrentLocale( ): void { $translator = new Translator($this->translator, $this->requestStack, $this->defaultLocale); - $request = $this->createMock(Request::class); - $request->query = $this->createMock(ParameterBag::class); + $request = new Request(['locale' => $requestedLocale]); + $this->requestStack ->expects($this->once()) ->method('getCurrentRequest') ->willReturn($request); - $request->query - ->expects($this->once()) - ->method('get') - ->with('locale') - ->willReturn($requestedLocale); - $actualLocale = $translator->loadCurrentLocale(); $this->assertSame($expectedLocale, $actualLocale); } @@ -114,21 +108,20 @@ public function testLoadAcceptedLanguagesHeader( ): void { $translator = new Translator($this->translator, $this->requestStack, $this->defaultLocale); - $request = $this->createConfiguredMock(Request::class, [ - 'getPreferredLanguage' => $acceptedLanguage - ]); - $request->query = $this->createMock(ParameterBag::class); + $request = $this->getMockBuilder(Request::class) + ->setConstructorArgs([ + ['locale' => $requestedLocale] + ]) + ->onlyMethods(['getPreferredLanguage']) + ->getMock(); + + $request->method('getPreferredLanguage')->willReturn($acceptedLanguage); + $this->requestStack ->expects($this->once()) ->method('getCurrentRequest') ->willReturn($request); - $request->query - ->expects($this->once()) - ->method('get') - ->with('locale') - ->willReturn($requestedLocale); - $actualLocale = $translator->loadCurrentLocale(); $this->assertSame($expectedLocale, $actualLocale); }