Completed
Push — master ( c0f250...321e24 )
by Filipe
15:10
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
/**
4
 * This file is part of slick/web_stack package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace spec\Slick\WebStack\Router\Builder;
11
12
use Aura\Router\Map;
13
use Aura\Router\Route;
14
use Slick\WebStack\Router\Builder\FactoryInterface;
15
use Slick\WebStack\Router\Builder\RouteFactory;
16
use PhpSpec\ObjectBehavior;
17
18
/**
19
 * RouteFactorySpec specs
20
 *
21
 * @package spec\Slick\WebStack\Router\Builder
22
 */
23
class RouteFactorySpec extends ObjectBehavior
24
{
25
    function it_is_initializable()
26
    {
27
        $this->shouldHaveType(RouteFactory::class);
28
    }
29
    function its_a_route_factory()
30
    {
31
        $this->shouldBeAnInstanceOf(FactoryInterface::class);
32
    }
33
    function it_parses_simple_route_definitions(
34
        Map $map,
35
        Route $route
36
    )
37
    {
38
        $map->get('blog.read', '/blog/{id}')->willReturn($route);
39
        $this->parse('blog.read', '/blog/{id}', $map)->shouldBe($route);
40
        $map->get('blog.read', '/blog/{id}')->shouldHaveBeenCalled();
41
    }
42 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...
43
        Map $map,
44
        Route $route
45
    )
46
    {
47
        $data = [
48
            'name' => 'blog.edit',
49
            'data' => [
50
                'method' => 'PUT',
51
                'allows' => ['POST'],
52
                'path' => '/blog/{id}/edit'
53
            ],
54
        ];
55
        $map->route($data['name'], $data['data']['path'])->willReturn($route);
56
        $this->parse($data['name'], $data['data'], $map)->shouldBe($route);
57
        $map->route($data['name'], $data['data']['path'])->shouldHaveBeenCalled();
58
        $route->allows(['PUT', 'POST'])->shouldHaveBeenCalled();
59
    }
60 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...
61
        Map $map,
62
        Route $route
63
    )
64
    {
65
        $data = [
66
            'name' => 'blog.edit',
67
            'data' => [
68
                'defaults' => [
69
                    'id' => null
70
                ],
71
                'host' => 'www.example.com',
72
                'path' => '/blog/{id}/edit',
73
                'allows' => ['GET', 'POST']
74
            ],
75
        ];
76
        $map->route($data['name'], $data['data']['path'])->willReturn($route);
77
        $this->parse($data['name'], $data['data'], $map)->shouldBe($route);
78
        $route->defaults($data['data']['defaults'])->shouldHaveBeenCalled();
79
        $route->host($data['data']['host'])->shouldHaveBeenCalled();
80
    }
81
82
}