|
|
@@ -63,7 +63,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testBaseUrl()
|
|
|
{
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$routes->fallbacks();
|
|
|
});
|
|
|
$this->assertRegExp('/^http(s)?:\/\//', Router::url('/', true));
|
|
|
@@ -78,7 +78,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testFullBaseURL()
|
|
|
{
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$routes->fallbacks();
|
|
|
});
|
|
|
Router::fullBaseUrl('http://example.com');
|
|
|
@@ -188,7 +188,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testGenerateUrlResourceRoute()
|
|
|
{
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$routes->resources('Posts');
|
|
|
});
|
|
|
|
|
|
@@ -814,8 +814,8 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testUrlGenerationPrefixedPlugin()
|
|
|
{
|
|
|
- Router::prefix('admin', function ($routes) {
|
|
|
- $routes->plugin('MyPlugin', function ($routes) {
|
|
|
+ Router::prefix('admin', function (RouteBuilder $routes) {
|
|
|
+ $routes->plugin('MyPlugin', function (RouteBuilder $routes) {
|
|
|
$routes->fallbacks('InflectedRoute');
|
|
|
});
|
|
|
});
|
|
|
@@ -831,8 +831,8 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testUrlGenerationMultiplePrefixes()
|
|
|
{
|
|
|
- Router::prefix('admin', function ($routes) {
|
|
|
- $routes->prefix('backoffice', function ($routes) {
|
|
|
+ Router::prefix('admin', function (RouteBuilder $routes) {
|
|
|
+ $routes->prefix('backoffice', function (RouteBuilder $routes) {
|
|
|
$routes->fallbacks('InflectedRoute');
|
|
|
});
|
|
|
});
|
|
|
@@ -1566,11 +1566,11 @@ class RouterTest extends TestCase
|
|
|
{
|
|
|
Router::extensions(['json']);
|
|
|
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$routes->setExtensions('rss');
|
|
|
$routes->connect('/', ['controller' => 'Pages', 'action' => 'index']);
|
|
|
|
|
|
- $routes->scope('/api', function ($routes) {
|
|
|
+ $routes->scope('/api', function (RouteBuilder $routes) {
|
|
|
$routes->setExtensions('xml');
|
|
|
$routes->connect('/docs', ['controller' => 'ApiDocs', 'action' => 'index']);
|
|
|
});
|
|
|
@@ -1586,7 +1586,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testResourcesInScope()
|
|
|
{
|
|
|
- Router::scope('/api', ['prefix' => 'api'], function ($routes) {
|
|
|
+ Router::scope('/api', ['prefix' => 'api'], function (RouteBuilder $routes) {
|
|
|
$routes->setExtensions(['json']);
|
|
|
$routes->resources('Articles');
|
|
|
});
|
|
|
@@ -2472,7 +2472,7 @@ class RouterTest extends TestCase
|
|
|
|
|
|
public function testReverseFull()
|
|
|
{
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$routes->fallbacks();
|
|
|
});
|
|
|
$params = [
|
|
|
@@ -2693,7 +2693,7 @@ class RouterTest extends TestCase
|
|
|
['action' => 'other|actions']
|
|
|
);
|
|
|
$result = $route->match(['controller' => 'blog_posts', 'action' => 'foo']);
|
|
|
- $this->assertFalse($result);
|
|
|
+ $this->assertNull($result);
|
|
|
|
|
|
$result = $route->match(['controller' => 'blog_posts', 'action' => 'actions']);
|
|
|
$this->assertEquals('/blog/actions/', $result);
|
|
|
@@ -2708,7 +2708,7 @@ class RouterTest extends TestCase
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
$result = $route->parseRequest($this->makeRequest('/blog/foobar', 'GET'));
|
|
|
- $this->assertFalse($result);
|
|
|
+ $this->assertNull($result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -2718,8 +2718,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testScope()
|
|
|
{
|
|
|
- Router::scope('/path', ['param' => 'value'], function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::scope('/path', ['param' => 'value'], function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('/path', $routes->path());
|
|
|
$this->assertEquals(['param' => 'value'], $routes->params());
|
|
|
$this->assertEquals('', $routes->namePrefix());
|
|
|
@@ -2748,7 +2747,7 @@ class RouterTest extends TestCase
|
|
|
public function testScopeExtensionsContained()
|
|
|
{
|
|
|
Router::extensions(['json']);
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$this->assertEquals(['json'], $routes->getExtensions(), 'Should default to global extensions.');
|
|
|
$routes->setExtensions(['rss']);
|
|
|
|
|
|
@@ -2762,13 +2761,13 @@ class RouterTest extends TestCase
|
|
|
|
|
|
$this->assertEquals(['json', 'rss'], array_values(Router::extensions()));
|
|
|
|
|
|
- Router::scope('/api', function ($routes) {
|
|
|
+ Router::scope('/api', function (RouteBuilder $routes) {
|
|
|
$this->assertEquals(['json'], $routes->getExtensions(), 'Should default to global extensions.');
|
|
|
|
|
|
$routes->setExtensions(['json', 'csv']);
|
|
|
$routes->connect('/export', []);
|
|
|
|
|
|
- $routes->scope('/v1', function ($routes) {
|
|
|
+ $routes->scope('/v1', function (RouteBuilder $routes) {
|
|
|
$this->assertEquals(['json', 'csv'], $routes->getExtensions());
|
|
|
});
|
|
|
});
|
|
|
@@ -2784,7 +2783,7 @@ class RouterTest extends TestCase
|
|
|
public function testScopeOptions()
|
|
|
{
|
|
|
$options = ['param' => 'value', 'routeClass' => 'InflectedRoute', 'extensions' => ['json']];
|
|
|
- Router::scope('/path', $options, function ($routes) {
|
|
|
+ Router::scope('/path', $options, function (RouteBuilder $routes) {
|
|
|
$this->assertSame('InflectedRoute', $routes->getRouteClass());
|
|
|
$this->assertSame(['json'], $routes->getExtensions());
|
|
|
$this->assertEquals('/path', $routes->path());
|
|
|
@@ -2799,8 +2798,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testScopeNamePrefix()
|
|
|
{
|
|
|
- Router::scope('/path', ['param' => 'value', '_namePrefix' => 'path:'], function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::scope('/path', ['param' => 'value', '_namePrefix' => 'path:'], function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('/path', $routes->path());
|
|
|
$this->assertEquals(['param' => 'value'], $routes->params());
|
|
|
$this->assertEquals('path:', $routes->namePrefix());
|
|
|
@@ -2816,14 +2814,12 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testPrefix()
|
|
|
{
|
|
|
- Router::prefix('admin', function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::prefix('admin', function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('/admin', $routes->path());
|
|
|
$this->assertEquals(['prefix' => 'admin'], $routes->params());
|
|
|
});
|
|
|
|
|
|
- Router::prefix('admin', ['_namePrefix' => 'admin:'], function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::prefix('admin', ['_namePrefix' => 'admin:'], function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('admin:', $routes->namePrefix());
|
|
|
$this->assertEquals(['prefix' => 'admin'], $routes->params());
|
|
|
});
|
|
|
@@ -2836,14 +2832,12 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testPrefixOptions()
|
|
|
{
|
|
|
- Router::prefix('admin', ['param' => 'value'], function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::prefix('admin', ['param' => 'value'], function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('/admin', $routes->path());
|
|
|
$this->assertEquals(['prefix' => 'admin', 'param' => 'value'], $routes->params());
|
|
|
});
|
|
|
|
|
|
- Router::prefix('CustomPath', ['path' => '/custom-path'], function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::prefix('CustomPath', ['path' => '/custom-path'], function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('/custom-path', $routes->path());
|
|
|
$this->assertEquals(['prefix' => 'custom_path'], $routes->params());
|
|
|
});
|
|
|
@@ -2856,8 +2850,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testPlugin()
|
|
|
{
|
|
|
- Router::plugin('DebugKit', function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::plugin('DebugKit', function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('/debug_kit', $routes->path());
|
|
|
$this->assertEquals(['plugin' => 'DebugKit'], $routes->params());
|
|
|
});
|
|
|
@@ -2870,14 +2863,12 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
public function testPluginOptions()
|
|
|
{
|
|
|
- Router::plugin('DebugKit', ['path' => '/debugger'], function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::plugin('DebugKit', ['path' => '/debugger'], function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('/debugger', $routes->path());
|
|
|
$this->assertEquals(['plugin' => 'DebugKit'], $routes->params());
|
|
|
});
|
|
|
|
|
|
- Router::plugin('Contacts', ['_namePrefix' => 'contacts:'], function ($routes) {
|
|
|
- $this->assertInstanceOf('Cake\Routing\RouteBuilder', $routes);
|
|
|
+ Router::plugin('Contacts', ['_namePrefix' => 'contacts:'], function (RouteBuilder $routes) {
|
|
|
$this->assertEquals('contacts:', $routes->namePrefix());
|
|
|
});
|
|
|
}
|
|
|
@@ -2906,7 +2897,7 @@ class RouterTest extends TestCase
|
|
|
|
|
|
Router::reload();
|
|
|
Router::defaultRouteClass('DashedRoute');
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$routes->fallbacks();
|
|
|
});
|
|
|
|
|
|
@@ -3045,7 +3036,7 @@ class RouterTest extends TestCase
|
|
|
*/
|
|
|
protected function _connectDefaultRoutes()
|
|
|
{
|
|
|
- Router::scope('/', function ($routes) {
|
|
|
+ Router::scope('/', function (RouteBuilder $routes) {
|
|
|
$routes->fallbacks('InflectedRoute');
|
|
|
});
|
|
|
}
|