Skip to content

Commit

Permalink
rename to DuplicateNamedRouteException and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saeideng authored and markstory committed Aug 19, 2016
1 parent f2d7c7c commit ee96e83
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
Expand Up @@ -15,10 +15,9 @@
use Cake\Core\Exception\Exception;

/**
* Exception raised when a URL cannot be reverse routed
* or when a URL cannot be parsed.
* Exception raised when a route names used twice.
*/
class DuplicateRouteException extends Exception
class DuplicateNamedRouteException extends Exception
{

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/RouteCollection.php
Expand Up @@ -15,7 +15,7 @@
namespace Cake\Routing;

use Cake\Routing\Exception\MissingRouteException;
use Cake\Routing\Exception\DuplicateRouteException;
use Cake\Routing\Exception\DuplicateNamedRouteException;
use Cake\Routing\Route\Route;

/**
Expand Down Expand Up @@ -79,7 +79,7 @@ public function add(Route $route, array $options = [])
// Explicit names
if (isset($options['_name'])) {
if (isset($this->_named[$options['_name']])) {
throw new DuplicateRouteException([
throw new DuplicateNamedRouteException([
'url' => $options['_name'],
'message' => 'A named route was found for "%s" that is already used, route names must be unique across your entire application.'
]);
Expand Down
Expand Up @@ -19,7 +19,7 @@ use Cake\Error\Debugger;
$this->layout = 'dev_error';

$this->assign('title', 'Duplicate Route');
$this->assign('templateName', 'duplicate_route.ctp');
$this->assign('templateName', 'duplicate_named_route.ctp');

$attributes = $error->getAttributes();

Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Routing/RouteCollectionTest.php
Expand Up @@ -358,11 +358,11 @@ public function testAddingRoutes()
/**
* Test the add() with some _name.
*
* @expectedException \Cake\Routing\Exception\DuplicateRouteException
* @expectedException \Cake\Routing\Exception\DuplicateNamedRouteException
*
* @return void
*/
public function testAddingDuplicatedRoutesName()
public function testAddingDuplicateNamedRoutes()
{
$one = new Route('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
$two = new Route('/', ['controller' => 'Dashboards', 'action' => 'display']);
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Routing/RouterTest.php
Expand Up @@ -1194,10 +1194,10 @@ public function testNamedRouteException()
/**
* Test that using duplicate names causes exceptions.
*
* @expectedException \Cake\Routing\Exception\DuplicateRouteException
* @expectedException \Cake\Routing\Exception\DuplicateNamedRouteException
* @return void
*/
public function testDuplicateRouteException()
public function testDuplicateNamedRouteException()
{
Router::connect(
'/users/:name',
Expand All @@ -1221,7 +1221,7 @@ public function testDuplicateRouteException()
*
* @return void
*/
public function testNoDuplicateRouteException()
public function testNoDuplicateNamedRouteException()
{
Router::connect(
'/users/:name',
Expand All @@ -1231,7 +1231,7 @@ public function testNoDuplicateRouteException()
Router::connect(
'/users/:name',
['controller' => 'users', 'action' => 'view'],
['_name' => 'otherName']
['_name' => 'test2']
);
Router::connect(
'/users/:name',
Expand Down

0 comments on commit ee96e83

Please sign in to comment.