Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
dependency-versions: "${{ matrix.dependency-versions }}"

- name: "run unit tests"
run: "vendor/bin/simple-phpunit --colors=always"
run: "vendor/bin/simple-phpunit"


# This is a "trick", a meta task which does not change, and we can use in
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@
"doctrine/dbal": "^4.0",
"doctrine/doctrine-bundle": "^2.15|^3.0",
"doctrine/orm": "^3.0",
"php-cs-fixer/shim": "^3.38",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-symfony": "^2.0",
"rector/rector": "^2.5",
"php-cs-fixer/shim": "^3.95",
"phpstan/phpstan": "^2.3",
"phpstan/phpstan-symfony": "^2.1",
"rector/rector": "^2.6",
"symfony/browser-kit": "^7.4|^8.1",
"symfony/phpunit-bridge": "^8.1"
},
"conflict": {
"doctrine/dbal": "<4.0",
"doctrine/doctrine-bundle": "<2.15",
"doctrine/orm": "<3.0"
"doctrine/orm": "<3.0",
"symfony/error-handler": "<7.4.17"
},
"suggest": {
"doctrine/doctrine-bundle": "Allow usage of doctrine as persistence layer",
Expand Down
27 changes: 13 additions & 14 deletions phpunit.xml.dist → phpunit.dist.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
failOnRisky="true"
failOnWarning="true"
>
<php>
<server name="KERNEL_CLASS" value="League\Bundle\OAuth2ServerBundle\Tests\Fixtures\TestKernel" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
<server name="KERNEL_CLASS" value="League\Bundle\OAuth2ServerBundle\Tests\Fixtures\TestKernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
<env name="SYMFONY_PHPUNIT_VERSION" value="11.5"/>
</php>

<testsuites>
<testsuite name="unit">
<directory>./tests/Unit</directory>
Expand All @@ -27,14 +27,13 @@
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory>.</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
</source>
</phpunit>
File renamed without changes.
4 changes: 2 additions & 2 deletions src/Command/ClearExpiredTokensCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->clearExpiredDeviceCodes($io);
}

return 0;
return Command::SUCCESS;
}

if ($clearExpiredAccessTokens) {
Expand All @@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->clearExpiredDeviceCodes($io);
}

return 0;
return Command::SUCCESS;
}

private function clearExpiredAccessTokens(SymfonyStyle $io): void
Expand Down
4 changes: 2 additions & 2 deletions src/Command/CreateClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (\InvalidArgumentException $exception) {
$io->error($exception->getMessage());

return 1;
return Command::FAILURE;
}

$this->clientManager->save($client);
Expand All @@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
];
$io->table($headers, $rows);

return 0;
return Command::SUCCESS;
}

private function resolvePlainSecret(InputInterface $input): ?string
Expand Down
4 changes: 2 additions & 2 deletions src/Command/DeleteClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (null === $client = $this->clientManager->find($input->getArgument('identifier'))) {
$io->error(\sprintf('OAuth2 client identified as "%s" does not exist.', $input->getArgument('identifier')));

return 1;
return Command::FAILURE;
}

$this->clientManager->remove($client);
$io->success('OAuth2 client deleted successfully.');

return 0;
return Command::SUCCESS;
}
}
2 changes: 1 addition & 1 deletion src/Command/ListClientsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$clients = $this->clientManager->list($criteria);
$this->drawTable($input, $output, $clients);

return 0;
return Command::SUCCESS;
}

private function getFindByCriteria(InputInterface $input): ClientFilter
Expand Down
4 changes: 2 additions & 2 deletions src/Command/UpdateClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (null === $client = $this->clientManager->find($input->getArgument('identifier'))) {
$io->error(\sprintf('OAuth2 client identified as "%s" does not exist.', $input->getArgument('identifier')));

return 1;
return Command::FAILURE;
}

$client->setActive($this->getClientActiveFromInput($input, $client->isActive()));
Expand All @@ -64,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$io->success('OAuth2 client updated successfully.');

return 0;
return Command::SUCCESS;
}

private function getClientActiveFromInput(InputInterface $input, bool $actual): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

