HelloServiceProviderTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 5
Bugs 1 Features 5
Metric Value
wmc 1
eloc 17
c 5
b 1
f 5
dl 0
loc 28
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testBoot() 0 26 1
1
<?php
2
3
namespace ByTIC\Hello\Tests;
4
5
use ByTIC\Hello\HelloServiceProvider;
6
use ByTIC\Hello\Utility\ConfigHelper;
7
use ByTIC\Hello\Utility\ModelsHelper;
8
use League\OAuth2\Server\AuthorizationServer;
9
use Mockery as m;
10
use Nip\Config\Config;
11
use Nip\Container\Container;
12
13
use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface;
14
use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
15
use League\OAuth2\Server\Repositories\ClientRepositoryInterface;
16
use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface;
17
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
18
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
19
use Nip\Records\RecordManager;
20
use Nip\Request;
21
use Nip\Router\Route\Route;
22
use Nip\Router\RouteCollection;
23
use Nip\Router\Router;
24
25
/**
26
 * Class HelloServiceProviderTest
27
 * @package ByTIC\Hello\Tests
28
 */
29
class HelloServiceProviderTest extends AbstractTest
30
{
31
    public function testBoot()
32
    {
33
        $container = new Container();
34
        $provider = new HelloServiceProvider();
35
        $provider->setContainer($container);
36
37
        $router = new Router(null, function () {
38
            return new RouteCollection();
39
        });
40
        $container->set('router', $router);
41
42
        $provider->boot();
43
44
        $routes = $router->getRoutes();
45
        self::assertCount(1, $routes);
46
47
        self::assertTrue($routes->has('oauth.keys'));
48
49
        $request = \Nip\Http\Request::create('/oauth/keys');
50
        self::assertSame(
51
            [
52
                '_route' => 'oauth.keys',
53
                'controller' => 'ByTIC\Hello\Modules\Oauth\Controllers\KeysController',
54
                'action' => 'index',
55
            ],
56
            $router->matchRequest($request)
57
        );
58
    }
59
}
60