Passed
Branch master (e8fd46)
by Alexey
03:15
created

RoutesCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 9
1
<?php
2
3
class RoutesCommandTest extends PHPUnit_Framework_TestCase
4
{
5
6
    public function tearDown()
7
    {
8
        Mockery::close();
9
    }
10
11
    /**
12
     * @test
13
     */
14
    public function canHandleEmptyRouteArray()
15
    {
16
        $routeCollector = Mockery::mock(\Venta\Contracts\Routing\RouteCollector::class);
17
        $routeCollector->shouldReceive('getRoutes')->once()->andReturn([]);
18
19
        $command = new \Venta\Framework\Commands\Routes($routeCollector);
20
        $input = new \Symfony\Component\Console\Input\ArrayInput([]);
21
        $output = new \Symfony\Component\Console\Output\BufferedOutput();
22
        $command->run($input, $output);
23
        $result = $output->fetch();
24
25
        $this->assertContains('Application has no routes.', $result);
26
    }
27
28
    /**
29
     * @ignore
30
     */
31
    public function canListRoutes()
32
    {
33
        $routeCollector = Mockery::mock(\Venta\Contracts\Routing\RouteCollector::class);
34
        $route = (new \Venta\Routing\Route(['GET', 'POST'], '/qwerty', 'callable'))
35
            ->withHost('localhost')
36
            ->withMiddleware('middleware1', function () {
37
            })
38
            ->withMiddleware('middleware2', function () {
39
            })
40
            ->withName('named')
41
            ->withScheme('http');
42
        $routeCollector->shouldReceive('getRoutes')->once()->andReturn([$route]);
43
44
        $command = new \Venta\Framework\Commands\Routes($routeCollector);
45
        $input = new \Symfony\Component\Console\Input\ArrayInput([]);
46
        $output = new \Symfony\Component\Console\Output\BufferedOutput();
47
        $command->run($input, $output);
48
        $result = $output->fetch();
49
50
        $this->assertContains('callable', $result);
51
    }
52
53
}
54