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
				
			
		|  | @ -4,19 +4,18 @@ | |||
|  * | ||||
|  * Test Case for ControllerTestCase class | ||||
|  * | ||||
|  * PHP version 5 | ||||
|  * | ||||
|  * CakePHP : Rapid Development Framework (http://cakephp.org) | ||||
|  * Copyright 2005-2012, Cake Software Foundation, Inc. | ||||
|  * 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. | ||||
|  * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) | ||||
|  * @link          http://cakephp.org CakePHP Project | ||||
|  * @package       Cake.Test.Case.TestSuite | ||||
|  * @since         CakePHP 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('Controller', 'Controller'); | ||||
|  | @ -26,11 +25,6 @@ App::uses('CakeHtmlReporter', 'TestSuite/Reporter'); | |||
| 
 | ||||
| require_once dirname(dirname(__FILE__)) . DS . 'Model' . DS . 'models.php'; | ||||
| 
 | ||||
| /** | ||||
|  * AppController class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.TestSuite | ||||
|  */ | ||||
| if (!class_exists('AppController', false)) { | ||||
| /** | ||||
|  * AppController class | ||||
|  | @ -43,7 +37,6 @@ if (!class_exists('AppController', false)) { | |||
| 	 * helpers property | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 * @access public | ||||
| 	 */ | ||||
| 		public $helpers = array('Html'); | ||||
| 
 | ||||
|  | @ -51,7 +44,6 @@ if (!class_exists('AppController', false)) { | |||
| 	 * uses property | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 * @access public | ||||
| 	 */ | ||||
| 		public $uses = array('ControllerPost'); | ||||
| 
 | ||||
|  | @ -59,7 +51,6 @@ if (!class_exists('AppController', false)) { | |||
| 	 * components property | ||||
| 	 * | ||||
| 	 * @var array | ||||
| 	 * @access public | ||||
| 	 */ | ||||
| 		public $components = array('Cookie'); | ||||
| 
 | ||||
|  | @ -72,6 +63,12 @@ if (!class_exists('AppController', false)) { | |||
|  * PostsController class | ||||
|  */ | ||||
| if (!class_exists('PostsController')) { | ||||
| 
 | ||||
| /** | ||||
|  * PostsController | ||||
|  * | ||||
|  * @package       Cake.Test.Case.TestSuite | ||||
|  */ | ||||
| 	class PostsController extends AppController { | ||||
| 
 | ||||
| 	/** | ||||
|  | @ -89,6 +86,8 @@ if (!class_exists('PostsController')) { | |||
| 
 | ||||
| /** | ||||
|  * ControllerTestCaseTest controller | ||||
|  * | ||||
|  * @package       Cake.Test.Case.TestSuite | ||||
|  */ | ||||
| class ControllerTestCaseTestController extends AppController { | ||||
| 
 | ||||
|  | @ -146,6 +145,8 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Test that ControllerTestCase::generate() creates mock objects correctly | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGenerate() { | ||||
| 		if (defined('APP_CONTROLLER_EXISTS')) { | ||||
|  | @ -209,8 +210,34 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 		$this->assertEquals('written!', $Posts->Auth->Session->write('something')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testGenerateWithComponentConfig | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGenerateWithComponentConfig() { | ||||
| 		$Tests = $this->Case->generate('TestConfigs', array( | ||||
| 		)); | ||||
| 
 | ||||
| 		$expected = array('some' => 'config'); | ||||
| 		$settings = array_intersect_key($Tests->RequestHandler->settings, array('some' => 'foo')); | ||||
| 		$this->assertSame($expected, $settings, 'A mocked component should have the same config as an unmocked component'); | ||||
| 
 | ||||
| 		$Tests = $this->Case->generate('TestConfigs', array( | ||||
| 			'components' => array( | ||||
| 				'RequestHandler' => array('isPut') | ||||
| 			) | ||||
| 		)); | ||||
| 
 | ||||
| 		$expected = array('some' => 'config'); | ||||
| 		$settings = array_intersect_key($Tests->RequestHandler->settings, array('some' => 'foo')); | ||||
| 		$this->assertSame($expected, $settings, 'A mocked component should have the same config as an unmocked component'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests ControllerTestCase::generate() using classes from plugins | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testGenerateWithPlugin() { | ||||
| 		$Tests = $this->Case->generate('TestPlugin.Tests', array( | ||||
|  | @ -245,9 +272,11 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Tests testAction | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testTestAction() { | ||||
| 		$Controller = $this->Case->generate('TestsApps'); | ||||
| 		$this->Case->generate('TestsApps'); | ||||
| 		$this->Case->testAction('/tests_apps/index'); | ||||
| 		$this->assertInternalType('array', $this->Case->controller->viewVars); | ||||
| 
 | ||||
|  | @ -268,6 +297,30 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 			'Location' => 'http://cakephp.org' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $results); | ||||
| 		$this->assertSame(302, $Controller->response->statusCode()); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test array URLs with testAction() | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testTestActionArrayUrls() { | ||||
| 		$this->Case->generate('TestsApps'); | ||||
| 		$this->Case->testAction(array('controller' => 'tests_apps', 'action' => 'index')); | ||||
| 		$this->assertInternalType('array', $this->Case->controller->viewVars); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that file responses don't trigger errors. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testActionWithFile() { | ||||
| 		$Controller = $this->Case->generate('TestsApps'); | ||||
| 		$this->Case->testAction('/tests_apps/file'); | ||||
| 		$this->assertArrayHasKey('Content-Disposition', $Controller->response->header()); | ||||
| 		$this->assertArrayHasKey('Content-Length', $Controller->response->header()); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -276,7 +329,7 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testTestActionWithPlugin() { | ||||
| 		$Controller = $this->Case->generate('TestPlugin.Tests'); | ||||
| 		$this->Case->generate('TestPlugin.Tests'); | ||||
| 		$this->Case->testAction('/test_plugin/tests/index'); | ||||
| 		$this->assertEquals('It is a variable', $this->Case->controller->viewVars['test_value']); | ||||
| 	} | ||||
|  | @ -306,17 +359,20 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
|  * Tests not using loaded routes during tests | ||||
|  * | ||||
|  * @expectedException MissingActionException | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSkipRoutes() { | ||||
| 		Router::connect('/:controller/:action/*'); | ||||
| 		include CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'routes.php'; | ||||
| 
 | ||||
| 		$this->Case->loadRoutes = false; | ||||
| 		$result = $this->Case->testAction('/tests_apps/missing_action.json', array('return' => 'view')); | ||||
| 		$this->Case->testAction('/tests_apps/missing_action.json', array('return' => 'view')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests backwards compatibility with setting the return type | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testBCSetReturn() { | ||||
| 		$this->Case->autoMock = true; | ||||
|  | @ -346,6 +402,8 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Tests sending POST data to testAction | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testTestActionPostData() { | ||||
| 		$this->Case->autoMock = true; | ||||
|  | @ -388,11 +446,13 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Tests sending GET data to testAction | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testTestActionGetData() { | ||||
| 		$this->Case->autoMock = true; | ||||
| 
 | ||||
| 		$result = $this->Case->testAction('/tests_apps_posts/url_var', array( | ||||
| 		$this->Case->testAction('/tests_apps_posts/url_var', array( | ||||
| 			'method' => 'get', | ||||
| 			'data' => array( | ||||
| 				'some' => 'var', | ||||
|  | @ -414,7 +474,7 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 		)); | ||||
| 		$this->assertEquals(array('gogo', 'val2'), $result['params']['pass']); | ||||
| 
 | ||||
| 		$result = $this->Case->testAction('/tests_apps_posts/url_var', array( | ||||
| 		$this->Case->testAction('/tests_apps_posts/url_var', array( | ||||
| 			'return' => 'vars', | ||||
| 			'method' => 'get', | ||||
| 			'data' => array( | ||||
|  | @ -444,6 +504,8 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Tests autoMock ability | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoMock() { | ||||
| 		$this->Case->autoMock = true; | ||||
|  | @ -457,6 +519,8 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Test using testAction and not mocking | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testNoMocking() { | ||||
| 		$result = $this->Case->testAction('/tests_apps/some_method'); | ||||
|  | @ -520,7 +584,7 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testTestActionWithMultipleRedirect() { | ||||
| 		$Controller = $this->Case->generate('TestsApps'); | ||||
| 		$this->Case->generate('TestsApps'); | ||||
| 
 | ||||
| 		$options = array('method' => 'get'); | ||||
| 		$this->Case->testAction('/tests_apps/redirect_to', $options); | ||||
|  | @ -532,7 +596,6 @@ class ControllerTestCaseTest extends CakeTestCase { | |||
|  * will always have a fresh reference to those object available | ||||
|  * | ||||
|  * @return void | ||||
|  * @see http://cakephp.lighthouseapp.com/projects/42648-cakephp/tickets/2705-requesthandler-weird-behavior | ||||
|  */ | ||||
| 	public function testComponentsSameRequestAndResponse() { | ||||
| 		$this->Case->generate('TestsApps'); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko