mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-03 14:43:49 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -2,19 +2,18 @@
|
|||
/**
|
||||
* CakeRequest Test case file.
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Test.Case.Routing.Route
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('CakeRoute', 'Routing/Route');
|
||||
|
@ -24,7 +23,7 @@ App::uses('Router', 'Routing');
|
|||
* Test case for CakeRoute
|
||||
*
|
||||
* @package Cake.Test.Case.Routing.Route
|
||||
**/
|
||||
*/
|
||||
class CakeRouteTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
|
@ -41,7 +40,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
* Test the construction of a CakeRoute
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testConstruction() {
|
||||
$route = new CakeRoute('/:controller/:action/:id', array(), array('id' => '[0-9]+'));
|
||||
|
||||
|
@ -55,7 +54,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
* test Route compiling.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testBasicRouteCompiling() {
|
||||
$route = new CakeRoute('/', array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||
$result = $route->compile();
|
||||
|
@ -107,7 +106,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
* test compiling routes with keys that have patterns
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testRouteCompilingWithParamPatterns() {
|
||||
$route = new CakeRoute(
|
||||
'/:controller/:action/:id',
|
||||
|
@ -119,7 +118,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$this->assertRegExp($result, '/posts/view/518098');
|
||||
$this->assertNotRegExp($result, '/posts/edit/name-of-post');
|
||||
$this->assertNotRegExp($result, '/posts/edit/4/other:param');
|
||||
$this->assertEquals(array('controller', 'action', 'id'), $route->keys);
|
||||
$this->assertEquals(array('id', 'controller', 'action'), $route->keys);
|
||||
|
||||
$route = new CakeRoute(
|
||||
'/:lang/:controller/:action/:id',
|
||||
|
@ -131,7 +130,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$this->assertRegExp($result, '/cze/articles/view/1');
|
||||
$this->assertNotRegExp($result, '/language/articles/view/2');
|
||||
$this->assertNotRegExp($result, '/eng/articles/view/name-of-article');
|
||||
$this->assertEquals(array('lang', 'controller', 'action', 'id'), $route->keys);
|
||||
$this->assertEquals(array('lang', 'id', 'controller', 'action'), $route->keys);
|
||||
|
||||
foreach (array(':', '@', ';', '$', '-') as $delim) {
|
||||
$route = new CakeRoute('/posts/:id' . $delim . ':title');
|
||||
|
@ -142,7 +141,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$this->assertNotRegExp($result, '/posts/11!nameofarticle');
|
||||
$this->assertNotRegExp($result, '/posts/11');
|
||||
|
||||
$this->assertEquals(array('id', 'title'), $route->keys);
|
||||
$this->assertEquals(array('title', 'id'), $route->keys);
|
||||
}
|
||||
|
||||
$route = new CakeRoute(
|
||||
|
@ -156,7 +155,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$this->assertNotRegExp($result, '/posts/hey_now:nameofarticle');
|
||||
$this->assertNotRegExp($result, '/posts/:nameofarticle/2009');
|
||||
$this->assertNotRegExp($result, '/posts/:nameofarticle/01');
|
||||
$this->assertEquals(array('id', 'title', 'year'), $route->keys);
|
||||
$this->assertEquals(array('year', 'title', 'id'), $route->keys);
|
||||
|
||||
$route = new CakeRoute(
|
||||
'/posts/:url_title-(uuid::id)',
|
||||
|
@ -205,7 +204,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
|
||||
$this->assertRegExp($result, '/some_extra/page/this_is_the_slug');
|
||||
$this->assertRegExp($result, '/page/this_is_the_slug');
|
||||
$this->assertEquals(array('extra', 'slug'), $route->keys);
|
||||
$this->assertEquals(array('slug', 'extra'), $route->keys);
|
||||
$this->assertEquals(array('extra' => '[a-z1-9_]*', 'slug' => '[a-z1-9_]+', 'action' => 'view'), $route->options);
|
||||
$expected = array(
|
||||
'controller' => 'pages',
|
||||
|
@ -235,7 +234,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
* test that routes match their pattern.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testMatchBasic() {
|
||||
$route = new CakeRoute('/:controller/:action/:id', array('plugin' => null));
|
||||
$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null));
|
||||
|
@ -309,6 +308,11 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$result = $route->match($url);
|
||||
$expected = '/admin/subscriptions/edit_admin_e/1';
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'admin_edit', 1);
|
||||
$result = $route->match($url);
|
||||
$expected = '/admin/subscriptions/edit/1';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,6 +487,40 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$this->assertEquals('red', $result['color']);
|
||||
}
|
||||
|
||||
/**
|
||||
* test persist with a non array value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testPersistParamsNonArray() {
|
||||
$url = array('controller' => 'posts', 'action' => 'index');
|
||||
$params = array('lang' => 'en', 'color' => 'blue');
|
||||
|
||||
$route = new CakeRoute(
|
||||
'/:lang/:color/blog/:action',
|
||||
array('controller' => 'posts')
|
||||
// No persist options
|
||||
);
|
||||
$result = $route->persistParams($url, $params);
|
||||
$this->assertEquals($url, $result);
|
||||
|
||||
$route = new CakeRoute(
|
||||
'/:lang/:color/blog/:action',
|
||||
array('controller' => 'posts'),
|
||||
array('persist' => false)
|
||||
);
|
||||
$result = $route->persistParams($url, $params);
|
||||
$this->assertEquals($url, $result);
|
||||
|
||||
$route = new CakeRoute(
|
||||
'/:lang/:color/blog/:action',
|
||||
array('controller' => 'posts'),
|
||||
array('persist' => 'derp')
|
||||
);
|
||||
$result = $route->persistParams($url, $params);
|
||||
$this->assertEquals($url, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test the parse method of CakeRoute.
|
||||
*
|
||||
|
@ -817,6 +855,41 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test matching of parameters where one parameter name starts with another parameter name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testMatchSimilarParameters() {
|
||||
$route = new CakeRoute('/:thisParam/:thisParamIsLonger');
|
||||
|
||||
$url = array(
|
||||
'thisParamIsLonger' => 'bar',
|
||||
'thisParam' => 'foo',
|
||||
);
|
||||
|
||||
$result = $route->match($url);
|
||||
$expected = '/foo/bar';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test match() with trailing ** style routes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testMatchTrailing() {
|
||||
$route = new CakeRoute('/pages/**', array('controller' => 'pages', 'action' => 'display'));
|
||||
$id = 'test/ spaces/漢字/la†în';
|
||||
$result = $route->match(array(
|
||||
'controller' => 'pages',
|
||||
'action' => 'display',
|
||||
$id
|
||||
));
|
||||
$expected = '/pages/test/%20spaces/%E6%BC%A2%E5%AD%97/la%E2%80%A0%C3%AEn';
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test restructuring args with pass key
|
||||
*
|
||||
|
@ -869,7 +942,7 @@ class CakeRouteTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testParseTrailingUTF8() {
|
||||
$route = new CakeRoute('/category/**', array('controller' => 'categories','action' => 'index'));
|
||||
$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');
|
||||
$expected = array(
|
||||
'controller' => 'categories',
|
||||
|
@ -880,4 +953,58 @@ class CakeRouteTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that utf-8 patterns work for :section
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUTF8PatternOnSection() {
|
||||
$route = new CakeRoute(
|
||||
'/:section',
|
||||
array('plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index'),
|
||||
array(
|
||||
'persist' => array('section'),
|
||||
'section' => 'آموزش|weblog'
|
||||
)
|
||||
);
|
||||
|
||||
$result = $route->parse('/%D8%A2%D9%85%D9%88%D8%B2%D8%B4');
|
||||
$expected = array('section' => 'آموزش', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => array(), 'named' => array());
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = $route->parse('/weblog');
|
||||
$expected = array('section' => 'weblog', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => array(), 'named' => array());
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for __set_state magic method on CakeRoute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSetState() {
|
||||
$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('/'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
/**
|
||||
* CakeRequest Test case file.
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Test.Case.Routing.Route
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('PluginShortRoute', 'Routing/Route');
|
||||
|
@ -25,7 +24,7 @@ App::uses('Router', 'Routing');
|
|||
*
|
||||
* @package Cake.Test.Case.Routing.Route
|
||||
*/
|
||||
class PluginShortRouteTest extends CakeTestCase {
|
||||
class PluginShortRouteTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
|
@ -56,7 +55,7 @@ class PluginShortRouteTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* test the reverse routing of the plugin shortcut urls.
|
||||
* test the reverse routing of the plugin shortcut URLs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -2,19 +2,18 @@
|
|||
/**
|
||||
* CakeRequest Test case file.
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Test.Case.Routing.Route
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('RedirectRoute', 'Routing/Route');
|
||||
|
@ -26,7 +25,7 @@ App::uses('Router', 'Routing');
|
|||
*
|
||||
* @package Cake.Test.Case.Routing.Route
|
||||
*/
|
||||
class RedirectRouteTest extends CakeTestCase {
|
||||
class RedirectRouteTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
|
@ -48,14 +47,14 @@ class RedirectRouteTest extends CakeTestCase {
|
|||
$route = new RedirectRoute('/home', array('controller' => 'posts'));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/home');
|
||||
$route->parse('/home');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/posts', true), $header['Location']);
|
||||
|
||||
$route = new RedirectRoute('/home', array('controller' => 'posts', 'action' => 'index'));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/home');
|
||||
$route->parse('/home');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/posts', true), $header['Location']);
|
||||
$this->assertEquals(301, $route->response->statusCode());
|
||||
|
@ -63,14 +62,14 @@ class RedirectRouteTest extends CakeTestCase {
|
|||
$route = new RedirectRoute('/google', 'http://google.com');
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/google');
|
||||
$route->parse('/google');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals('http://google.com', $header['Location']);
|
||||
|
||||
$route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('status' => 302));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/posts/2');
|
||||
$route->parse('/posts/2');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/posts/view', true), $header['Location']);
|
||||
$this->assertEquals(302, $route->response->statusCode());
|
||||
|
@ -78,30 +77,46 @@ class RedirectRouteTest extends CakeTestCase {
|
|||
$route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('persist' => true));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/posts/2');
|
||||
$route->parse('/posts/2');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/posts/view/2', true), $header['Location']);
|
||||
|
||||
$route = new RedirectRoute('/posts/*', '/test', array('persist' => true));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/posts/2');
|
||||
$route->parse('/posts/2');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/test', true), $header['Location']);
|
||||
|
||||
$route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add'), array('persist' => true));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/my_controllers/do_something/passme/named:param');
|
||||
$route->parse('/my_controllers/do_something/passme/named:param');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/tags/add/passme/named:param', true), $header['Location']);
|
||||
|
||||
$route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add'));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/my_controllers/do_something/passme/named:param');
|
||||
$route->parse('/my_controllers/do_something/passme/named:param');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/tags/add', true), $header['Location']);
|
||||
|
||||
$route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$route->parse('/nl/my_controllers/');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/tags/add/lang:nl', true), $header['Location']);
|
||||
|
||||
Router::$routes = array(); // reset default routes
|
||||
Router::connect('/:lang/preferred_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
|
||||
$route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang')));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$route->parse('/nl/my_controllers/');
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals(Router::url('/nl/preferred_controllers', true), $header['Location']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue