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,26 +2,24 @@ | |||
| /** | ||||
|  * CookieComponentTest 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('Component', 'Controller'); | ||||
| App::uses('Controller', 'Controller'); | ||||
| App::uses('CookieComponent', 'Controller/Component'); | ||||
| 
 | ||||
| 
 | ||||
| /** | ||||
|  * CookieComponentTestController class | ||||
|  * | ||||
|  | @ -72,6 +70,7 @@ class CookieComponentTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		$_COOKIE = array(); | ||||
| 		$this->Controller = new CookieComponentTestController(new CakeRequest(), new CakeResponse()); | ||||
| 		$this->Controller->constructClasses(); | ||||
|  | @ -93,6 +92,7 @@ class CookieComponentTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
| 		$this->Cookie->destroy(); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -153,6 +153,24 @@ class CookieComponentTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $data); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test read operations on corrupted cookie data. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testReadCorruptedCookieData() { | ||||
| 		$this->Cookie->type('aes'); | ||||
| 		$this->Cookie->key = sha1('some bad key'); | ||||
| 
 | ||||
| 		$data = $this->_implode(array('name' => 'jill', 'age' => 24)); | ||||
| 		// Corrupt the cookie data by slicing some bytes off.
 | ||||
| 		$_COOKIE['CakeTestCookie'] = array( | ||||
| 			'BadData' => substr(Security::encrypt($data, $this->Cookie->key), 0, -5) | ||||
| 		); | ||||
| 		$this->assertFalse($this->Cookie->check('BadData.name'), 'Key does not exist'); | ||||
| 		$this->assertNull($this->Cookie->read('BadData.name'), 'Key does not exist'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testReadPlainCookieData | ||||
|  * | ||||
|  | @ -169,6 +187,19 @@ class CookieComponentTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $data); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test read array keys from string data. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testReadNestedDataFromStrings() { | ||||
| 		$_COOKIE['CakeTestCookie'] = array( | ||||
| 			'User' => 'bad data' | ||||
| 		); | ||||
| 		$this->assertFalse($this->Cookie->check('User.name'), 'No key'); | ||||
| 		$this->assertNull($this->Cookie->read('User.name'), 'No key'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test read() after switching the cookie name. | ||||
|  * | ||||
|  | @ -201,6 +232,84 @@ class CookieComponentTest extends CakeTestCase { | |||
| 		$this->assertEquals('value', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test write() encrypted data with falsey value | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testWriteWithFalseyValue() { | ||||
| 		$this->skipIf(!extension_loaded('mcrypt'), 'No Mcrypt, skipping.'); | ||||
| 		$this->Cookie->type('aes'); | ||||
| 		$this->Cookie->key = 'qSI232qs*&sXOw!adre@34SAv!@*(XSL#$%)asGb$@11~_+!@#HKis~#^'; | ||||
| 
 | ||||
| 		$this->Cookie->write('Testing'); | ||||
| 		$result = $this->Cookie->read('Testing'); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
| 		$this->Cookie->write('Testing', ''); | ||||
| 		$result = $this->Cookie->read('Testing'); | ||||
| 		$this->assertEquals('', $result); | ||||
| 
 | ||||
| 		$this->Cookie->write('Testing', false); | ||||
| 		$result = $this->Cookie->read('Testing'); | ||||
| 		$this->assertFalse($result); | ||||
| 
 | ||||
| 		$this->Cookie->write('Testing', 1); | ||||
| 		$result = $this->Cookie->read('Testing'); | ||||
| 		$this->assertEquals(1, $result); | ||||
| 
 | ||||
| 		$this->Cookie->write('Testing', '0'); | ||||
| 		$result = $this->Cookie->read('Testing'); | ||||
| 		$this->assertSame('0', $result); | ||||
| 
 | ||||
| 		$this->Cookie->write('Testing', 0); | ||||
| 		$result = $this->Cookie->read('Testing'); | ||||
| 		$this->assertSame(0, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that two write() calls use the expiry. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testWriteMultipleShareExpiry() { | ||||
| 		$this->Cookie->write('key1', 'value1', false); | ||||
| 		$this->Cookie->write('key2', 'value2', false); | ||||
| 
 | ||||
| 		$name = $this->Cookie->name . '[key1]'; | ||||
| 		$result = $this->Controller->response->cookie($name); | ||||
| 		$this->assertWithinMargin(time() + 10, $result['expire'], 2, 'Expiry time is wrong'); | ||||
| 
 | ||||
| 		$name = $this->Cookie->name . '[key2]'; | ||||
| 		$result = $this->Controller->response->cookie($name); | ||||
| 		$this->assertWithinMargin(time() + 10, $result['expire'], 2, 'Expiry time is wrong'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test write with distant future cookies | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testWriteFarFuture() { | ||||
| 		$this->Cookie->write('Testing', 'value', false, '+90 years'); | ||||
| 		$future = new DateTime('now'); | ||||
| 		$future->modify('+90 years'); | ||||
| 
 | ||||
| 		$expected = array( | ||||
| 			'name' => $this->Cookie->name . '[Testing]', | ||||
| 			'value' => 'value', | ||||
| 			'path' => '/', | ||||
| 			'domain' => '', | ||||
| 			'secure' => false, | ||||
| 			'httpOnly' => false); | ||||
| 		$result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]'); | ||||
| 
 | ||||
| 		$this->assertEquals($future->format('U'), $result['expire'], '', 3); | ||||
| 		unset($result['expire']); | ||||
| 
 | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test write with httpOnly cookies | ||||
|  * | ||||
|  | @ -282,6 +391,44 @@ class CookieComponentTest extends CakeTestCase { | |||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that writing mixed arrays results in the correct data. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testWriteMixedArray() { | ||||
| 		$this->Cookie->encrypt = false; | ||||
| 		$this->Cookie->write('User', array('name' => 'mark'), false); | ||||
| 		$this->Cookie->write('User.email', 'mark@example.com', false); | ||||
| 		$expected = array( | ||||
| 			'name' => $this->Cookie->name . '[User]', | ||||
| 			'value' => '{"name":"mark","email":"mark@example.com"}', | ||||
| 			'path' => '/', | ||||
| 			'domain' => '', | ||||
| 			'secure' => false, | ||||
| 			'httpOnly' => false | ||||
| 		); | ||||
| 		$result = $this->Controller->response->cookie($this->Cookie->name . '[User]'); | ||||
| 		unset($result['expire']); | ||||
| 
 | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->Cookie->write('User.email', 'mark@example.com', false); | ||||
| 		$this->Cookie->write('User', array('name' => 'mark'), false); | ||||
| 		$expected = array( | ||||
| 			'name' => $this->Cookie->name . '[User]', | ||||
| 			'value' => '{"name":"mark"}', | ||||
| 			'path' => '/', | ||||
| 			'domain' => '', | ||||
| 			'secure' => false, | ||||
| 			'httpOnly' => false | ||||
| 		); | ||||
| 		$result = $this->Controller->response->cookie($this->Cookie->name . '[User]'); | ||||
| 		unset($result['expire']); | ||||
| 
 | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testReadingCookieValue | ||||
|  * | ||||
|  | @ -336,6 +483,25 @@ class CookieComponentTest extends CakeTestCase { | |||
| 		$this->assertNull($data); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test delete() on corrupted/truncated cookie data. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDeleteCorruptedCookieData() { | ||||
| 		$this->Cookie->type('aes'); | ||||
| 		$this->Cookie->key = sha1('some bad key'); | ||||
| 
 | ||||
| 		$data = $this->_implode(array('name' => 'jill', 'age' => 24)); | ||||
| 		// Corrupt the cookie data by slicing some bytes off.
 | ||||
| 		$_COOKIE['CakeTestCookie'] = array( | ||||
| 			'BadData' => substr(Security::encrypt($data, $this->Cookie->key), 0, -5) | ||||
| 		); | ||||
| 
 | ||||
| 		$this->assertNull($this->Cookie->delete('BadData.name')); | ||||
| 		$this->assertNull($this->Cookie->read('BadData.name')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testReadingCookieArray | ||||
|  * | ||||
|  | @ -513,17 +679,21 @@ class CookieComponentTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Test reading empty values. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testReadEmpty() { | ||||
| 		$_COOKIE['CakeTestCookie'] = array( | ||||
| 			'JSON' => '{"name":"value"}', | ||||
| 			'Empty' => '', | ||||
| 			'String' => '{"somewhat:"broken"}' | ||||
| 			'String' => '{"somewhat:"broken"}', | ||||
| 			'Array' => '{}' | ||||
| 		); | ||||
| 		$this->assertEquals(array('name' => 'value'), $this->Cookie->read('JSON')); | ||||
| 		$this->assertEquals('value', $this->Cookie->read('JSON.name')); | ||||
| 		$this->assertEquals('', $this->Cookie->read('Empty')); | ||||
| 		$this->assertEquals('{"somewhat:"broken"}', $this->Cookie->read('String')); | ||||
| 		$this->assertEquals(array(), $this->Cookie->read('Array')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -538,6 +708,60 @@ class CookieComponentTest extends CakeTestCase { | |||
| 		$this->assertNull($this->Cookie->read('value')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheck method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheck() { | ||||
| 		$this->Cookie->write('CookieComponentTestCase', 'value'); | ||||
| 		$this->assertTrue($this->Cookie->check('CookieComponentTestCase')); | ||||
| 
 | ||||
| 		$this->assertFalse($this->Cookie->check('NotExistingCookieComponentTestCase')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheckingSavedEmpty method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheckingSavedEmpty() { | ||||
| 		$this->Cookie->write('CookieComponentTestCase', 0); | ||||
| 		$this->assertTrue($this->Cookie->check('CookieComponentTestCase')); | ||||
| 
 | ||||
| 		$this->Cookie->write('CookieComponentTestCase', '0'); | ||||
| 		$this->assertTrue($this->Cookie->check('CookieComponentTestCase')); | ||||
| 
 | ||||
| 		$this->Cookie->write('CookieComponentTestCase', false); | ||||
| 		$this->assertTrue($this->Cookie->check('CookieComponentTestCase')); | ||||
| 
 | ||||
| 		$this->Cookie->write('CookieComponentTestCase', null); | ||||
| 		$this->assertFalse($this->Cookie->check('CookieComponentTestCase')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheckKeyWithSpaces method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheckKeyWithSpaces() { | ||||
| 		$this->Cookie->write('CookieComponent Test', "test"); | ||||
| 		$this->assertTrue($this->Cookie->check('CookieComponent Test')); | ||||
| 		$this->Cookie->delete('CookieComponent Test'); | ||||
| 
 | ||||
| 		$this->Cookie->write('CookieComponent Test.Test Case', "test"); | ||||
| 		$this->assertTrue($this->Cookie->check('CookieComponent Test.Test Case')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheckEmpty | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheckEmpty() { | ||||
| 		$this->assertFalse($this->Cookie->check()); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that deleting a top level keys kills the child elements too. | ||||
|  * | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko