summaryrefslogtreecommitdiff
path: root/tests/Unit/Routing/RoutingServiceProviderTest.php
blob: 4f1cd5fccfa3ec60e61026dfb9024c1da93eb04e (plain)
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
<?php

namespace Engelsystem\Test\Routing;

use Engelsystem\Application;
use Engelsystem\Routing\RoutingServiceProvider;
use Engelsystem\Routing\UrlGenerator;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;

class RoutingServiceProviderTest extends TestCase
{
    /**
     * @covers \Engelsystem\Routing\RoutingServiceProvider::register()
     */
    public function testRegister()
    {
        /** @var PHPUnit_Framework_MockObject_MockObject|UrlGenerator $urlGenerator */
        $urlGenerator = $this->getMockBuilder(UrlGenerator::class)
            ->getMock();

        /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */
        $app = $this->getMockBuilder(Application::class)
            ->setMethods(['make', 'instance'])
            ->getMock();

        $app->expects($this->once())
            ->method('make')
            ->with(UrlGenerator::class)
            ->willReturn($urlGenerator);

        $app->expects($this->once())
            ->method('instance')
            ->with('routing.urlGenerator', $urlGenerator);

        $serviceProvider = new RoutingServiceProvider($app);
        $serviceProvider->register();
    }
}