mirror of
				https://github.com/brmlab/brmsklad.git
				synced 2025-10-31 08:13: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
				
			
		|  | @ -2,25 +2,26 @@ | |||
| /** | ||||
|  * RequestHandlerComponentTest file | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * 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://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests | ||||
|  * @package       Cake.Test.Case.Controller.Component | ||||
|  * @since         CakePHP(tm) v 1.2.0.5435 | ||||
|  * @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('RequestHandlerComponent', 'Controller/Component'); | ||||
| App::uses('CakeRequest', 'Network'); | ||||
| App::uses('CakeResponse', 'Network'); | ||||
| App::uses('Router', 'Routing'); | ||||
| App::uses('JsonView', 'View'); | ||||
| 
 | ||||
| /** | ||||
|  * RequestHandlerTestController class | ||||
|  | @ -32,7 +33,7 @@ class RequestHandlerTestController extends Controller { | |||
| /** | ||||
|  * uses property | ||||
|  * | ||||
|  * @var mixed null | ||||
|  * @var mixed | ||||
|  */ | ||||
| 	public $uses = null; | ||||
| 
 | ||||
|  | @ -70,6 +71,14 @@ class RequestHandlerTestController extends Controller { | |||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * CustomJsonView class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Controller.Component | ||||
|  */ | ||||
| class CustomJsonView extends JsonView { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * RequestHandlerComponentTest class | ||||
|  | @ -137,12 +146,14 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testConstructorSettings() { | ||||
| 		$settings = array( | ||||
| 			'ajaxLayout' => 'test_ajax' | ||||
| 			'ajaxLayout' => 'test_ajax', | ||||
| 			'viewClassMap' => array('json' => 'MyPlugin.MyJson') | ||||
| 		); | ||||
| 		$Collection = new ComponentCollection(); | ||||
| 		$Collection->init($this->Controller); | ||||
| 		$RequestHandler = new RequestHandlerComponent($Collection, $settings); | ||||
| 		$this->assertEquals('test_ajax', $RequestHandler->ajaxLayout); | ||||
| 		$this->assertEquals(array('json' => 'MyPlugin.MyJson'), $RequestHandler->settings['viewClassMap']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -178,7 +189,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testInitializeContentTypeWithjQueryAccept() { | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01'; | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'application/json, application/javascript, */*; q=0.01'; | ||||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 		Router::parseExtensions('json'); | ||||
| 
 | ||||
|  | @ -186,6 +197,20 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 		$this->assertEquals('json', $this->RequestHandler->ext); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that RequestHandler does not set extension to csv for text/plain mimetype | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testInitializeContentTypeWithjQueryTextPlainAccept() { | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'text/plain, */*; q=0.01'; | ||||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 		Router::parseExtensions('csv'); | ||||
| 
 | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that RequestHandler sets $this->ext when jQuery sends its wonky-ish headers | ||||
|  * and the application is configured to handle multiple extensions | ||||
|  | @ -193,7 +218,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testInitializeContentTypeWithjQueryAcceptAndMultiplesExtensions() { | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01'; | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'application/json, application/javascript, */*; q=0.01'; | ||||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 		Router::parseExtensions('rss', 'json'); | ||||
| 
 | ||||
|  | @ -216,17 +241,40 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that ext is not set with multiple accepted content types. | ||||
|  * Test that ext is set to the first listed extension with multiple accepted | ||||
|  * content types. | ||||
|  * Having multiple types accepted with same weight, means the client lets the | ||||
|  * server choose the returned content type. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testInitializeNoContentTypeWithMultipleAcceptedTypes() { | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, application/xml, */*; q=0.01'; | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'application/json, application/javascript, application/xml, */*; q=0.01'; | ||||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 		Router::parseExtensions('xml', 'json'); | ||||
| 
 | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$this->assertEquals('xml', $this->RequestHandler->ext); | ||||
| 
 | ||||
| 		$this->RequestHandler->ext = null; | ||||
| 		Router::setExtensions(array('json', 'xml'), false); | ||||
| 
 | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$this->assertEquals('json', $this->RequestHandler->ext); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that ext is set to type with highest weight | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testInitializeContentTypeWithMultipleAcceptedTypes() { | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'text/csv;q=1.0, application/json;q=0.8, application/xml;q=0.7'; | ||||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 		Router::parseExtensions('xml', 'json'); | ||||
| 
 | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$this->assertEquals('json', $this->RequestHandler->ext); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -243,6 +291,19 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that the headers sent by firefox are not treated as XML requests. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testInititalizeFirefoxHeaderNotXml() { | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8'; | ||||
| 		Router::parseExtensions('xml', 'json'); | ||||
| 
 | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$this->assertNull($this->RequestHandler->ext); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that a type mismatch doesn't incorrectly set the ext | ||||
|  * | ||||
|  | @ -264,6 +325,33 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 		call_user_func_array(array('Router', 'parseExtensions'), $extensions); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testViewClassMap method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testViewClassMap() { | ||||
| 		$this->RequestHandler->settings = array('viewClassMap' => array('json' => 'CustomJson')); | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$result = $this->RequestHandler->viewClassMap(); | ||||
| 		$expected = array( | ||||
| 			'json' => 'CustomJson', | ||||
| 			'xml' => 'Xml' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->RequestHandler->viewClassMap('xls', 'Excel.Excel'); | ||||
| 		$expected = array( | ||||
| 			'json' => 'CustomJson', | ||||
| 			'xml' => 'Xml', | ||||
| 			'xls' => 'Excel.Excel' | ||||
| 		); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->RequestHandler->renderAs($this->Controller, 'json'); | ||||
| 		$this->assertEquals('CustomJson', $this->Controller->viewClass); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testDisabling method | ||||
|  * | ||||
|  | @ -278,19 +366,6 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 		$this->assertEquals(true, $this->Controller->params['isAjax']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testAutoResponseType method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAutoResponseType() { | ||||
| 		$this->Controller->ext = '.thtml'; | ||||
| 		$this->Controller->request->params['ext'] = 'rss'; | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$this->RequestHandler->startup($this->Controller); | ||||
| 		$this->assertEquals('.ctp', $this->Controller->ext); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testAutoAjaxLayout method | ||||
|  * | ||||
|  | @ -372,6 +447,23 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 		$this->assertNull($this->RequestHandler->beforeRedirect($this->Controller, '/')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that redirects with ajax and no URL don't do anything. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testAjaxRedirectWithNoUrl() { | ||||
| 		$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; | ||||
| 		$this->Controller->response = $this->getMock('CakeResponse'); | ||||
| 
 | ||||
| 		$this->Controller->response->expects($this->never()) | ||||
| 			->method('body'); | ||||
| 
 | ||||
| 		$this->RequestHandler->initialize($this->Controller); | ||||
| 		$this->RequestHandler->startup($this->Controller); | ||||
| 		$this->assertNull($this->RequestHandler->beforeRedirect($this->Controller, null)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testRenderAs method | ||||
|  * | ||||
|  | @ -523,6 +615,22 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 		$result = $this->RequestHandler->requestedWith(array('rss', 'atom')); | ||||
| 		$this->assertFalse($result); | ||||
| 
 | ||||
| 		$_SERVER['REQUEST_METHOD'] = 'DELETE'; | ||||
| 		$this->assertEquals('json', $this->RequestHandler->requestedWith()); | ||||
| 
 | ||||
| 		$_SERVER['REQUEST_METHOD'] = 'PATCH'; | ||||
| 		$this->assertEquals('json', $this->RequestHandler->requestedWith()); | ||||
| 
 | ||||
| 		$_SERVER['REQUEST_METHOD'] = 'POST'; | ||||
| 		unset($_SERVER['CONTENT_TYPE']); | ||||
| 		$_SERVER['HTTP_CONTENT_TYPE'] = 'application/json'; | ||||
| 
 | ||||
| 		$result = $this->RequestHandler->requestedWith(array('json', 'xml')); | ||||
| 		$this->assertEquals('json', $result); | ||||
| 
 | ||||
| 		$result = $this->RequestHandler->requestedWith(array('rss', 'atom')); | ||||
| 		$this->assertFalse($result); | ||||
| 
 | ||||
| 		$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; | ||||
| 		$this->assertTrue($this->RequestHandler->isXml()); | ||||
| 		$this->assertFalse($this->RequestHandler->isAtom()); | ||||
|  | @ -630,7 +738,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 		$this->assertEquals('text/vnd.wap.wml', $result); | ||||
| 
 | ||||
| 		$result = $this->RequestHandler->mapAlias(array('xml', 'js', 'json')); | ||||
| 		$expected = array('application/xml', 'text/javascript', 'application/json'); | ||||
| 		$expected = array('application/xml', 'application/javascript', 'application/json'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -762,10 +870,9 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * test that the beforeRedirect callback properly converts | ||||
|  * array urls into their correct string ones, and adds base => false so | ||||
|  * the correct urls are generated. | ||||
|  * array URLs into their correct string ones, and adds base => false so | ||||
|  * the correct URLs are generated. | ||||
|  * | ||||
|  * @link http://cakephp.lighthouseapp.com/projects/42648-cakephp-1x/tickets/276 | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testBeforeRedirectCallbackWithArrayUrl() { | ||||
|  | @ -800,7 +907,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 
 | ||||
| 		$controller = $this->getMock('Controller', array('header')); | ||||
| 		$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); | ||||
| 		$RequestHandler->response = $this->getMock('CakeResponse', array('_sendHeader','statusCode')); | ||||
| 		$RequestHandler->response = $this->getMock('CakeResponse', array('_sendHeader', 'statusCode')); | ||||
| 		$RequestHandler->request = $this->getMock('CakeRequest'); | ||||
| 		$RequestHandler->request->expects($this->once())->method('is') | ||||
| 			->with('ajax') | ||||
|  | @ -810,7 +917,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
| 
 | ||||
| 		ob_start(); | ||||
| 		$RequestHandler->beforeRedirect($controller, 'request_handler_test/param_method/first/second', 403); | ||||
| 		$result = ob_get_clean(); | ||||
| 		ob_get_clean(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -825,7 +932,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
|  * Test checkNotModified method | ||||
|  * | ||||
|  * @return void | ||||
|  **/ | ||||
|  */ | ||||
| 	public function testCheckNotModifiedByEtagStar() { | ||||
| 		$_SERVER['HTTP_IF_NONE_MATCH'] = '*'; | ||||
| 		$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); | ||||
|  | @ -839,7 +946,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
|  * Test checkNotModified method | ||||
|  * | ||||
|  * @return void | ||||
|  **/ | ||||
|  */ | ||||
| 	public function testCheckNotModifiedByEtagExact() { | ||||
| 		$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; | ||||
| 		$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); | ||||
|  | @ -853,7 +960,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
|  * Test checkNotModified method | ||||
|  * | ||||
|  * @return void | ||||
|  **/ | ||||
|  */ | ||||
| 	public function testCheckNotModifiedByEtagAndTime() { | ||||
| 		$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; | ||||
| 		$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; | ||||
|  | @ -869,7 +976,7 @@ class RequestHandlerComponentTest extends CakeTestCase { | |||
|  * Test checkNotModified method | ||||
|  * | ||||
|  * @return void | ||||
|  **/ | ||||
|  */ | ||||
| 	public function testCheckNotModifiedNoInfo() { | ||||
| 		$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); | ||||
| 		$RequestHandler->response = $this->getMock('CakeResponse', array('notModified')); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko