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
				
			
		|  | @ -2,24 +2,41 @@ | |||
| /** | ||||
|  * ErrorHandlerTest 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.Error | ||||
|  * @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('ErrorHandler', 'Error'); | ||||
| App::uses('Controller', 'Controller'); | ||||
| App::uses('Router', 'Routing'); | ||||
| App::uses('Debugger', 'Utility'); | ||||
| 
 | ||||
| /** | ||||
|  * A faulty ExceptionRenderer to test nesting. | ||||
|  */ | ||||
| class FaultyExceptionRenderer extends ExceptionRenderer { | ||||
| 
 | ||||
| /** | ||||
|  * Dummy rendering implementation. | ||||
|  * | ||||
|  * @return void | ||||
|  * @throws Exception | ||||
|  */ | ||||
| 	public function render() { | ||||
| 		throw new Exception('Error from renderer.'); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * ErrorHandlerTest class | ||||
|  | @ -76,6 +93,8 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| 		set_error_handler('ErrorHandler::handleError'); | ||||
| 		$this->_restoreError = true; | ||||
| 
 | ||||
| 		Debugger::getInstance()->output('html'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		$wrong .= ''; | ||||
| 		$result = ob_get_clean(); | ||||
|  | @ -107,6 +126,8 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| 		set_error_handler('ErrorHandler::handleError'); | ||||
| 		$this->_restoreError = true; | ||||
| 
 | ||||
| 		Debugger::getInstance()->output('html'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		trigger_error('Test error', $error); | ||||
| 
 | ||||
|  | @ -182,7 +203,7 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| 			$result[0] | ||||
| 		); | ||||
| 		$this->assertRegExp('/^Trace:/', $result[1]); | ||||
| 		$this->assertRegExp('/^ErrorHandlerTest\:\:testHandleErrorLoggingTrace\(\)/', $result[2]); | ||||
| 		$this->assertRegExp('/^ErrorHandlerTest\:\:testHandleErrorLoggingTrace\(\)/', $result[3]); | ||||
| 		if (file_exists(LOGS . 'debug.log')) { | ||||
| 			unlink(LOGS . 'debug.log'); | ||||
| 		} | ||||
|  | @ -194,8 +215,6 @@ class ErrorHandlerTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testHandleException() { | ||||
| 		$this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.'); | ||||
| 
 | ||||
| 		$error = new NotFoundException('Kaboom!'); | ||||
| 		ob_start(); | ||||
| 		ErrorHandler::handleException($error); | ||||
|  | @ -209,8 +228,6 @@ class ErrorHandlerTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testHandleExceptionLog() { | ||||
| 		$this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.'); | ||||
| 
 | ||||
| 		if (file_exists(LOGS . 'error.log')) { | ||||
| 			unlink(LOGS . 'error.log'); | ||||
| 		} | ||||
|  | @ -223,8 +240,37 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| 		$this->assertRegExp('/Kaboom!/', $result, 'message missing.'); | ||||
| 
 | ||||
| 		$log = file(LOGS . 'error.log'); | ||||
| 		$this->assertRegExp('/\[NotFoundException\] Kaboom!/', $log[0], 'message missing.'); | ||||
| 		$this->assertRegExp('/\#0.*ErrorHandlerTest->testHandleExceptionLog/', $log[1], 'Stack trace missing.'); | ||||
| 		$this->assertContains('[NotFoundException] Kaboom!', $log[0], 'message missing.'); | ||||
| 		$this->assertContains('ErrorHandlerTest->testHandleExceptionLog', $log[2], 'Stack trace missing.'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test handleException generating log. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testHandleExceptionLogSkipping() { | ||||
| 		if (file_exists(LOGS . 'error.log')) { | ||||
| 			unlink(LOGS . 'error.log'); | ||||
| 		} | ||||
| 		Configure::write('Exception.log', true); | ||||
| 		Configure::write('Exception.skipLog', array('NotFoundException')); | ||||
| 		$notFound = new NotFoundException('Kaboom!'); | ||||
| 		$forbidden = new ForbiddenException('Fooled you!'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		ErrorHandler::handleException($notFound); | ||||
| 		$result = ob_get_clean(); | ||||
| 		$this->assertRegExp('/Kaboom!/', $result, 'message missing.'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		ErrorHandler::handleException($forbidden); | ||||
| 		$result = ob_get_clean(); | ||||
| 		$this->assertRegExp('/Fooled you!/', $result, 'message missing.'); | ||||
| 
 | ||||
| 		$log = file(LOGS . 'error.log'); | ||||
| 		$this->assertNotContains('[NotFoundException] Kaboom!', $log[0], 'message should not be logged.'); | ||||
| 		$this->assertContains('[ForbiddenException] Fooled you!', $log[0], 'message missing.'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -251,14 +297,14 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| /** | ||||
|  * test handleFatalError generating a page. | ||||
|  * | ||||
|  * These tests start two buffers as handleFatalError blows the outer one up. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testHandleFatalErrorPage() { | ||||
| 		$this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.'); | ||||
| 
 | ||||
| 		$originalDebugLevel = Configure::read('debug'); | ||||
| 		$line = __LINE__; | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		ob_start(); | ||||
| 		Configure::write('debug', 1); | ||||
| 		ErrorHandler::handleFatalError(E_ERROR, 'Something wrong', __FILE__, $line); | ||||
|  | @ -267,6 +313,7 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| 		$this->assertContains(__FILE__, $result, 'filename missing.'); | ||||
| 		$this->assertContains((string)$line, $result, 'line missing.'); | ||||
| 
 | ||||
| 		ob_start(); | ||||
| 		ob_start(); | ||||
| 		Configure::write('debug', 0); | ||||
| 		ErrorHandler::handleFatalError(E_ERROR, 'Something wrong', __FILE__, $line); | ||||
|  | @ -274,8 +321,6 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| 		$this->assertNotContains('Something wrong', $result, 'message must not appear.'); | ||||
| 		$this->assertNotContains(__FILE__, $result, 'filename must not appear.'); | ||||
| 		$this->assertContains('An Internal Error Has Occurred', $result); | ||||
| 
 | ||||
| 		Configure::write('debug', $originalDebugLevel); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -284,8 +329,6 @@ class ErrorHandlerTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testHandleFatalErrorLog() { | ||||
| 		$this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.'); | ||||
| 
 | ||||
| 		if (file_exists(LOGS . 'error.log')) { | ||||
| 			unlink(LOGS . 'error.log'); | ||||
| 		} | ||||
|  | @ -299,4 +342,48 @@ class ErrorHandlerTest extends CakeTestCase { | |||
| 		$this->assertContains('[FatalErrorException] Something wrong', $log[1], 'message missing.'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testExceptionRendererNestingDebug method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExceptionRendererNestingDebug() { | ||||
| 		Configure::write('debug', 2); | ||||
| 		Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); | ||||
| 
 | ||||
| 		$result = false; | ||||
| 		try { | ||||
| 			ob_start(); | ||||
| 			ob_start(); | ||||
| 			ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); | ||||
| 		} catch (Exception $e) { | ||||
| 			$result = $e instanceof FatalErrorException; | ||||
| 		} | ||||
| 
 | ||||
| 		restore_error_handler(); | ||||
| 		$this->assertTrue($result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testExceptionRendererNestingProduction method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testExceptionRendererNestingProduction() { | ||||
| 		Configure::write('debug', 0); | ||||
| 		Configure::write('Exception.renderer', 'FaultyExceptionRenderer'); | ||||
| 
 | ||||
| 		$result = false; | ||||
| 		try { | ||||
| 			ob_start(); | ||||
| 			ob_start(); | ||||
| 			ErrorHandler::handleFatalError(E_USER_ERROR, 'Initial error', __FILE__, __LINE__); | ||||
| 		} catch (Exception $e) { | ||||
| 			$result = $e instanceof InternalErrorException; | ||||
| 		} | ||||
| 
 | ||||
| 		restore_error_handler(); | ||||
| 		$this->assertTrue($result); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko