Skip to content

Commit

Permalink
Convert to using ::class in RouteBuilder tests.
Browse files Browse the repository at this point in the history
Refs #9633
  • Loading branch information
markstory committed Nov 8, 2016
1 parent 9004f6b commit 469d827
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions tests/TestCase/Routing/RouteBuilderTest.php
Expand Up @@ -16,8 +16,11 @@

use Cake\Routing\RouteBuilder;
use Cake\Routing\RouteCollection;
use Cake\Routing\Router;
use Cake\Routing\Route\DashedRoute;
use Cake\Routing\Route\InflectedRoute;
use Cake\Routing\Route\RedirectRoute;
use Cake\Routing\Route\Route;
use Cake\Routing\Router;
use Cake\TestSuite\TestCase;

/**
Expand Down Expand Up @@ -81,8 +84,8 @@ public function testRoutes()

$all = $this->collection->routes();
$this->assertCount(2, $all);
$this->assertInstanceOf('Cake\Routing\Route\Route', $all[0]);
$this->assertInstanceOf('Cake\Routing\Route\Route', $all[1]);
$this->assertInstanceOf(Route::class, $all[0]);
$this->assertInstanceOf(Route::class, $all[1]);
}

/**
Expand All @@ -102,8 +105,8 @@ public function testRouteClass()
$routes->connect('/:controller/:action/*');

$all = $this->collection->routes();
$this->assertInstanceOf('Cake\Routing\Route\InflectedRoute', $all[0]);
$this->assertInstanceOf('Cake\Routing\Route\InflectedRoute', $all[1]);
$this->assertInstanceOf(InflectedRoute::class, $all[0]);
$this->assertInstanceOf(InflectedRoute::class, $all[1]);

$this->collection = new RouteCollection();
$routes = new RouteBuilder($this->collection, '/l');
Expand Down Expand Up @@ -142,7 +145,7 @@ public function testConnectBasic()
$this->assertNull($routes->connect('/:controller'));
$route = $this->collection->routes()[0];

$this->assertInstanceOf('Cake\Routing\Route\Route', $route);
$this->assertInstanceOf(Route::class, $route);
$this->assertEquals('/l/:controller', $route->template);
$expected = ['prefix' => 'api', 'action' => 'index', 'plugin' => null];
$this->assertEquals($expected, $route->defaults);
Expand Down Expand Up @@ -289,12 +292,12 @@ public function testRedirect()
$routes->redirect('/p/:id', ['controller' => 'posts', 'action' => 'view'], ['status' => 301]);
$route = $this->collection->routes()[0];

$this->assertInstanceOf('Cake\Routing\Route\RedirectRoute', $route);
$this->assertInstanceOf(RedirectRoute::class, $route);

$routes->redirect('/old', '/forums', ['status' => 301]);
$route = $this->collection->routes()[1];

$this->assertInstanceOf('Cake\Routing\Route\RedirectRoute', $route);
$this->assertInstanceOf(RedirectRoute::class, $route);
$this->assertEquals('/forums', $route->redirect[0]);
}

Expand All @@ -307,7 +310,7 @@ 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->assertInstanceOf(RouteBuilder::class, $r);
$this->assertCount(0, $this->collection->routes());
$this->assertEquals('/path/admin', $r->path());
$this->assertEquals(['prefix' => 'admin', 'key' => 'value', 'param' => 'value'], $r->params());
Expand All @@ -324,7 +327,7 @@ public function testPrefixWithNoParams()
{
$routes = new RouteBuilder($this->collection, '/path', ['key' => 'value']);
$res = $routes->prefix('admin', function ($r) {
$this->assertInstanceOf('Cake\Routing\RouteBuilder', $r);
$this->assertInstanceOf(RouteBuilder::class, $r);
$this->assertCount(0, $this->collection->routes());
$this->assertEquals('/path/admin', $r->path());
$this->assertEquals(['prefix' => 'admin', 'key' => 'value'], $r->params());
Expand Down Expand Up @@ -680,7 +683,7 @@ public function testFallbacks()
$all = $this->collection->routes();
$this->assertEquals('/api/:controller', $all[0]->template);
$this->assertEquals('/api/:controller/:action/*', $all[1]->template);
$this->assertInstanceOf('Cake\Routing\Route\Route', $all[0]);
$this->assertInstanceOf(Route::class, $all[0]);
}

/**
Expand All @@ -696,7 +699,7 @@ public function testFallbacksWithClass()
$all = $this->collection->routes();
$this->assertEquals('/api/:controller', $all[0]->template);
$this->assertEquals('/api/:controller/:action/*', $all[1]->template);
$this->assertInstanceOf('Cake\Routing\Route\InflectedRoute', $all[0]);
$this->assertInstanceOf(InflectedRoute::class, $all[0]);
}

/**
Expand Down

0 comments on commit 469d827

Please sign in to comment.