From 907596b2f5acc0870303f21489c35ceecf7ab6b5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 12 Mar 2012 21:36:27 -0400 Subject: [PATCH] Fix coding standards in Case/Routing --- lib/Cake/Test/Case/Routing/DispatcherTest.php | 29 +++++++++++++------ .../Test/Case/Routing/Route/CakeRouteTest.php | 12 ++------ .../Routing/Route/PluginShortRouteTest.php | 2 ++ .../Case/Routing/Route/RedirectRouteTest.php | 1 + lib/Cake/Test/Case/Routing/RouterTest.php | 16 ++++------ 5 files changed, 31 insertions(+), 29 deletions(-) diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index 80e100a1a68..1a3600bd96d 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -30,9 +30,11 @@ * @package Cake.Test.Case.Routing */ class DispatcherMockCakeResponse extends CakeResponse { + protected function _sendHeader($name, $value = null) { return $name . ' ' . $value; } + } /** @@ -65,11 +67,15 @@ class MyPluginAppController extends AppController { } abstract class DispatcherTestAbstractController extends Controller { + abstract public function index(); + } interface DispatcherTestInterfaceController { + public function index(); + } /** @@ -120,6 +126,7 @@ public function add() { public function admin_add($id = null) { return $id; } + } /** @@ -212,6 +219,7 @@ public function display($page = null) { public function index() { return true; } + } /** @@ -252,6 +260,7 @@ public function admin_index() { public function camelCased() { return true; } + } /** @@ -300,6 +309,7 @@ public function admin_index() { public function index() { return true; } + } /** @@ -361,6 +371,7 @@ public function index() { public function change() { return true; } + } /** @@ -461,6 +472,7 @@ public function themed() { $this->viewClass = 'Theme'; $this->theme = 'TestTheme'; } + } /** @@ -492,6 +504,7 @@ class TimesheetsController extends Controller { public function index() { return true; } + } /** @@ -733,7 +746,7 @@ public function testMissingControllerAbstract() { */ public function testDispatchBasic() { App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) + 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) )); $Dispatcher = new TestDispatcher(); Configure::write('App.baseUrl', '/index.php'); @@ -930,7 +943,6 @@ public function testAutomaticPluginControllerDispatch() { $this->assertSame($controller->action, 'add'); $this->assertEquals($controller->params['named'], array('param' => 'value', 'param2' => 'value2')); - Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; $Dispatcher = new TestDispatcher(); @@ -951,7 +963,6 @@ public function testAutomaticPluginControllerDispatch() { $expected = $pluginUrl; $this->assertEquals($controller->params['controller'], $expected); - Configure::write('Routing.prefixes', array('admin')); Router::reload(); @@ -994,7 +1005,7 @@ public function testAutomaticPluginControllerDispatch() { 'plugin' => 'articles_test', 'action' => 'admin_index', 'prefix' => 'admin', - 'admin' => true, + 'admin' => true, 'return' => 1 ); foreach ($expected as $key => $value) { @@ -1173,8 +1184,8 @@ public function testAssets() { App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Vendor' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor'. DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) + 'Vendor' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS), + 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) )); CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); @@ -1291,8 +1302,8 @@ public function testAsset($url, $file) { App::build(array( 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Vendor' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor'. DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) + 'Vendor' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS), + 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) )); CakePlugin::load(array('TestPlugin', 'PluginJs')); @@ -1302,7 +1313,7 @@ public function testAsset($url, $file) { $Dispatcher->dispatch(new CakeRequest($url), $response); $result = ob_get_clean(); - $path = CAKE. 'Test' . DS . 'test_app' . DS . str_replace('/', DS, $file); + $path = CAKE . 'Test' . DS . 'test_app' . DS . str_replace('/', DS, $file); $file = file_get_contents($path); $this->assertEquals($file, $result); diff --git a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php index 55f8363391c..cefc66af74e 100644 --- a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php @@ -26,6 +26,7 @@ * @package Cake.Test.Case.Routing.Route **/ class CakeRouteTest extends CakeTestCase { + /** * setUp method * @@ -195,7 +196,6 @@ public function testComplexRouteCompilingAndParsing() { $this->assertEquals($result['day'], '01'); $this->assertEquals($result['pass'][0], 'title-of-post'); - $route = new CakeRoute( "/:extra/page/:slug/*", array('controller' => 'pages', 'action' => 'view', 'extra' => null), @@ -254,7 +254,6 @@ public function testMatchBasic() { $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'about')); $this->assertFalse($result); - $route = new CakeRoute('/pages/*', array('controller' => 'pages', 'action' => 'display')); $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'home')); $this->assertEquals($result, '/pages/home'); @@ -262,7 +261,6 @@ public function testMatchBasic() { $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'about')); $this->assertEquals($result, '/pages/about'); - $route = new CakeRoute('/blog/:action', array('controller' => 'posts')); $result = $route->match(array('controller' => 'posts', 'action' => 'view')); $this->assertEquals($result, '/blog/view'); @@ -276,12 +274,10 @@ public function testMatchBasic() { $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => 2)); $this->assertFalse($result); - $route = new CakeRoute('/foo/:controller/:action', array('action' => 'index')); $result = $route->match(array('controller' => 'posts', 'action' => 'view')); $this->assertEquals($result, '/foo/posts/view'); - $route = new CakeRoute('/:plugin/:id/*', array('controller' => 'posts', 'action' => 'view')); $result = $route->match(array('plugin' => 'test', 'controller' => 'posts', 'action' => 'view', 'id' => '1')); $this->assertEquals($result, '/test/1/'); @@ -295,7 +291,6 @@ public function testMatchBasic() { $result = $route->match(array('plugin' => 'fo', 'controller' => 'posts', 'action' => 'edit', 'id' => 1)); $this->assertFalse($result); - $route = new CakeRoute('/admin/subscriptions/:action/*', array( 'controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin' )); @@ -862,8 +857,7 @@ public function testParseTrailing() { * Test the /** special type on parsing - UTF8. * * @return void - */ - + */ public function testParseTrailingUTF8() { $route = new CakeRoute( '/category/**', array('controller' => 'categories','action' => 'index')); $result = $route->parse('/category/%D9%85%D9%88%D8%A8%D8%A7%DB%8C%D9%84'); @@ -874,6 +868,6 @@ public function testParseTrailingUTF8() { 'named' => array() ); $this->assertEquals($expected, $result); + } - } } diff --git a/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php b/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php index 9283bd672c5..b6fa4677c7e 100644 --- a/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php @@ -19,12 +19,14 @@ App::uses('PluginShortRoute', 'Routing/Route'); App::uses('Router', 'Routing'); + /** * test case for PluginShortRoute * * @package Cake.Test.Case.Routing.Route */ class PluginShortRouteTestCase extends CakeTestCase { + /** * setUp method * diff --git a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php index 3ecd200a424..d01fee7cb86 100644 --- a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php @@ -27,6 +27,7 @@ * @package Cake.Test.Case.Routing.Route */ class RedirectRouteTestCase extends CakeTestCase { + /** * setUp method * diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index ade59c3de46..83ecfd18227 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -686,7 +686,6 @@ public function testUrlGenerationWithAdminPrefix() { $expected = '/magazine/admin/users/login'; $this->assertEquals($expected, $result); - Router::reload(); $request = new CakeRequest(); $request->addParams(array( @@ -722,7 +721,6 @@ public function testUrlGenerationWithAdminPrefix() { $expected = '/admin/pages/add'; $this->assertEquals($expected, $result); - Router::reload(); Router::parse('/'); $request = new CakeRequest(); @@ -757,7 +755,6 @@ public function testUrlGenerationWithAdminPrefix() { $expected = '/admin/pages/edit/284'; $this->assertEquals($expected, $result); - Router::reload(); Router::parse('/'); @@ -775,7 +772,6 @@ public function testUrlGenerationWithAdminPrefix() { $expected = '/admin/pages/add'; $this->assertEquals($expected, $result); - Router::reload(); Router::parse('/'); @@ -793,7 +789,6 @@ public function testUrlGenerationWithAdminPrefix() { $expected = '/admin/pages/edit/284'; $this->assertEquals($expected, $result); - Router::reload(); Router::connect('/admin/posts/*', array('controller' => 'posts', 'action' => 'index', 'admin' => true)); Router::parse('/'); @@ -1057,7 +1052,6 @@ public function testPersistentParameters() { Router::connect('/about', array('controller' => 'pages', 'action' => 'view', 'about')); Router::parse('/en/red/posts/view/5'); - $request = new CakeRequest(); Router::setRequestInfo( $request->addParams(array( @@ -1184,7 +1178,7 @@ public function testPrefixRoutingAndPlugins() { Configure::write('Routing.prefixes', array('admin')); $paths = App::path('plugins'); App::build(array( - 'plugins' => array( + 'plugins' => array( CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS ) ), App::RESET); @@ -1320,7 +1314,7 @@ public function testQuerystringGeneration() { $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => array('var' => 'test', 'var2' => 'test2', 'more' => 'test data'))); $this->assertEquals($expected, $result); -// Test bug #4614 + // Test bug #4614 $restore = ini_get('arg_separator.output'); ini_set('arg_separator.output', '&'); $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => array('var' => 'test', 'var2' => 'test2', 'more' => 'test data'))); @@ -2198,7 +2192,7 @@ public function testDefaultsMethod() { */ public function testConnectDefaultRoutes() { App::build(array( - 'plugins' => array( + 'plugins' => array( CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS ) ), App::RESET); @@ -2494,7 +2488,7 @@ public function testResourceMap() { array('action' => 'edit', 'method' => 'POST', 'id' => true) ); $this->assertEquals($default, $exepcted); - + $custom = array( array('action' => 'index', 'method' => 'GET', 'id' => false), array('action' => 'view', 'method' => 'GET', 'id' => true), @@ -2505,7 +2499,7 @@ public function testResourceMap() { ); Router::resourceMap($custom); $this->assertEquals($custom, Router::resourceMap()); - + Router::resourceMap($default); }