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
				
			
		|  | @ -1,20 +1,22 @@ | |||
| <?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 | ||||
|  * @since         CakePHP(tm) v 1.2.0.5432 | ||||
|  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php) | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('Debugger', 'Utility'); | ||||
| 
 | ||||
| /** | ||||
|  * DebugggerTestCaseDebuggger class | ||||
|  * DebuggerTestCaseDebugger class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Utility | ||||
|  */ | ||||
|  | @ -65,7 +67,7 @@ class DebuggerTest extends CakeTestCase { | |||
| 	public function testDocRef() { | ||||
| 		ini_set('docref_root', ''); | ||||
| 		$this->assertEquals(ini_get('docref_root'), ''); | ||||
| 		$debugger = new Debugger(); | ||||
| 		new Debugger(); | ||||
| 		$this->assertEquals(ini_get('docref_root'), 'http://php.net/'); | ||||
| 	} | ||||
| 
 | ||||
|  | @ -87,7 +89,7 @@ class DebuggerTest extends CakeTestCase { | |||
| 		$pattern = '/<code>.*?<span style\="color\: \#\d+">.*?<\?php/'; | ||||
| 		$this->assertRegExp($pattern, $result[0]); | ||||
| 
 | ||||
| 		$result = Debugger::excerpt(__FILE__, 10, 2); | ||||
| 		$result = Debugger::excerpt(__FILE__, 11, 2); | ||||
| 		$this->assertEquals(5, count($result)); | ||||
| 
 | ||||
| 		$pattern = '/<span style\="color\: \#\d{6}">\*<\/span>/'; | ||||
|  | @ -141,8 +143,8 @@ class DebuggerTest extends CakeTestCase { | |||
| 			'a' => array( | ||||
| 				'href' => "javascript:void(0);", | ||||
| 				'onclick' => "preg:/document\.getElementById\('cakeErr[a-z0-9]+\-trace'\)\.style\.display = " . | ||||
| 					 "\(document\.getElementById\('cakeErr[a-z0-9]+\-trace'\)\.style\.display == 'none'" . | ||||
| 					 " \? '' \: 'none'\);/" | ||||
| 					"\(document\.getElementById\('cakeErr[a-z0-9]+\-trace'\)\.style\.display == 'none'" . | ||||
| 					" \? '' \: 'none'\);/" | ||||
| 			), | ||||
| 			'b' => array(), 'Notice', '/b', ' (8)', | ||||
| 		)); | ||||
|  | @ -153,6 +155,24 @@ class DebuggerTest extends CakeTestCase { | |||
| 		$this->assertContains('$wrong = ''', $result[3], 'Context should be HTML escaped.'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test encodes error messages | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testOutputEncodeDescription() { | ||||
| 		set_error_handler('Debugger::showError'); | ||||
| 		$this->_restoreError = true; | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		$a = array(); | ||||
| 		$b = $a['<script>alert(1)</script>']; | ||||
| 		$result = ob_get_clean(); | ||||
| 
 | ||||
| 		$this->assertNotContains('<script>alert(1)', $result); | ||||
| 		$this->assertContains('<script>alert(1)', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests that changes in output formats using Debugger::output() change the templates used. | ||||
|  * | ||||
|  | @ -171,7 +191,7 @@ class DebuggerTest extends CakeTestCase { | |||
| 
 | ||||
| 		Debugger::output('xml', array( | ||||
| 			'error' => '<error><code>{:code}</code><file>{:file}</file><line>{:line}</line>' . | ||||
| 				 '{:description}</error>', | ||||
| 				'{:description}</error>', | ||||
| 			'context' => "<context>{:context}</context>", | ||||
| 			'trace' => "<stack>{:trace}</stack>", | ||||
| 		)); | ||||
|  | @ -185,7 +205,7 @@ class DebuggerTest extends CakeTestCase { | |||
| 			'error' => array(), | ||||
| 			'code' => array(), '8', '/code', | ||||
| 			'file' => array(), 'preg:/[^<]+/', '/file', | ||||
| 			'line' => array(), '' . (intval(__LINE__) - 7), '/line', | ||||
| 			'line' => array(), '' . ((int)__LINE__ - 7), '/line', | ||||
| 			'preg:/Undefined variable:\s+foo/', | ||||
| 			'/error' | ||||
| 		); | ||||
|  | @ -223,7 +243,7 @@ class DebuggerTest extends CakeTestCase { | |||
| 
 | ||||
| 		Debugger::addFormat('js', array( | ||||
| 			'traceLine' => '{:reference} - <a href="txmt://open?url=file://{:file}' . | ||||
| 							 '&line={:line}">{:path}</a>, line {:line}' | ||||
| 				'&line={:line}">{:path}</a>, line {:line}' | ||||
| 		)); | ||||
| 		Debugger::outputAs('js'); | ||||
| 
 | ||||
|  | @ -232,7 +252,7 @@ class DebuggerTest extends CakeTestCase { | |||
| 
 | ||||
| 		Debugger::addFormat('xml', array( | ||||
| 			'error' => '<error><code>{:code}</code><file>{:file}</file><line>{:line}</line>' . | ||||
| 						 '{:description}</error>', | ||||
| 				'{:description}</error>', | ||||
| 		)); | ||||
| 		Debugger::outputAs('xml'); | ||||
| 
 | ||||
|  | @ -244,7 +264,7 @@ class DebuggerTest extends CakeTestCase { | |||
| 			'<error', | ||||
| 			'<code', '8', '/code', | ||||
| 			'<file', 'preg:/[^<]+/', '/file', | ||||
| 			'<line', '' . (intval(__LINE__) - 7), '/line', | ||||
| 			'<line', '' . ((int)__LINE__ - 7), '/line', | ||||
| 			'preg:/Undefined variable:\s+foo/', | ||||
| 			'/error' | ||||
| 		); | ||||
|  | @ -272,6 +292,8 @@ class DebuggerTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Test method for testing addFormat with callbacks. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function customFormat($error, $strings) { | ||||
| 		return $error['error'] . ': I eated an error ' . $error['file']; | ||||
|  | @ -331,10 +353,47 @@ object(View) { | |||
| 	request => object(CakeRequest) {} | ||||
| 	response => object(CakeResponse) {} | ||||
| 	elementCache => 'default' | ||||
| 	elementCacheSettings => array() | ||||
| 	Html => object(HtmlHelper) {} | ||||
| 	Form => object(FormHelper) {} | ||||
| 	int => (int) 2 | ||||
| 	float => (float) 1.333 | ||||
| 
 | ||||
| TEXT; | ||||
| 		if (version_compare(PHP_VERSION, '5.3.0') >= 0) { | ||||
| 			$expected .= <<<TEXT | ||||
| 	[protected] _passedVars => array( | ||||
| 		(int) 0 => 'viewVars', | ||||
| 		(int) 1 => 'autoLayout', | ||||
| 		(int) 2 => 'ext', | ||||
| 		(int) 3 => 'helpers', | ||||
| 		(int) 4 => 'view', | ||||
| 		(int) 5 => 'layout', | ||||
| 		(int) 6 => 'name', | ||||
| 		(int) 7 => 'theme', | ||||
| 		(int) 8 => 'layoutPath', | ||||
| 		(int) 9 => 'viewPath', | ||||
| 		(int) 10 => 'request', | ||||
| 		(int) 11 => 'plugin', | ||||
| 		(int) 12 => 'passedArgs', | ||||
| 		(int) 13 => 'cacheAction' | ||||
| 	) | ||||
| 	[protected] _scripts => array() | ||||
| 	[protected] _paths => array() | ||||
| 	[protected] _pathsForPlugin => array() | ||||
| 	[protected] _parents => array() | ||||
| 	[protected] _current => null | ||||
| 	[protected] _currentType => '' | ||||
| 	[protected] _stack => array() | ||||
| 	[protected] _eventManager => object(CakeEventManager) {} | ||||
| 	[protected] _eventManagerConfigured => false | ||||
| 
 | ||||
| TEXT; | ||||
| 		} | ||||
| 		$expected .= <<<TEXT | ||||
| } | ||||
| TEXT; | ||||
| 
 | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 
 | ||||
| 		$data = array( | ||||
|  | @ -362,6 +421,44 @@ array( | |||
| 		[maximum depth reached] | ||||
| 	) | ||||
| ) | ||||
| TEXT; | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 
 | ||||
| 		$data = false; | ||||
| 		$result = Debugger::exportVar($data); | ||||
| 		$expected = <<<TEXT | ||||
| false | ||||
| TEXT; | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 
 | ||||
| 		$file = fopen('php://output', 'w'); | ||||
| 		fclose($file); | ||||
| 		$result = Debugger::exportVar($file); | ||||
| 		$this->assertTextEquals('unknown', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test exporting various kinds of false. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExportVarZero() { | ||||
| 		$data = array( | ||||
| 			'nothing' => '', | ||||
| 			'null' => null, | ||||
| 			'false' => false, | ||||
| 			'szero' => '0', | ||||
| 			'zero' => 0 | ||||
| 		); | ||||
| 		$result = Debugger::exportVar($data); | ||||
| 		$expected = <<<TEXT | ||||
| array( | ||||
| 	'nothing' => '', | ||||
| 	'null' => null, | ||||
| 	'false' => false, | ||||
| 	'szero' => '0', | ||||
| 	'zero' => (int) 0 | ||||
| ) | ||||
| TEXT; | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 	} | ||||
|  | @ -375,21 +472,44 @@ TEXT; | |||
| 		if (file_exists(LOGS . 'debug.log')) { | ||||
| 			unlink(LOGS . 'debug.log'); | ||||
| 		} | ||||
| 		CakeLog::config('file', array('engine' => 'File', 'path' => TMP . 'logs' . DS)); | ||||
| 
 | ||||
| 		Debugger::log('cool'); | ||||
| 		$result = file_get_contents(LOGS . 'debug.log'); | ||||
| 		$this->assertRegExp('/DebuggerTest\:\:testLog/i', $result); | ||||
| 		$this->assertRegExp("/'cool'/", $result); | ||||
| 		$this->assertContains('DebuggerTest::testLog', $result); | ||||
| 		$this->assertContains("'cool'", $result); | ||||
| 
 | ||||
| 		unlink(LOGS . 'debug.log'); | ||||
| 
 | ||||
| 		Debugger::log(array('whatever', 'here')); | ||||
| 		$result = file_get_contents(LOGS . 'debug.log'); | ||||
| 		$this->assertRegExp('/DebuggerTest\:\:testLog/i', $result); | ||||
| 		$this->assertRegExp('/\[main\]/', $result); | ||||
| 		$this->assertRegExp('/array/', $result); | ||||
| 		$this->assertRegExp("/'whatever',/", $result); | ||||
| 		$this->assertRegExp("/'here'/", $result); | ||||
| 		$this->assertContains('DebuggerTest::testLog', $result); | ||||
| 		$this->assertContains('[main]', $result); | ||||
| 		$this->assertContains('array', $result); | ||||
| 		$this->assertContains("'whatever',", $result); | ||||
| 		$this->assertContains("'here'", $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test log() depth | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testLogDepth() { | ||||
| 		if (file_exists(LOGS . 'debug.log')) { | ||||
| 			unlink(LOGS . 'debug.log'); | ||||
| 		} | ||||
| 		CakeLog::config('file', array('engine' => 'File', 'path' => TMP . 'logs' . DS)); | ||||
| 
 | ||||
| 		$val = array( | ||||
| 			'test' => array('key' => 'val') | ||||
| 		); | ||||
| 		Debugger::log($val, LOG_DEBUG, 0); | ||||
| 		$result = file_get_contents(LOGS . 'debug.log'); | ||||
| 		$this->assertContains('DebuggerTest::testLog', $result); | ||||
| 		$this->assertNotContains("/'val'/", $result); | ||||
| 
 | ||||
| 		unlink(LOGS . 'debug.log'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -413,8 +533,11 @@ TEXT; | |||
| 		ob_start(); | ||||
| 		Debugger::dump($var); | ||||
| 		$result = ob_get_clean(); | ||||
| 
 | ||||
| 		$open = PHP_SAPI === 'cli' ? "\n" : '<pre>'; | ||||
| 		$close = PHP_SAPI === 'cli' ? "\n" : '</pre>'; | ||||
| 		$expected = <<<TEXT | ||||
| <pre>array( | ||||
| {$open}array( | ||||
| 	'People' => array( | ||||
| 		(int) 0 => array( | ||||
| 			'name' => 'joeseph', | ||||
|  | @ -427,7 +550,22 @@ TEXT; | |||
| 			'hair' => 'black' | ||||
| 		) | ||||
| 	) | ||||
| )</pre> | ||||
| ){$close} | ||||
| TEXT; | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		Debugger::dump($var, 1); | ||||
| 		$result = ob_get_clean(); | ||||
| 
 | ||||
| 		$open = PHP_SAPI === 'cli' ? "\n" : '<pre>'; | ||||
| 		$close = PHP_SAPI === 'cli' ? "\n" : '</pre>'; | ||||
| 		$expected = <<<TEXT | ||||
| {$open}array( | ||||
| 	'People' => array( | ||||
| 		[maximum depth reached] | ||||
| 	) | ||||
| ){$close} | ||||
| TEXT; | ||||
| 		$this->assertTextEquals($expected, $result); | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko