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 a44a255
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
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 a44a255

Please sign in to comment.