| 1 | <?php |
||
| 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 |