Failed Conditions
Push — ng ( 977556...d85ce7 )
by Florent
03:52
created

ClientRegistrationManagementRuleTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testClientRegistrationManagementRuleSetAsDefault() 0 11 1
A getCallable() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Component\ClientConfigurationEndpoint\Tests;
15
16
use OAuth2Framework\Component\Core\Client\ClientId;
17
use OAuth2Framework\Component\Core\DataBag\DataBag;
18
use PHPUnit\Framework\TestCase;
19
20
/**
21
 * @group Tests
22
 */
23
class ClientRegistrationManagementRuleTest extends TestCase
24
{
25
    /**
26
     * @test
27
     */
28
    public function testClientRegistrationManagementRuleSetAsDefault()
29
    {
30
        $clientId = ClientId::create('CLIENT_ID');
31
        $commandParameters = DataBag::create([]);
32
        $rule = new ClientConfigurationRouteRule();
33
        $validatedParameters = $rule->handle($clientId, $commandParameters, DataBag::create([]), $this->getCallable());
34
35
        self::assertTrue($validatedParameters->has('registration_access_token'));
36
        self::assertTrue($validatedParameters->has('registration_client_uri'));
37
        self::assertEquals('https://www.example.com/client/CLIENT_ID', $validatedParameters->get('registration_client_uri'));
38
    }
39
40
    /**
41
     * @return callable
42
     */
43
    private function getCallable(): callable
44
    {
45
        return function (ClientId $clientId, DataBag $commandParameters, DataBag $validatedParameters): DataBag {
46
            return $validatedParameters;
47
        };
48
    }
49
}
50