abstract class AbstractAcceptanceTest extends WebTestCase
abstract class AbstractAcceptanceTestCase extends WebTestCase
{
/**
* @var Application
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/AuthorizationEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use League\Bundle\OAuth2ServerBundle\Tests\TestHelper;
use Symfony\Component\HttpFoundation\Response;

final class AuthorizationEndpointTest extends AbstractAcceptanceTest
final class AuthorizationEndpointTest extends AbstractAcceptanceTestCase
{
protected function setUp(): void
{
Expand Down
7 changes: 1 addition & 6 deletions tests/Acceptance/ClearExpiredTokensCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;

final class ClearExpiredTokensCommandTest extends AbstractAcceptanceTest
final class ClearExpiredTokensCommandTest extends AbstractAcceptanceTestCase
{
protected function setUp(): void
{
Expand All @@ -34,11 +34,6 @@ protected function setUp(): void
);
}

protected function tearDown(): void
{
parent::tearDown();
}

public function testClearExpiredAccessAndRefreshTokensAndAuthCodes(): void
{
$command = $this->command();
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/CreateClientCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\PasswordHasher\PasswordHasherInterface;

final class CreateClientCommandTest extends AbstractAcceptanceTest
final class CreateClientCommandTest extends AbstractAcceptanceTestCase
{
public function testCreateClient(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Acceptance/CustomPersistenceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Bundle\FrameworkBundle\Console\Application;

class CustomPersistenceManagerTest extends AbstractAcceptanceTest
class CustomPersistenceManagerTest extends AbstractAcceptanceTestCase
{
private AccessTokenManagerInterface&MockObject $accessTokenManager;
private ClientManagerInterface&MockObject $clientManager;
Expand Down Expand Up @@ -111,10 +111,10 @@ public function testSuccessfulRefreshTokenRequest(): void
$accessToken = new AccessToken('access_token', new \DateTimeImmutable('+1 hour'), $client, 'user', []);
$refreshToken = new RefreshToken('refresh_token', new \DateTimeImmutable('+1 month'), $accessToken);

$this->refreshTokenManager->expects(self::atLeastOnce())->method('find')->willReturn($refreshToken, null);
$this->refreshTokenManager->expects(self::atLeastOnce())->method('find')->willReturn($refreshToken, null, null);
$this->client->getContainer()->set('test.refresh_token_manager', $this->refreshTokenManager);

$this->accessTokenManager->expects(self::atLeastOnce())->method('find')->willReturn($accessToken, null);
$this->accessTokenManager->expects(self::atLeastOnce())->method('find')->willReturn($accessToken, null, null);
$this->accessTokenManager->expects(self::atLeastOnce())->method('save');
$this->client->getContainer()->set('test.access_token_manager', $this->accessTokenManager);

Expand Down
8 changes: 4 additions & 4 deletions tests/Acceptance/DeleteClientCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace League\Bundle\OAuth2ServerBundle\Tests\Acceptance;

use League\Bundle\OAuth2ServerBundle\Command\DeleteClientCommand;
use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface;
use League\Bundle\OAuth2ServerBundle\Model\Client;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;

/**
* @covers \League\Bundle\OAuth2ServerBundle\Command\DeleteClientCommand
*/
final class DeleteClientCommandTest extends AbstractAcceptanceTest
#[CoversClass(DeleteClientCommand::class)]
final class DeleteClientCommandTest extends AbstractAcceptanceTestCase
{
public function testDeleteClient(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/DeviceCodeEndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use League\Bundle\OAuth2ServerBundle\Manager\ScopeManagerInterface;
use League\Bundle\OAuth2ServerBundle\Tests\Fixtures\FixtureFactory;

final class DeviceCodeEndpointTest extends AbstractAcceptanceTest
final class DeviceCodeEndpointTest extends AbstractAcceptanceTestCase
{
protected function setUp(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Acceptance/DoctrineAccessTokenManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use League\Bundle\OAuth2ServerBundle\Model\AccessToken;
use League\Bundle\OAuth2ServerBundle\Model\Client;
use League\Bundle\OAuth2ServerBundle\Model\RefreshToken;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @TODO This should be in the Integration tests folder but the current tests infrastructure would need improvements first.
*
* @covers \League\Bundle\OAuth2ServerBundle\Manager\Doctrine\AccessTokenManager
*/
final class DoctrineAccessTokenManagerTest extends AbstractAcceptanceTest
#[CoversClass(DoctrineAccessTokenManager::class)]
final class DoctrineAccessTokenManagerTest extends AbstractAcceptanceTestCase
{
public function testClearExpired(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Acceptance/DoctrineAuthCodeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use League\Bundle\OAuth2ServerBundle\Manager\Doctrine\AuthorizationCodeManager as DoctrineAuthCodeManager;
use League\Bundle\OAuth2ServerBundle\Model\AuthorizationCode;
use League\Bundle\OAuth2ServerBundle\Model\Client;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @TODO This should be in the Integration tests folder but the current tests infrastructure would need improvements first.
*
* @covers \League\Bundle\OAuth2ServerBundle\Manager\Doctrine\AuthorizationCodeManager
*/
final class DoctrineAuthCodeManagerTest extends AbstractAcceptanceTest
#[CoversClass(DoctrineAuthCodeManager::class)]
final class DoctrineAuthCodeManagerTest extends AbstractAcceptanceTestCase
{
public function testClearExpired(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Acceptance/DoctrineClientManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
use League\Bundle\OAuth2ServerBundle\Model\RefreshToken;
use League\Bundle\OAuth2ServerBundle\Tests\Fixtures\FixtureFactory;
use League\Bundle\OAuth2ServerBundle\ValueObject\Scope;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @TODO This should be in the Integration tests folder but the current tests infrastructure would need improvements first.
*
* @covers \League\Bundle\OAuth2ServerBundle\Manager\Doctrine\ClientManager
*/
final class DoctrineClientManagerTest extends AbstractAcceptanceTest
#[CoversClass(DoctrineClientManager::class)]
final class DoctrineClientManagerTest extends AbstractAcceptanceTestCase
{
public function testSimpleDelete(): void
{
Expand Down
15 changes: 6 additions & 9 deletions tests/Acceptance/DoctrineCredentialsRevokerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
use League\Bundle\OAuth2ServerBundle\Model\RefreshToken;
use League\Bundle\OAuth2ServerBundle\Service\CredentialsRevoker\DoctrineCredentialsRevoker;
use League\Bundle\OAuth2ServerBundle\Tests\Fixtures\FixtureFactory;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @TODO This should be in the Integration tests folder but the current tests infrastructure would need improvements first.
*
* @covers \League\Bundle\OAuth2ServerBundle\Service\CredentialsRevoker\DoctrineCredentialsRevoker
*/
final class DoctrineCredentialsRevokerTest extends AbstractAcceptanceTest
#[CoversClass(DoctrineCredentialsRevoker::class)]
final class DoctrineCredentialsRevokerTest extends AbstractAcceptanceTestCase
{
/**
* @dataProvider provideRevokeCredentialsOptions
*/
#[DataProvider('provideRevokeCredentialsOptions')]
public function testRevokesAllCredentialsForUser(bool $persistAccessToken, bool $enableDeviceCodeGrant): void
{
$userIdentifier = FixtureFactory::FIXTURE_USER;
Expand Down Expand Up @@ -69,9 +68,7 @@ public static function provideRevokeCredentialsOptions(): iterable
yield [false, false];
}

/**
* @dataProvider provideRevokeCredentialsOptions
*/
#[DataProvider('provideRevokeCredentialsOptions')]
public function testRevokesAllCredentialsForClient(bool $persistAccessToken, bool $enableDeviceCodeGrant): void
{
/** @var EntityManagerInterface $em */
Expand Down
6 changes: 3 additions & 3 deletions tests/Acceptance/DoctrineDeviceCodeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
use League\Bundle\OAuth2ServerBundle\Manager\Doctrine\DeviceCodeManager as DoctrineDeviceCodeManager;
use League\Bundle\OAuth2ServerBundle\Model\Client;
use League\Bundle\OAuth2ServerBundle\Model\DeviceCode;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @TODO This should be in the Integration tests folder but the current tests infrastructure would need improvements first.
*
* @covers \League\Bundle\OAuth2ServerBundle\Manager\Doctrine\DeviceCodeManager
*/
final class DoctrineDeviceCodeManagerTest extends AbstractAcceptanceTest
#[CoversClass(DoctrineDeviceCodeManager::class)]
final class DoctrineDeviceCodeManagerTest extends AbstractAcceptanceTestCase
{
public function testClearExpired(): void
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Acceptance/DoctrineRefreshTokenManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
use League\Bundle\OAuth2ServerBundle\Model\AccessToken;
use League\Bundle\OAuth2ServerBundle\Model\Client;
use League\Bundle\OAuth2ServerBundle\Model\RefreshToken;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @TODO This should be in the Integration tests folder but the current tests infrastructure would need improvements first.
*
* @covers \League\Bundle\OAuth2ServerBundle\Manager\Doctrine\RefreshTokenManager
*/
final class DoctrineRefreshTokenManagerTest extends AbstractAcceptanceTest
#[CoversClass(DoctrineRefreshTokenManager::class)]
final class DoctrineRefreshTokenManagerTest extends AbstractAcceptanceTestCase
{
public function testClearExpired(): void
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Acceptance/InMemoryClientManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

use League\Bundle\OAuth2ServerBundle\Manager\InMemory\ClientManager as InMemoryClientManager;
use League\Bundle\OAuth2ServerBundle\Model\Client;
use League\Bundle\OAuth2ServerBundle\Tests\Acceptance\AbstractAcceptanceTest;
use League\Bundle\OAuth2ServerBundle\Tests\Acceptance\AbstractAcceptanceTestCase;
use League\Bundle\OAuth2ServerBundle\Tests\Fixtures\FixtureFactory;
use League\Bundle\OAuth2ServerBundle\ValueObject\Scope;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @TODO This should be in the Integration tests folder but the current tests infrastructure would need improvements first.
*/
final class InMemoryClientManagerTest extends AbstractAcceptanceTest
final class InMemoryClientManagerTest extends AbstractAcceptanceTestCase
{
public function testSaveClientWithoutScopeAddDefaultScopes(): void
{
Expand Down
Loading
Loading