Browse Source

rename to DuplicateNamedRouteException and tests

saeid 9 years ago
parent
commit
ee96e831d5

+ 2 - 3
src/Routing/Exception/DuplicateRouteException.php

@@ -15,10 +15,9 @@ namespace Cake\Routing\Exception;
 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
 {
 
     /**

+ 2 - 2
src/Routing/RouteCollection.php

@@ -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;
 
 /**
@@ -79,7 +79,7 @@ class RouteCollection
         // 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.'
                 ]);

+ 1 - 1
src/Template/Error/duplicate_route.ctp

@@ -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();
 

+ 2 - 2
tests/TestCase/Routing/RouteCollectionTest.php

@@ -358,11 +358,11 @@ class RouteCollectionTest extends TestCase
     /**
      * 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']);

+ 4 - 4
tests/TestCase/Routing/RouterTest.php

@@ -1194,10 +1194,10 @@ class RouterTest extends TestCase
     /**
      * 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',
@@ -1221,7 +1221,7 @@ class RouterTest extends TestCase
      *
      * @return void
      */
-    public function testNoDuplicateRouteException()
+    public function testNoDuplicateNamedRouteException()
     {
         Router::connect(
             '/users/:name',
@@ -1231,7 +1231,7 @@ class RouterTest extends TestCase
 		Router::connect(
             '/users/:name',
             ['controller' => 'users', 'action' => 'view'],
-            ['_name' => 'otherName']
+            ['_name' => 'test2']
         );
 		Router::connect(
             '/users/:name',