Completed
Push — master ( bd4c23...b341c0 )
by Filipe
10:29
created

it_parses_simple_route_definitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
namespace spec\Slick\Mvc\Http\Router\Builder;
4
5
use Aura\Router\Map;
6
use Aura\Router\Route;
7
use Slick\Mvc\Http\Router\Builder\FactoryInterface;
8
use Slick\Mvc\Http\Router\Builder\RouteFactory;
9
use PhpSpec\ObjectBehavior;
10
use Prophecy\Argument;
11
12
class RouteFactorySpec extends ObjectBehavior
13
{
14
    function it_is_initializable()
15
    {
16
        $this->shouldHaveType(RouteFactory::class);
17
    }
18
19
    function its_a_route_factory()
20
    {
21
        $this->shouldBeAnInstanceOf(FactoryInterface::class);
22
    }
23
24
    function it_parses_simple_route_definitions(
25
        Map $map,
26
        Route $route
27
    )
28
    {
29
        $map->get('blog.read', '/blog/{id}')->willReturn($route);
30
        $this->parse('blog.read', '/blog/{id}', $map)->shouldBe($route);
31
        $map->get('blog.read', '/blog/{id}')->shouldHaveBeenCalled();
32
    }
33
34 View Code Duplication
    function it_can_parse_complex_route_definitions(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
        Map $map,
36
        Route $route
37
    )
38
    {
39
        $data = [
40
            'name' => 'blog.edit',
41
            'data' => [
42
                'method' => 'PUT',
43
                'allows' => ['POST'],
44
                'path' => '/blog/{id}/edit'
45
            ],
46
        ];
47
        $map->route($data['name'], $data['data']['path'])->willReturn($route);
48
        $this->parse($data['name'], $data['data'], $map)->shouldBe($route);
49
        $map->route($data['name'], $data['data']['path'])->shouldHaveBeenCalled();
50
        $route->allows(['PUT', 'POST'])->shouldHaveBeenCalled();
51
    }
52
53 View Code Duplication
    function it_can_add_all_known_route_properties(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
        Map $map,
55
        Route $route
56
    )
57
    {
58
        $data = [
59
            'name' => 'blog.edit',
60
            'data' => [
61
                'defaults' => [
62
                    'id' => null
63
                ],
64
                'host' => 'www.example.com',
65
                'path' => '/blog/{id}/edit',
66
                'allows' => ['GET', 'POST']
67
            ],
68
        ];
69
        $map->route($data['name'], $data['data']['path'])->willReturn($route);
70
        $this->parse($data['name'], $data['data'], $map)->shouldBe($route);
71
        $route->defaults($data['data']['defaults'])->shouldHaveBeenCalled();
72
        $route->host($data['data']['host'])->shouldHaveBeenCalled();
73
    }
74
}
75