Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Dec 21, 2023
1 parent 269f1e2 commit 8524bf0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) || '' }}"

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class Scope implements ScopeEntityInterface
use EntityTrait;

#[\ReturnTypeWillChange]
public function jsonSerialize()
public function jsonSerialize(): mixed
{
return $this->getIdentifier();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Acceptance/AbstractAcceptanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getUserIdentifier(): string
return FixtureFactory::FIXTURE_USER;
}

public function eraseCredentials()
public function eraseCredentials(): void
{
}
}
21 changes: 13 additions & 8 deletions tests/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,7 +21,7 @@

final class TestKernel extends Kernel implements CompilerPassInterface
{
public function boot()
public function boot(): void
{
$this->initializeEnvironmentVariables();

Expand All @@ -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',
Expand Down

0 comments on commit 8524bf0

Please sign in to comment.