|
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); |
|
|
|
|
|
|
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
|
|
|
|
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:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.