|
|
@@ -306,6 +306,23 @@ class RouteBuilderTest extends TestCase
|
|
|
public function testPrefix()
|
|
|
{
|
|
|
$routes = new RouteBuilder($this->collection, '/path', ['key' => 'value']);
|
|
|
+ $res = $routes->prefix('admin', ['param' => 'value'], function ($r) {
|
|
|
+ $this->assertInstanceOf('Cake\Routing\RouteBuilder', $r);
|
|
|
+ $this->assertCount(0, $this->collection->routes());
|
|
|
+ $this->assertEquals('/path/admin', $r->path());
|
|
|
+ $this->assertEquals(['prefix' => 'admin', 'key' => 'value', 'param' => 'value'], $r->params());
|
|
|
+ });
|
|
|
+ $this->assertNull($res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test creating sub-scopes with prefix()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testPrefixWithNoParams()
|
|
|
+ {
|
|
|
+ $routes = new RouteBuilder($this->collection, '/path', ['key' => 'value']);
|
|
|
$res = $routes->prefix('admin', function ($r) {
|
|
|
$this->assertInstanceOf('Cake\Routing\RouteBuilder', $r);
|
|
|
$this->assertCount(0, $this->collection->routes());
|
|
|
@@ -323,9 +340,10 @@ class RouteBuilderTest extends TestCase
|
|
|
public function testNestedPrefix()
|
|
|
{
|
|
|
$routes = new RouteBuilder($this->collection, '/admin', ['prefix' => 'admin']);
|
|
|
- $res = $routes->prefix('api', function ($r) {
|
|
|
+ $res = $routes->prefix('api', ['_namePrefix' => 'api:'], function ($r) {
|
|
|
$this->assertEquals('/admin/api', $r->path());
|
|
|
$this->assertEquals(['prefix' => 'admin/api'], $r->params());
|
|
|
+ $this->assertEquals('api:', $r->namePrefix());
|
|
|
});
|
|
|
$this->assertNull($res);
|
|
|
}
|