Test Failed
Push — master ( a6b51e...5fffdb )
by Gabriel
08:05
created

HelloServiceProviderTest::testBoot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
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\Router;
22
23
/**
24
 * Class HelloServiceProviderTest
25
 * @package ByTIC\Hello\Tests
26
 */
27
class HelloServiceProviderTest extends AbstractTest
28
{
29
    public function testBoot()
30
    {
31
        $container = new Container();
32
        $provider = new HelloServiceProvider();
33
        $provider->setContainer($container);
34
35
        $router = new Router();
36
        $container->set('router', $router);
37
38
        $provider->boot();
39
40
        $routes = $router->getRoutes();
41
        self::assertCount(1, $routes);
0 ignored issues
show
Bug introduced by
It seems like $routes defined by $router->getRoutes() on line 40 can also be of type array<integer,object<Nip\Router\Route\Route>>; however, PHPUnit\Framework\Assert::assertCount() does only seem to accept object<Countable>|object...nit\Framework\iterable>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
42
43
        self::assertTrue($routes->has('oauth.keys'));
44
45
        $request = Request::create('/oauth/keys');
46
        self::assertSame(
47
            [
48
                'controller' => 'ByTIC\Hello\Modules\Oauth\Controllers\KeysController',
49
                'action' => 'index',
50
                '_route' => 'oauth.keys'
51
            ],
52
            $router->matchRequest($request)
53
        );
54
    }
55
}
56