Skip to content

Commit

Permalink
Fix coding standards in Case/Routing
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 13, 2012
1 parent b2d393e commit 907596b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 29 deletions.
29 changes: 20 additions & 9 deletions lib/Cake/Test/Case/Routing/DispatcherTest.php
Expand Up @@ -30,9 +30,11 @@
* @package Cake.Test.Case.Routing
*/
class DispatcherMockCakeResponse extends CakeResponse {

protected function _sendHeader($name, $value = null) {
return $name . ' ' . $value;
}

}

/**
Expand Down Expand Up @@ -65,11 +67,15 @@ class MyPluginAppController extends AppController {
}

abstract class DispatcherTestAbstractController extends Controller {

abstract public function index();

}

interface DispatcherTestInterfaceController {

public function index();

}

/**
Expand Down Expand Up @@ -120,6 +126,7 @@ public function add() {
public function admin_add($id = null) {
return $id;
}

}

/**
Expand Down Expand Up @@ -212,6 +219,7 @@ public function display($page = null) {
public function index() {
return true;
}

}

/**
Expand Down Expand Up @@ -252,6 +260,7 @@ public function admin_index() {
public function camelCased() {
return true;
}

}

/**
Expand Down Expand Up @@ -300,6 +309,7 @@ public function admin_index() {
public function index() {
return true;
}

}

/**
Expand Down Expand Up @@ -361,6 +371,7 @@ public function index() {
public function change() {
return true;
}

}

/**
Expand Down Expand Up @@ -461,6 +472,7 @@ public function themed() {
$this->viewClass = 'Theme';
$this->theme = 'TestTheme';
}

}

/**
Expand Down Expand Up @@ -492,6 +504,7 @@ class TimesheetsController extends Controller {
public function index() {
return true;
}

}

/**
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand All @@ -951,7 +963,6 @@ public function testAutomaticPluginControllerDispatch() {
$expected = $pluginUrl;
$this->assertEquals($controller->params['controller'], $expected);


Configure::write('Routing.prefixes', array('admin'));

Router::reload();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'));

Expand Down Expand Up @@ -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'));

Expand All @@ -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);

Expand Down
12 changes: 3 additions & 9 deletions lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php
Expand Up @@ -26,6 +26,7 @@
* @package Cake.Test.Case.Routing.Route
**/
class CakeRouteTest extends CakeTestCase {

/**
* setUp method
*
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -254,15 +254,13 @@ 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');

$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');
Expand All @@ -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/');
Expand All @@ -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'
));
Expand Down Expand Up @@ -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');
Expand All @@ -874,6 +868,6 @@ public function testParseTrailingUTF8() {
'named' => array()
);
$this->assertEquals($expected, $result);
}

}
}
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php
Expand Up @@ -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
*
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php
Expand Up @@ -27,6 +27,7 @@
* @package Cake.Test.Case.Routing.Route
*/
class RedirectRouteTestCase extends CakeTestCase {

/**
* setUp method
*
Expand Down
16 changes: 5 additions & 11 deletions lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -686,7 +686,6 @@ public function testUrlGenerationWithAdminPrefix() {
$expected = '/magazine/admin/users/login';
$this->assertEquals($expected, $result);


Router::reload();
$request = new CakeRequest();
$request->addParams(array(
Expand Down Expand Up @@ -722,7 +721,6 @@ public function testUrlGenerationWithAdminPrefix() {
$expected = '/admin/pages/add';
$this->assertEquals($expected, $result);


Router::reload();
Router::parse('/');
$request = new CakeRequest();
Expand Down Expand Up @@ -757,7 +755,6 @@ public function testUrlGenerationWithAdminPrefix() {
$expected = '/admin/pages/edit/284';
$this->assertEquals($expected, $result);


Router::reload();
Router::parse('/');

Expand All @@ -775,7 +772,6 @@ public function testUrlGenerationWithAdminPrefix() {
$expected = '/admin/pages/add';
$this->assertEquals($expected, $result);


Router::reload();
Router::parse('/');

Expand All @@ -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('/');
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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')));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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),
Expand All @@ -2505,7 +2499,7 @@ public function testResourceMap() {
);
Router::resourceMap($custom);
$this->assertEquals($custom, Router::resourceMap());

Router::resourceMap($default);
}

Expand Down

0 comments on commit 907596b

Please sign in to comment.