mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fix coding standards in Case/Routing
This commit is contained in:
parent
b2d393eeb9
commit
907596b2f5
5 changed files with 31 additions and 29 deletions
|
@ -30,9 +30,11 @@ if (!class_exists('AppController', false)) {
|
|||
* @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 @@ class MyPluginController extends MyPluginAppController {
|
|||
public function admin_add($id = null) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,6 +219,7 @@ class OtherPagesController extends MyPluginAppController {
|
|||
public function index() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,6 +260,7 @@ class TestDispatchPagesController extends AppController {
|
|||
public function camelCased() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -300,6 +309,7 @@ class ArticlesTestController extends ArticlesTestAppController {
|
|||
public function index() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -361,6 +371,7 @@ class SomePostsController extends AppController {
|
|||
public function change() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -461,6 +472,7 @@ class TestCachedPagesController extends Controller {
|
|||
$this->viewClass = 'Theme';
|
||||
$this->theme = 'TestTheme';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -492,6 +504,7 @@ class TimesheetsController extends Controller {
|
|||
public function index() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -733,7 +746,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
*/
|
||||
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 @@ class DispatcherTest extends CakeTestCase {
|
|||
$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 @@ class DispatcherTest extends CakeTestCase {
|
|||
$expected = $pluginUrl;
|
||||
$this->assertEquals($controller->params['controller'], $expected);
|
||||
|
||||
|
||||
Configure::write('Routing.prefixes', array('admin'));
|
||||
|
||||
Router::reload();
|
||||
|
@ -994,7 +1005,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
'plugin' => 'articles_test',
|
||||
'action' => 'admin_index',
|
||||
'prefix' => 'admin',
|
||||
'admin' => true,
|
||||
'admin' => true,
|
||||
'return' => 1
|
||||
);
|
||||
foreach ($expected as $key => $value) {
|
||||
|
@ -1173,8 +1184,8 @@ class DispatcherTest extends CakeTestCase {
|
|||
|
||||
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 @@ class DispatcherTest extends CakeTestCase {
|
|||
|
||||
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 @@ class DispatcherTest extends CakeTestCase {
|
|||
$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);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ App::uses('Router', 'Routing');
|
|||
* @package Cake.Test.Case.Routing.Route
|
||||
**/
|
||||
class CakeRouteTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
|
@ -195,7 +196,6 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$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 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$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 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$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 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$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 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$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 @@ class CakeRouteTest extends CakeTestCase {
|
|||
* 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 @@ class CakeRouteTest extends CakeTestCase {
|
|||
'named' => array()
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -27,6 +27,7 @@ App::uses('Router', 'Routing');
|
|||
* @package Cake.Test.Case.Routing.Route
|
||||
*/
|
||||
class RedirectRouteTestCase extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
|
|
|
@ -686,7 +686,6 @@ class RouterTest extends CakeTestCase {
|
|||
$expected = '/magazine/admin/users/login';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
||||
Router::reload();
|
||||
$request = new CakeRequest();
|
||||
$request->addParams(array(
|
||||
|
@ -722,7 +721,6 @@ class RouterTest extends CakeTestCase {
|
|||
$expected = '/admin/pages/add';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
||||
Router::reload();
|
||||
Router::parse('/');
|
||||
$request = new CakeRequest();
|
||||
|
@ -757,7 +755,6 @@ class RouterTest extends CakeTestCase {
|
|||
$expected = '/admin/pages/edit/284';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
||||
Router::reload();
|
||||
Router::parse('/');
|
||||
|
||||
|
@ -775,7 +772,6 @@ class RouterTest extends CakeTestCase {
|
|||
$expected = '/admin/pages/add';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
|
||||
Router::reload();
|
||||
Router::parse('/');
|
||||
|
||||
|
@ -793,7 +789,6 @@ class RouterTest extends CakeTestCase {
|
|||
$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 @@ class RouterTest extends CakeTestCase {
|
|||
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 @@ class RouterTest extends CakeTestCase {
|
|||
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 @@ class RouterTest extends CakeTestCase {
|
|||
$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 @@ class RouterTest extends CakeTestCase {
|
|||
*/
|
||||
public function testConnectDefaultRoutes() {
|
||||
App::build(array(
|
||||
'plugins' => array(
|
||||
'plugins' => array(
|
||||
CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS
|
||||
)
|
||||
), App::RESET);
|
||||
|
@ -2494,7 +2488,7 @@ class RouterTest extends CakeTestCase {
|
|||
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 @@ class RouterTest extends CakeTestCase {
|
|||
);
|
||||
Router::resourceMap($custom);
|
||||
$this->assertEquals($custom, Router::resourceMap());
|
||||
|
||||
|
||||
Router::resourceMap($default);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue