RPRegistrationDynamic::getTestId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClient\ConformanceTest\RpTest\DynamicClientRegistration;
6
7
use PHPUnit\Framework\Assert;
8
use Facile\OpenIDClient\ConformanceTest\RpTest\AbstractRpTest;
9
use Facile\OpenIDClient\ConformanceTest\TestInfo;
10
use Facile\OpenIDClient\Issuer\IssuerBuilder;
11
use Facile\OpenIDClient\Service\RegistrationService;
12
13
/**
14
 * Use the client registration endpoint in order to dynamically register the Relying Party.
15
 *
16
 * Get a Client Registration Response.
17
 */
18
class RPRegistrationDynamic extends AbstractRpTest
19
{
20
21
    public function getTestId(): string
22
    {
23
        return 'rp-registration-dynamic';
24
    }
25
26
    public function execute(TestInfo $testInfo): void
27
    {
28
        $clientRegistrationService = new RegistrationService();
0 ignored issues
show
Bug introduced by
The call to Facile\OpenIDClient\Serv...nService::__construct() has too few arguments starting with client. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $clientRegistrationService = /** @scrutinizer ignore-call */ new RegistrationService();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
29
30
        $configUri = sprintf('%s/%s/%s/.well-known/openid-configuration', $testInfo->getRoot(), $testInfo->getRpId(), $this->getTestId());
31
        $issuer = (new IssuerBuilder())
32
            ->build($configUri);
33
34
        $metadata = $clientRegistrationService->register($issuer, [
35
            'client_name' => $testInfo->getRpId() . '/' . $this->getTestId(),
36
            'redirect_uris' => [
37
                'https://example.com/callback',
38
            ],
39
            'contacts' => [
40
                '[email protected]',
41
            ],
42
        ]);
43
44
        Assert::assertArrayHasKey('client_id', $metadata);
45
        Assert::assertArrayHasKey('client_secret_expires_at', $metadata);
46
    }
47
}
48