From 8524bf0607e590033719e7438f694fe6ca2a2fca Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 20 Dec 2023 19:49:00 +0100 Subject: [PATCH] Fix tests --- .github/workflows/unit-tests.yml | 26 +++++++-------------- src/Entity/Scope.php | 2 +- tests/Acceptance/AbstractAcceptanceTest.php | 3 ++- tests/Fixtures/User.php | 2 +- tests/TestKernel.php | 21 ++++++++++------- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index e21d40a9..119b836d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -14,25 +14,17 @@ jobs: strategy: fail-fast: false matrix: - #Stable supported versions - php: ['8.1', '8.2'] - symfony: ['5.4.*', '6.2.*'] - composer-flags: ['--prefer-stable'] - can-fail: [false] - exclude: - - php: '8.1' - symfony: '6.2.*' include: - # Lowest supported versions - - php: '8.1' - symfony: '5.4.*' - composer-flags: '--prefer-stable --prefer-lowest' + # Lowest Deps + - php: 8.1 + symfony: 5.4.* + composer-flags: '--prefer-stable' + can-fail: false + # Stable deps + - php: 8.2 + symfony: 6.3.* + composer-flags: '--prefer-stable' can-fail: false - # Development versions - - php: '8.3' - symfony: '6.3.x-dev' - composer-flags: '' - can-fail: true name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}" diff --git a/src/Entity/Scope.php b/src/Entity/Scope.php index 08a9c168..ad61965f 100644 --- a/src/Entity/Scope.php +++ b/src/Entity/Scope.php @@ -12,7 +12,7 @@ final class Scope implements ScopeEntityInterface use EntityTrait; #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): mixed { return $this->getIdentifier(); } diff --git a/tests/Acceptance/AbstractAcceptanceTest.php b/tests/Acceptance/AbstractAcceptanceTest.php index 18624c28..23509d50 100644 --- a/tests/Acceptance/AbstractAcceptanceTest.php +++ b/tests/Acceptance/AbstractAcceptanceTest.php @@ -4,6 +4,7 @@ namespace League\Bundle\OAuth2ServerBundle\Tests\Acceptance; +use Doctrine\DBAL\Platforms\SqlitePlatform; use League\Bundle\OAuth2ServerBundle\Tests\TestHelper; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\KernelBrowser; @@ -30,7 +31,7 @@ protected function setUp(): void TestHelper::initializeDoctrineSchema($this->application); $connection = $this->client->getContainer()->get('database_connection'); - if ('sqlite' === $connection->getDatabasePlatform()->getName()) { + if ($connection->getDatabasePlatform() instanceof SqlitePlatform) { // https://www.sqlite.org/foreignkeys.html $connection->executeQuery('PRAGMA foreign_keys = ON'); } diff --git a/tests/Fixtures/User.php b/tests/Fixtures/User.php index 43702bf7..277db961 100644 --- a/tests/Fixtures/User.php +++ b/tests/Fixtures/User.php @@ -33,7 +33,7 @@ public function getUserIdentifier(): string return FixtureFactory::FIXTURE_USER; } - public function eraseCredentials() + public function eraseCredentials(): void { } } diff --git a/tests/TestKernel.php b/tests/TestKernel.php index 12abdec2..acfc1a2a 100644 --- a/tests/TestKernel.php +++ b/tests/TestKernel.php @@ -5,6 +5,7 @@ namespace League\Bundle\OAuth2ServerBundle\Tests; use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\ORM\Configuration as OrmConfiguration; use League\Bundle\OAuth2ServerBundle\Manager\AccessTokenManagerInterface; use League\Bundle\OAuth2ServerBundle\Manager\AuthorizationCodeManagerInterface; use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface; @@ -20,7 +21,7 @@ final class TestKernel extends Kernel implements CompilerPassInterface { - public function boot() + public function boot(): void { $this->initializeEnvironmentVariables(); @@ -47,27 +48,31 @@ public function getLogDir(): string return sprintf('%s/tests/.kernel/logs', $this->getProjectDir()); } - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $this->exposeManagerServices($container); } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load(function (ContainerBuilder $container) { - $container->loadFromExtension('doctrine', [ + $doctrine = [ 'dbal' => [ - 'driver' => 'sqlite', + 'driver' => 'pdo_sqlite', 'charset' => 'utf8mb4', 'url' => 'sqlite:///:memory:', 'default_table_options' => [ 'charset' => 'utf8mb4', 'utf8mb4_unicode_ci' => 'utf8mb4_unicode_ci', ], - 'platform_service' => SqlitePlatform::class, ], - 'orm' => null, - ]); + ]; + + if (method_exists(OrmConfiguration::class, 'setLazyGhostObjectEnabled')) { + $doctrine['orm'] = ['enable_lazy_ghost_objects'=> true]; + } + + $container->loadFromExtension('doctrine', $doctrine); $container->loadFromExtension('framework', [ 'secret' => 'nope',