mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 00:03:58 +01: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
				
			
		|  | @ -1,17 +1,19 @@ | |||
| <?php | ||||
| /** | ||||
|  * 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 Project | ||||
|  * @package       Cake.Test.Case.Controller | ||||
|  * @since         CakePHP(tm) v 1.2.0.5436 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Controller', 'Controller'); | ||||
| App::uses('Router', 'Routing'); | ||||
| App::uses('CakeRequest', 'Network'); | ||||
|  | @ -48,7 +50,6 @@ class ControllerTestAppController extends Controller { | |||
| 	public $components = array('Cookie'); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * ControllerPost class | ||||
|  * | ||||
|  | @ -56,17 +57,10 @@ class ControllerTestAppController extends Controller { | |||
|  */ | ||||
| class ControllerPost extends CakeTestModel { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'ControllerPost' | ||||
|  */ | ||||
| 	public $name = 'ControllerPost'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var string 'posts' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $useTable = 'posts'; | ||||
| 
 | ||||
|  | @ -80,7 +74,7 @@ class ControllerPost extends CakeTestModel { | |||
| /** | ||||
|  * lastQuery property | ||||
|  * | ||||
|  * @var mixed null | ||||
|  * @var mixed | ||||
|  */ | ||||
| 	public $lastQuery = null; | ||||
| 
 | ||||
|  | @ -102,7 +96,7 @@ class ControllerPost extends CakeTestModel { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function find($type = 'first', $options = array()) { | ||||
| 		if ($type == 'popular') { | ||||
| 		if ($type === 'popular') { | ||||
| 			$conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1'); | ||||
| 			$options = Hash::merge($options, compact('conditions')); | ||||
| 			return parent::find('all', $options); | ||||
|  | @ -119,13 +113,6 @@ class ControllerPost extends CakeTestModel { | |||
|  */ | ||||
| class ControllerCommentsController extends ControllerTestAppController { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'ControllerPost' | ||||
|  */ | ||||
| 	public $name = 'ControllerComments'; | ||||
| 
 | ||||
| 	protected $_mergeParent = 'ControllerTestAppController'; | ||||
| } | ||||
| 
 | ||||
|  | @ -139,14 +126,14 @@ class ControllerComment extends CakeTestModel { | |||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'ControllerComment' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'Comment'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var string 'comments' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $useTable = 'comments'; | ||||
| 
 | ||||
|  | @ -160,7 +147,7 @@ class ControllerComment extends CakeTestModel { | |||
| /** | ||||
|  * alias property | ||||
|  * | ||||
|  * @var string 'ControllerComment' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $alias = 'ControllerComment'; | ||||
| } | ||||
|  | @ -172,24 +159,17 @@ class ControllerComment extends CakeTestModel { | |||
|  */ | ||||
| class ControllerAlias extends CakeTestModel { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'ControllerAlias' | ||||
|  */ | ||||
| 	public $name = 'ControllerAlias'; | ||||
| 
 | ||||
| /** | ||||
|  * alias property | ||||
|  * | ||||
|  * @var string 'ControllerSomeAlias' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $alias = 'ControllerSomeAlias'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var string 'posts' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $useTable = 'posts'; | ||||
| } | ||||
|  | @ -203,20 +183,20 @@ class NameTest extends CakeTestModel { | |||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * @var string 'Name' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $name = 'Name'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * @var string 'names' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $useTable = 'comments'; | ||||
| 
 | ||||
| /** | ||||
|  * alias property | ||||
|  * | ||||
|  * @var string 'ControllerComment' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $alias = 'Name'; | ||||
| } | ||||
|  | @ -228,12 +208,6 @@ class NameTest extends CakeTestModel { | |||
|  */ | ||||
| class TestController extends ControllerTestAppController { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * @var string 'Name' | ||||
|  */ | ||||
| 	public $name = 'Test'; | ||||
| 
 | ||||
| /** | ||||
|  * helpers property | ||||
|  * | ||||
|  | @ -310,7 +284,7 @@ class TestController extends ControllerTestAppController { | |||
|  * | ||||
|  * @package       Cake.Test.Case.Controller | ||||
|  */ | ||||
| class TestComponent extends Object { | ||||
| class TestComponent extends CakeObject { | ||||
| 
 | ||||
| /** | ||||
|  * beforeRedirect method | ||||
|  | @ -359,6 +333,13 @@ class TestComponent extends Object { | |||
| 
 | ||||
| class Test2Component extends TestComponent { | ||||
| 
 | ||||
| 	public $model; | ||||
| 
 | ||||
| 	public function __construct(ComponentCollection $collection, $settings) { | ||||
| 		$this->controller = $collection->getController(); | ||||
| 		$this->model = $this->controller->modelClass; | ||||
| 	} | ||||
| 
 | ||||
| 	public function beforeRender(Controller $controller) { | ||||
| 		return false; | ||||
| 	} | ||||
|  | @ -372,12 +353,6 @@ class Test2Component extends TestComponent { | |||
|  */ | ||||
| class AnotherTestController extends ControllerTestAppController { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * @var string 'Name' | ||||
|  */ | ||||
| 	public $name = 'AnotherTest'; | ||||
| 
 | ||||
| /** | ||||
|  * uses property | ||||
|  * | ||||
|  | @ -446,11 +421,24 @@ class ControllerTest extends CakeTestCase { | |||
| 
 | ||||
| 		$result = $Controller->loadModel('ControllerPost'); | ||||
| 		$this->assertTrue($result); | ||||
| 		$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost')); | ||||
| 		$this->assertTrue(in_array('ControllerPost', $Controller->uses)); | ||||
| 		$this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); | ||||
| 		$this->assertContains('ControllerPost', $Controller->uses); | ||||
| 	} | ||||
| 
 | ||||
| 		ClassRegistry::flush(); | ||||
| 		unset($Controller); | ||||
| /** | ||||
|  * Test loadModel() when uses = true. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testLoadModelUsesTrue() { | ||||
| 		$request = new CakeRequest('controller_posts/index'); | ||||
| 		$response = $this->getMock('CakeResponse'); | ||||
| 		$Controller = new Controller($request, $response); | ||||
| 		$Controller->uses = true; | ||||
| 
 | ||||
| 		$Controller->loadModel('ControllerPost'); | ||||
| 		$this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); | ||||
| 		$this->assertContains('ControllerPost', $Controller->uses); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -494,8 +482,8 @@ class ControllerTest extends CakeTestCase { | |||
| 		$Controller = new Controller($request); | ||||
| 		$Controller->uses = array('ControllerPost', 'ControllerComment'); | ||||
| 		$Controller->constructClasses(); | ||||
| 		$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost')); | ||||
| 		$this->assertTrue(is_a($Controller->ControllerComment, 'ControllerComment')); | ||||
| 		$this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); | ||||
| 		$this->assertInstanceOf('ControllerComment', $Controller->ControllerComment); | ||||
| 
 | ||||
| 		$this->assertEquals('Comment', $Controller->ControllerComment->name); | ||||
| 
 | ||||
|  | @ -509,7 +497,23 @@ class ControllerTest extends CakeTestCase { | |||
| 		$Controller->constructClasses(); | ||||
| 
 | ||||
| 		$this->assertTrue(isset($Controller->TestPluginPost)); | ||||
| 		$this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost')); | ||||
| 		$this->assertInstanceOf('TestPluginPost', $Controller->TestPluginPost); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testConstructClassesWithComponents method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testConstructClassesWithComponents() { | ||||
| 		$Controller = new TestPluginController(new CakeRequest(), new CakeResponse()); | ||||
| 		$Controller->uses = array('NameTest'); | ||||
| 		$Controller->components[] = 'Test2'; | ||||
| 
 | ||||
| 		$Controller->constructClasses(); | ||||
| 		$this->assertEquals('NameTest', $Controller->Test2->model); | ||||
| 		$this->assertEquals('Name', $Controller->NameTest->name); | ||||
| 		$this->assertEquals('Name', $Controller->NameTest->alias); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -543,8 +547,8 @@ class ControllerTest extends CakeTestCase { | |||
| 		$Controller->flash('this should work', '/flash'); | ||||
| 		$result = $Controller->response->body(); | ||||
| 
 | ||||
| 		$expected = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||||
| 		<html xmlns="http://www.w3.org/1999/xhtml"> | ||||
| 		$expected = '<!DOCTYPE html> | ||||
| 		<html> | ||||
| 		<head> | ||||
| 		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||||
| 		<title>this should work</title> | ||||
|  | @ -601,7 +605,6 @@ class ControllerTest extends CakeTestCase { | |||
| 
 | ||||
| 		$Controller->set('title', 'someTitle'); | ||||
| 		$this->assertSame($Controller->viewVars['title'], 'someTitle'); | ||||
| 		$this->assertTrue(empty($Controller->pageTitle)); | ||||
| 
 | ||||
| 		$Controller->viewVars = array(); | ||||
| 		$expected = array('ModelName' => 'name', 'ModelName2' => 'name2'); | ||||
|  | @ -650,7 +653,7 @@ class ControllerTest extends CakeTestCase { | |||
| 		$expected = $Controller->ControllerComment->validationErrors; | ||||
| 
 | ||||
| 		$Controller->viewPath = 'Posts'; | ||||
| 		$result = $Controller->render('index'); | ||||
| 		$Controller->render('index'); | ||||
| 		$View = $Controller->View; | ||||
| 		$this->assertTrue(isset($View->validationErrors['ControllerComment'])); | ||||
| 		$this->assertEquals($expected, $View->validationErrors['ControllerComment']); | ||||
|  | @ -990,6 +993,7 @@ class ControllerTest extends CakeTestCase { | |||
| 		$Controller->constructClasses(); | ||||
| 
 | ||||
| 		$this->assertFalse(isset($Controller->Session)); | ||||
| 		$this->assertFalse(isset($Controller->Flash)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -1028,6 +1032,30 @@ class ControllerTest extends CakeTestCase { | |||
| 		$this->assertEquals('/', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that the referer is not absolute if it is '/'. | ||||
|  * | ||||
|  * This avoids the base path being applied twice on string urls. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRefererSlash() { | ||||
| 		$request = $this->getMock('CakeRequest', array('referer')); | ||||
| 		$request->base = '/base'; | ||||
| 		$request->expects($this->any()) | ||||
| 			->method('referer') | ||||
| 			->will($this->returnValue('/')); | ||||
| 		Router::setRequestInfo($request); | ||||
| 
 | ||||
| 		$controller = new Controller($request); | ||||
| 		$result = $controller->referer('/', true); | ||||
| 		$this->assertEquals('/', $result); | ||||
| 
 | ||||
| 		$controller = new Controller($request); | ||||
| 		$result = $controller->referer('/some/path', true); | ||||
| 		$this->assertEquals('/base/some/path', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testSetAction method | ||||
|  * | ||||
|  | @ -1075,10 +1103,11 @@ class ControllerTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testValidateErrorsOnArbitraryModels() { | ||||
| 		Configure::write('Config.language', 'eng'); | ||||
| 		$TestController = new TestController(); | ||||
| 
 | ||||
| 		$Post = new ControllerPost(); | ||||
| 		$Post->validate = array('title' => 'notEmpty'); | ||||
| 		$Post->validate = array('title' => 'notBlank'); | ||||
| 		$Post->set('title', ''); | ||||
| 		$result = $TestController->validateErrors($Post); | ||||
| 
 | ||||
|  | @ -1254,7 +1283,7 @@ class ControllerTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testPropertyBackwardsCompatibility() { | ||||
| 		$request = new CakeRequest('posts/index', null); | ||||
| 		$request = new CakeRequest('posts/index', false); | ||||
| 		$request->addParams(array('controller' => 'posts', 'action' => 'index')); | ||||
| 		$request->data = array('Post' => array('id' => 1)); | ||||
| 		$request->here = '/posts/index'; | ||||
|  | @ -1311,13 +1340,13 @@ class ControllerTest extends CakeTestCase { | |||
| 		$this->assertEquals(array(1, 2, 3), $results); | ||||
| 
 | ||||
| 		$Controller->passedArgs = array(); | ||||
| 		$Controller->paginate = array('limit' => '-1'); | ||||
| 		$this->assertEquals(array('limit' => '-1'), $Controller->paginate); | ||||
| 		$Controller->paginate = array('limit' => '1'); | ||||
| 		$this->assertEquals(array('limit' => '1'), $Controller->paginate); | ||||
| 		$Controller->paginate('ControllerPost'); | ||||
| 		$this->assertSame($Controller->params['paging']['ControllerPost']['page'], 1); | ||||
| 		$this->assertSame($Controller->params['paging']['ControllerPost']['pageCount'], 3); | ||||
| 		$this->assertSame($Controller->params['paging']['ControllerPost']['prevPage'], false); | ||||
| 		$this->assertSame($Controller->params['paging']['ControllerPost']['nextPage'], true); | ||||
| 		$this->assertFalse($Controller->params['paging']['ControllerPost']['prevPage']); | ||||
| 		$this->assertTrue($Controller->params['paging']['ControllerPost']['nextPage']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -1419,6 +1448,25 @@ class ControllerTest extends CakeTestCase { | |||
| 		$Controller->invokeAction($url); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test invoking controller methods. | ||||
|  * | ||||
|  * @expectedException PrivateActionException | ||||
|  * @expectedExceptionMessage Private Action TestController::Admin_add() is not directly accessible. | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testInvokeActionPrefixProtectionCasing() { | ||||
| 		Router::reload(); | ||||
| 		Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin')); | ||||
| 
 | ||||
| 		$url = new CakeRequest('test/Admin_add/'); | ||||
| 		$url->addParams(array('controller' => 'test_controller', 'action' => 'Admin_add')); | ||||
| 		$response = $this->getMock('CakeResponse'); | ||||
| 
 | ||||
| 		$Controller = new TestController($url, $response); | ||||
| 		$Controller->invokeAction($url); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test invoking controller methods. | ||||
|  * | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko