Skip to content

Commit ded78ac

Browse files
committed
Merge pull request dingo#895 from jonsa/master
Added a test for Contract\Routing\Adapter::getIterableRoutes()
2 parents f1f0bd2 + da0d8f8 commit ded78ac

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/Routing/Adapter/BaseAdapterTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,16 @@ public function testRoutingResources()
217217

218218
$this->assertEquals('foo', $this->router->dispatch($request)->getContent(), 'Router did not register controller correctly.');
219219
}
220+
221+
public function testIterableRoutes()
222+
{
223+
$this->router->version('v1', ['namespace' => 'Dingo\Api\Tests\Stubs'], function () {
224+
$this->router->post('/', ['uses' => 'RoutingControllerStub@index']);
225+
$this->router->post('/find', ['uses' => 'RoutingControllerOtherStub@show']);
226+
});
227+
228+
$routes = $this->adapter->getIterableRoutes();
229+
$this->assertTrue(array_key_exists('v1', (array) $routes));
230+
$this->assertEquals(2, count($routes['v1']));
231+
}
220232
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Dingo\Api\Tests\Stubs;
4+
5+
use Illuminate\Routing\Controller;
6+
7+
class RoutingControllerOtherStub extends Controller
8+
{
9+
public function find()
10+
{
11+
return 'baz';
12+
}
13+
}

0 commit comments

Comments
 (0)