-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRoutingServiceProviderTest.php
47 lines (35 loc) · 1.57 KB
/
RoutingServiceProviderTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Illuminatech\UrlTrailingSlash\Test;
use Illuminate\Config\Repository;
use Illuminate\Container\Container;
use Illuminate\Events\EventServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Routing\RoutingServiceProvider as BaseRoutingServiceProvider;
use Illuminatech\UrlTrailingSlash\Router;
use Illuminatech\UrlTrailingSlash\RoutingServiceProvider;
use Illuminatech\UrlTrailingSlash\UrlGenerator;
class RoutingServiceProviderTest extends TestCase
{
protected function readProtectedProperty(object $object, string $property)
{
$reflection = new \ReflectionObject($object);
$property = $reflection->getProperty($property);
$property->setAccessible(true);
return $property->getValue($object);
}
public function testRegister()
{
$container = new Container();
$container->instance('config', new Repository());
$container->instance('request', new Request());
(new EventServiceProvider($container))->register();
(new BaseRoutingServiceProvider($container))->register();
(new RoutingServiceProvider($container))->register();
$router = $container->make('router');
$this->assertInstanceOf(Router::class, $router);
$urlGenerator = $container->make('url');
$this->assertInstanceOf(UrlGenerator::class, $urlGenerator);
$this->assertInstanceOf(\Closure::class, $this->readProtectedProperty($urlGenerator, 'sessionResolver'));
$this->assertInstanceOf(\Closure::class, $this->readProtectedProperty($urlGenerator, 'keyResolver'));
}
}