Skip to content

Commit

Permalink
orm 3.0 support (#68)
Browse files Browse the repository at this point in the history
* oem3.0 support

* bump php requirement to 8.1

* remove php 8.0 & add 8.3 in gh workflow
  • Loading branch information
konradkozaczenko authored May 10, 2024
1 parent 09437e2 commit d0baefc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
Expand Down
1 change: 0 additions & 1 deletion src/EventListener/AssignLocaleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Doctrine\Common\EventArgs;
use Locastic\ApiPlatformTranslationBundle\Model\TranslatableInterface;
use Locastic\ApiPlatformTranslationBundle\Model\TranslationInterface;
use Locastic\ApiPlatformTranslationBundle\Translation\Translator;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/EventListener/AssignLocaleListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 11 additions & 18 deletions tests/Translation/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit d0baefc

Please sign in to comment.