Passed
Branch master (e8fd46)
by Alexey
02:50
created

RouteGroupSpec   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 3
1
<?php
2
3
namespace spec\Venta\Routing;
4
5
use PhpSpec\ObjectBehavior;
6
use Venta\Routing\Route;
7
8
class RouteGroupSpec extends ObjectBehavior
9
{
10
    function let()
11
    {
12
        $this->addRoute(new Route(['GET'], '/url', 'handler'));
13
    }
14
15
    function it_collects_route_by_callback()
16
    {
17
        $route = new Route(['GET'], '/url', 'handler');
18
        $group = $this->collect(function (\Venta\Contracts\Routing\RouteGroup $group) use ($route) {
19
            $group->addRoute($route);
20
        })->shouldBeAnInstanceOf(\Venta\Contracts\Routing\RouteGroup::class);
21
        assert(in_array($route, $group->getRoutes()));
22
    }
23
24
    function it_is_initializable()
25
    {
26
        $this->shouldHaveType(\Venta\Contracts\Routing\RouteGroup::class);
27
    }
28
29
    function it_sets_host_on_route()
30
    {
31
        $this->setHost('host')->shouldBe($this);
32
        $routes = $this->getRoutes();
33
        $routes[0]->getHost()->shouldBe('host');
34
    }
35
36
    function it_sets_prefix_on_route()
37
    {
38
        $this->setPrefix('prefix')->shouldBe($this);
39
        $routes = $this->getRoutes();
40
        $routes[0]->getPath()->shouldBe('/prefix/url');
41
    }
42
43
    function it_sets_scheme_on_route()
44
    {
45
        $this->setScheme('https')->shouldBe($this);
46
        $routes = $this->getRoutes();
47
        $routes[0]->getScheme()->shouldBe('https');
48
    }
49
50
}
51