From 6171ef69c36650d338a6dc10095b0cf0c1bcfe6e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 27 Oct 2014 20:49:38 -0400 Subject: [PATCH] Update test cases for CakeRoute::__set_state It removes the eval and test the __set_state more explicitly. --- .../Test/Case/Routing/Route/CakeRouteTest.php | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php index 3294f3577..6a05b378c 100644 --- a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php @@ -978,16 +978,33 @@ class CakeRouteTest extends CakeTestCase { } /** - * Test for var_export on CakeRoute + * Test for __set_state magic method on CakeRoute * * @return void */ public function testSetState() { - $route = new CakeRoute('/', array('controller' => 'pages', 'action' => 'display', 'home')); - // @codingStandardsIgnoreStart - $retrievedRoute = eval('return ' . var_export($route, true) . ';'); - // @codingStandardsIgnoreEnd - $this->assertEquals($route, $retrievedRoute); + $route = CakeRoute::__set_state(array( + 'keys' => array(), + 'options' => array(), + 'defaults' => array( + 'controller' => 'pages', + 'action' => 'display', + 'home', + ), + 'template' => '/', + '_greedy' => false, + '_compiledRoute' => null, + '_headerMap' => array ( + 'type' => 'content_type', + 'method' => 'request_method', + 'server' => 'server_name', + ), + )); + $this->assertInstanceOf('CakeRoute', $route); + $this->assertSame('/', $route->match(array('controller' => 'pages', 'action' => 'display', 'home'))); + $this->assertFalse($route->match(array('controller' => 'pages', 'action' => 'display', 'about'))); + $expected = array('controller' => 'pages', 'action' => 'display', 'pass' => array('home'), 'named' => array()); + $this->assertEquals($expected, $route->parse('/')); } }