GrantsTraitTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 1
eloc 14
c 3
b 1
f 0
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMakeGrantPersonalAccess() 0 23 1
1
<?php
2
3
namespace ByTIC\Hello\Tests\Oauth\ServiceProvider\Traits;
4
5
use ByTIC\Hello\HelloServiceProvider;
6
use ByTIC\Hello\Oauth\Grants\PersonalAccessGrant;
7
use ByTIC\Hello\Tests\AbstractTest;
8
use League\OAuth2\Server\AuthorizationServer;
9
use League\OAuth2\Server\CryptKey;
10
use Mockery;
11
use Nip\Container\Container;
12
13
/**
14
 * Class GrantsTraitTest
15
 * @package ByTIC\Hello\Tests\Oauth\ServiceProvider\Traits
16
 */
17
class GrantsTraitTest extends AbstractTest
18
{
19
    public function testMakeGrantPersonalAccess()
20
    {
21
        $container = new Container();
22
23
        /** @var Mockery\Mock|HelloServiceProvider $provider */
24
        $provider = \Mockery::mock(HelloServiceProvider::class)
25
            ->makePartial()->shouldAllowMockingProtectedMethods();
26
27
        $provider->shouldReceive('getRegisteredGrants')
28
            ->andReturn(['PersonalAccess' => PersonalAccessGrant::class]);
29
30
        $provider->shouldReceive('createAuthorizationServer')->andReturn(\Mockery::mock(AuthorizationServer::class));
31
32
        $provider->shouldReceive('makeCryptKey')
33
            ->andReturn(new CryptKey("-----BEGIN RSA PRIVATE KEY-----\nconfig\n-----END RSA PRIVATE KEY-----", null, false));
34
35
        $provider->shouldReceive('makeGrantPersonalAccess')->once();
36
37
        $provider->setContainer($container);
38
        $provider->registerAuthorizationServer();
39
40
        $server = $container->get('hello.server');
41
        self::assertInstanceOf(AuthorizationServer::class, $server);
42
    }
43
}
44