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,19 +2,18 @@ | |||
| /** | ||||
|  * AppTest file. | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * 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(tm) Project | ||||
|  * @package       Cake.Test.Case.Core | ||||
|  * @since         CakePHP(tm) 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 | ||||
|  */ | ||||
| 
 | ||||
| /** | ||||
|  | @ -96,7 +95,7 @@ class AppTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * tests that it is possible to set up paths using the cake 1.3 notation for them (models, behaviors, controllers...) | ||||
|  * tests that it is possible to set up paths using the CakePHP 1.3 notation for them (models, behaviors, controllers...) | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -302,7 +301,7 @@ class AppTest extends CakeTestCase { | |||
|  * @return void | ||||
|  */ | ||||
| 	public function testListObjects() { | ||||
| 		$result = App::objects('class',  CAKE . 'Routing', false); | ||||
| 		$result = App::objects('class', CAKE . 'Routing', false); | ||||
| 		$this->assertTrue(in_array('Dispatcher', $result)); | ||||
| 		$this->assertTrue(in_array('Router', $result)); | ||||
| 
 | ||||
|  | @ -363,6 +362,8 @@ class AppTest extends CakeTestCase { | |||
| 
 | ||||
| /** | ||||
|  * Make sure that .svn and friends are excluded from App::objects('plugin') | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testListObjectsIgnoreDotDirectories() { | ||||
| 		$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS; | ||||
|  | @ -429,27 +430,6 @@ class AppTest extends CakeTestCase { | |||
| 		App::build(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that pluginPath can find paths for plugins. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testPluginPath() { | ||||
| 		App::build(array( | ||||
| 			'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) | ||||
| 		)); | ||||
| 		CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); | ||||
| 
 | ||||
| 		$path = App::pluginPath('TestPlugin'); | ||||
| 		$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS; | ||||
| 		$this->assertEquals($expected, $path); | ||||
| 
 | ||||
| 		$path = App::pluginPath('TestPluginTwo'); | ||||
| 		$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPluginTwo' . DS; | ||||
| 		$this->assertEquals($expected, $path); | ||||
| 		App::build(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test that themePath can find paths for themes. | ||||
|  * | ||||
|  | @ -596,7 +576,6 @@ class AppTest extends CakeTestCase { | |||
|  * test that building helper paths actually works. | ||||
|  * | ||||
|  * @return void | ||||
|  * @link http://cakephp.lighthouseapp.com/projects/42648/tickets/410 | ||||
|  */ | ||||
| 	public function testImportingHelpersFromAlternatePaths() { | ||||
| 		$this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.'); | ||||
|  | @ -749,7 +728,7 @@ class AppTest extends CakeTestCase { | |||
| 		$result = App::import('Vendor', 'css/TestAsset', array('ext' => 'css')); | ||||
| 		$text = ob_get_clean(); | ||||
| 		$this->assertTrue($result); | ||||
| 		$this->assertEquals('this is the test asset css file', $text); | ||||
| 		$this->assertEquals('/* this is the test asset css file */', trim($text)); | ||||
| 
 | ||||
| 		$result = App::import('Vendor', 'TestPlugin.sample/SamplePlugin'); | ||||
| 		$this->assertTrue($result); | ||||
|  | @ -794,6 +773,7 @@ class AppTest extends CakeTestCase { | |||
|  * Tests that the automatic class loader will also find in "libs" folder for both | ||||
|  * app and plugins if it does not find the class in other configured paths | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testLoadClassInLibs() { | ||||
| 		App::build(array( | ||||
|  | @ -808,11 +788,11 @@ class AppTest extends CakeTestCase { | |||
| 
 | ||||
| 		$this->assertFalse(class_exists('TestUtilityClass', false)); | ||||
| 		App::uses('TestUtilityClass', 'Utility'); | ||||
| 		$this->assertTrue(class_exists('CustomLibClass')); | ||||
| 		$this->assertTrue(class_exists('TestUtilityClass')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests that  App::location() returns the defined path for a class | ||||
|  * Tests that App::location() returns the defined path for a class | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -848,4 +828,36 @@ class AppTest extends CakeTestCase { | |||
| 		App::uses('TestPluginOtherLibrary', 'TestPlugin.Lib'); | ||||
| 		$this->assertTrue(class_exists('TestPluginOtherLibrary')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that increaseMemoryLimit increases the maximum amount of memory actually | ||||
|  * | ||||
|  * @dataProvider memoryVariationProvider | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testIncreaseMemoryLimit($memoryLimit, $additionalKb, $expected) { | ||||
| 		$this->skipIf(!function_exists('ini_set')); | ||||
| 
 | ||||
| 		$originalMemoryLimit = ini_get('memory_limit'); | ||||
| 
 | ||||
| 		ini_set('memory_limit', $memoryLimit); | ||||
| 		App::increaseMemoryLimit($additionalKb); | ||||
| 		$this->assertEquals($expected, ini_get('memory_limit')); | ||||
| 
 | ||||
| 		ini_set('memory_limit', $originalMemoryLimit); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Data provider function for testIncreaseMemoryLimit  | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function memoryVariationProvider() { | ||||
| 		return array( | ||||
| 			array('131072K', 100000, '231072K'), | ||||
| 			array('256M', 1, '262145K'), | ||||
| 			array('1G', 1, '1048577K'), | ||||
| 			array('-1', 100000, '-1') | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -2,21 +2,21 @@ | |||
| /** | ||||
|  * ObjectTest 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.Core | ||||
|  * @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('CakeObject', 'Core'); | ||||
| App::uses('Object', 'Core'); | ||||
| App::uses('Router', 'Routing'); | ||||
| App::uses('Controller', 'Controller'); | ||||
|  | @ -29,17 +29,10 @@ App::uses('Model', 'Model'); | |||
|  */ | ||||
| class RequestActionPost extends CakeTestModel { | ||||
| 
 | ||||
| /** | ||||
|  * name property | ||||
|  * | ||||
|  * @var string 'ControllerPost' | ||||
|  */ | ||||
| 	public $name = 'RequestActionPost'; | ||||
| 
 | ||||
| /** | ||||
|  * useTable property | ||||
|  * | ||||
|  * @var string 'posts' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $useTable = 'posts'; | ||||
| } | ||||
|  | @ -55,14 +48,12 @@ class RequestActionController extends Controller { | |||
|  * uses property | ||||
|  * | ||||
|  * @var array | ||||
|  * @access public | ||||
|  */ | ||||
| 	public $uses = array('RequestActionPost'); | ||||
| 
 | ||||
| /** | ||||
|  * test_request_action method | ||||
|  * | ||||
|  * @access public | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function test_request_action() { | ||||
|  | @ -74,7 +65,6 @@ class RequestActionController extends Controller { | |||
|  * | ||||
|  * @param mixed $id | ||||
|  * @param mixed $other | ||||
|  * @access public | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function another_ra_test($id, $other) { | ||||
|  | @ -84,7 +74,7 @@ class RequestActionController extends Controller { | |||
| /** | ||||
|  * normal_request_action method | ||||
|  * | ||||
|  * @return void | ||||
|  * @return string Hello World! | ||||
|  */ | ||||
| 	public function normal_request_action() { | ||||
| 		return 'Hello World'; | ||||
|  | @ -93,19 +83,19 @@ class RequestActionController extends Controller { | |||
| /** | ||||
|  * returns $this->here | ||||
|  * | ||||
|  * @return void | ||||
|  * @return string $this->here. | ||||
|  */ | ||||
| 	public function return_here() { | ||||
| 		return $this->here; | ||||
| 		return $this->request->here(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * paginate_request_action method | ||||
|  * | ||||
|  * @return void | ||||
|  * @return true | ||||
|  */ | ||||
| 	public function paginate_request_action() { | ||||
| 		$data = $this->paginate(); | ||||
| 		$this->paginate(); | ||||
| 		return true; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -139,23 +129,23 @@ class RequestActionController extends Controller { | |||
| } | ||||
| 
 | ||||
| /** | ||||
|  * TestObject class | ||||
|  * TestCakeObject class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Core | ||||
|  */ | ||||
| class TestObject extends Object { | ||||
| class TestCakeObject extends CakeObject { | ||||
| 
 | ||||
| /** | ||||
|  * firstName property | ||||
|  * | ||||
|  * @var string 'Joel' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $firstName = 'Joel'; | ||||
| 
 | ||||
| /** | ||||
|  * lastName property | ||||
|  * | ||||
|  * @var string 'Moss' | ||||
|  * @var string | ||||
|  */ | ||||
| 	public $lastName = 'Moss'; | ||||
| 
 | ||||
|  | @ -262,8 +252,9 @@ class TestObject extends Object { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * undocumented function
 | ||||
|  * Set properties. | ||||
|  * | ||||
|  * @param array $properties The $properties. | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function set($properties = array()) { | ||||
|  | @ -281,12 +272,10 @@ class ObjectTestModel extends CakeTestModel { | |||
| 
 | ||||
| 	public $useTable = false; | ||||
| 
 | ||||
| 	public $name = 'ObjectTestModel'; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Object Test class | ||||
|  * CakeObject Test class | ||||
|  * | ||||
|  * @package       Cake.Test.Case.Core | ||||
|  */ | ||||
|  | @ -306,7 +295,7 @@ class ObjectTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		$this->object = new TestObject(); | ||||
| 		$this->object = new TestCakeObject(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -377,7 +366,7 @@ class ObjectTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testToString() { | ||||
| 		$result = strtolower($this->object->toString()); | ||||
| 		$this->assertEquals('testobject', $result); | ||||
| 		$this->assertEquals('testcakeobject', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -388,62 +377,62 @@ class ObjectTest extends CakeTestCase { | |||
| 	public function testMethodDispatching() { | ||||
| 		$this->object->emptyMethod(); | ||||
| 		$expected = array('emptyMethod'); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->oneParamMethod('Hello'); | ||||
| 		$expected[] = array('oneParamMethod' => array('Hello')); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->twoParamMethod(true, false); | ||||
| 		$expected[] = array('twoParamMethod' => array(true, false)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->threeParamMethod(true, false, null); | ||||
| 		$expected[] = array('threeParamMethod' => array(true, false, null)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->crazyMethod(1, 2, 3, 4, 5, 6, 7); | ||||
| 		$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object = new TestObject(); | ||||
| 		$this->object = new TestCakeObject(); | ||||
| 		$this->assertSame($this->object->methodCalls, array()); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('emptyMethod'); | ||||
| 		$expected = array('emptyMethod'); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('oneParamMethod', array('Hello')); | ||||
| 		$expected[] = array('oneParamMethod' => array('Hello')); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('twoParamMethod', array(true, false)); | ||||
| 		$expected[] = array('twoParamMethod' => array(true, false)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('threeParamMethod', array(true, false, null)); | ||||
| 		$expected[] = array('threeParamMethod' => array(true, false, null)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('fourParamMethod', array(1, 2, 3, 4)); | ||||
| 		$expected[] = array('fourParamMethod' => array(1, 2, 3, 4)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('fiveParamMethod', array(1, 2, 3, 4, 5)); | ||||
| 		$expected[] = array('fiveParamMethod' => array(1, 2, 3, 4, 5)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('crazyMethod', array(1, 2, 3, 4, 5, 6, 7)); | ||||
| 		$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('methodWithOptionalParam', array('Hello')); | ||||
| 		$expected[] = array('methodWithOptionalParam' => array("Hello")); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 
 | ||||
| 		$this->object->dispatchMethod('methodWithOptionalParam'); | ||||
| 		$expected[] = array('methodWithOptionalParam' => array(null)); | ||||
| 		$this->assertSame($this->object->methodCalls, $expected); | ||||
| 		$this->assertSame($expected, $this->object->methodCalls); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -466,7 +455,9 @@ class ObjectTest extends CakeTestCase { | |||
| 		$expected = 'This is a test'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$result = $this->object->requestAction(FULL_BASE_URL . '/request_action/test_request_action'); | ||||
| 		$result = $this->object->requestAction( | ||||
| 			Configure::read('App.fullBaseUrl') . '/request_action/test_request_action' | ||||
| 		); | ||||
| 		$expected = 'This is a test'; | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
|  | @ -492,6 +483,17 @@ class ObjectTest extends CakeTestCase { | |||
| 		$this->assertNull(Router::getRequest(), 'requests were not popped off the stack, this will break url generation'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test that here() is calculated correctly in requestAction | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testRequestActionHere() { | ||||
| 		$url = '/request_action/return_here?key=value'; | ||||
| 		$result = $this->object->requestAction($url); | ||||
| 		$this->assertStringEndsWith($url, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test requestAction() and plugins. | ||||
|  * | ||||
|  | @ -609,7 +611,7 @@ class ObjectTest extends CakeTestCase { | |||
| 		$this->assertEquals(null, $result['plugin']); | ||||
| 
 | ||||
| 		$result = $this->object->requestAction('/request_action/params_pass/sort:desc/limit:5'); | ||||
| 		$expected = array('sort' => 'desc', 'limit' => 5,); | ||||
| 		$expected = array('sort' => 'desc', 'limit' => 5); | ||||
| 		$this->assertEquals($expected, $result['named']); | ||||
| 
 | ||||
| 		$result = $this->object->requestAction( | ||||
|  | @ -687,4 +689,15 @@ class ObjectTest extends CakeTestCase { | |||
| 		); | ||||
| 		$this->assertEquals($data, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test backward compatibility | ||||
|  * | ||||
|  * @return voind | ||||
|  */ | ||||
| 	public function testBackwardCompatibility() { | ||||
| 		$this->skipIf(version_compare(PHP_VERSION, '7.0.0', '>=')); | ||||
| 
 | ||||
| 		$this->assertInstanceOf('Object', new ObjectTestModel); | ||||
| 	} | ||||
| } | ||||
|  | @ -2,26 +2,24 @@ | |||
| /** | ||||
|  * CakePluginTest file. | ||||
|  * | ||||
|  * PHP 5 | ||||
|  * | ||||
|  * 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(tm) Project | ||||
|  * @package       Cake.Test.Case.Core | ||||
|  * @since         CakePHP(tm) 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('CakePlugin', 'Core'); | ||||
| 
 | ||||
| /** | ||||
|  * CakePluginTest class | ||||
|  * | ||||
|  */ | ||||
| class CakePluginTest extends CakeTestCase { | ||||
| 
 | ||||
|  | @ -179,6 +177,20 @@ class CakePluginTest extends CakeTestCase { | |||
| 		CakePlugin::routes(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test ignoring missing bootstrap/routes file | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testIgnoreMissingFiles() { | ||||
| 		CakePlugin::loadAll(array(array( | ||||
| 			'bootstrap' => true, | ||||
| 			'routes' => true, | ||||
| 			'ignoreMissing' => true | ||||
| 		))); | ||||
| 		CakePlugin::routes(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests that CakePlugin::load() throws an exception on unknown plugin | ||||
|  * | ||||
|  | @ -197,10 +209,10 @@ class CakePluginTest extends CakeTestCase { | |||
| 	public function testPath() { | ||||
| 		CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); | ||||
| 		$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS; | ||||
| 		$this->assertEquals(CakePlugin::path('TestPlugin'), $expected); | ||||
| 		$this->assertEquals($expected, CakePlugin::path('TestPlugin')); | ||||
| 
 | ||||
| 		$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPluginTwo' . DS; | ||||
| 		$this->assertEquals(CakePlugin::path('TestPluginTwo'), $expected); | ||||
| 		$this->assertEquals($expected, CakePlugin::path('TestPluginTwo')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -240,8 +252,8 @@ class CakePluginTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests that CakePlugin::loadAll() will load all plugins in the configured folder wit defaults | ||||
|  * and overrides for a plugin | ||||
|  * Tests that CakePlugin::loadAll() will load all plugins in the configured folder with defaults | ||||
|  * and merges in global defaults. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
|  | @ -249,6 +261,24 @@ class CakePluginTest extends CakeTestCase { | |||
| 		CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true))); | ||||
| 		CakePlugin::routes(); | ||||
| 
 | ||||
| 		$expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo'); | ||||
| 		$this->assertEquals($expected, CakePlugin::loaded()); | ||||
| 		$this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap')); | ||||
| 		$this->assertEquals('loaded plugin routes', Configure::read('CakePluginTest.test_plugin.routes')); | ||||
| 		$this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap')); | ||||
| 		$this->assertEquals('loaded plugin two bootstrap', Configure::read('CakePluginTest.test_plugin_two.bootstrap')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Tests that CakePlugin::loadAll() will load all plugins in the configured folder with defaults | ||||
|  * and overrides for a plugin | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testLoadAllWithDefaultsAndOverrideComplex() { | ||||
| 		CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true, 'bootstrap' => false))); | ||||
| 		CakePlugin::routes(); | ||||
| 
 | ||||
| 		$expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo'); | ||||
| 		$this->assertEquals($expected, CakePlugin::loaded()); | ||||
| 		$this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap')); | ||||
|  |  | |||
|  | @ -4,20 +4,20 @@ | |||
|  * | ||||
|  * Holds several tests | ||||
|  * | ||||
|  * 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.Core | ||||
|  * @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('PhpReader', 'Configure'); | ||||
| 
 | ||||
| /** | ||||
|  | @ -67,6 +67,24 @@ class ConfigureTest extends CakeTestCase { | |||
| 		Configure::drop('test'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test to ensure bootrapping doesn't overwrite prior configs set under 'App' key | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testBootstrap() { | ||||
| 		$expected = array( | ||||
| 			'foo' => 'bar' | ||||
| 		); | ||||
| 		Configure::write('App', $expected); | ||||
| 
 | ||||
| 		Configure::bootstrap(true); | ||||
| 		$result = Configure::read('App'); | ||||
| 
 | ||||
| 		$this->assertEquals($expected['foo'], $result['foo']); | ||||
| 		$this->assertFalse($result['base']); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testRead method | ||||
|  * | ||||
|  | @ -131,6 +149,39 @@ class ConfigureTest extends CakeTestCase { | |||
| 		$this->assertEquals('4', $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test the consume method. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testConsume() { | ||||
| 		$this->assertNull(Configure::consume('DoesNotExist'), 'Should be null on empty value'); | ||||
| 		Configure::write('Test', array('key' => 'value', 'key2' => 'value2')); | ||||
| 
 | ||||
| 		$result = Configure::consume('Test.key'); | ||||
| 		$this->assertEquals('value', $result); | ||||
| 
 | ||||
| 		$result = Configure::read('Test.key2'); | ||||
| 		$this->assertEquals('value2', $result, 'Other values should remain.'); | ||||
| 
 | ||||
| 		$result = Configure::consume('Test'); | ||||
| 		$expected = array('key2' => 'value2'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testConsumeEmpty | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testConsumeEmpty() { | ||||
| 		Configure::write('Test', array('key' => 'value', 'key2' => 'value2')); | ||||
| 		$result = Configure::consume(''); | ||||
| 		$this->assertNull($result); | ||||
| 		$result = Configure::consume(null); | ||||
| 		$this->assertNull($result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * test setting display_errors with debug. | ||||
|  * | ||||
|  | @ -158,7 +209,7 @@ class ConfigureTest extends CakeTestCase { | |||
| 
 | ||||
| 		Configure::delete('SomeName.someKey'); | ||||
| 		$result = Configure::read('SomeName.someKey'); | ||||
| 		$this->assertTrue($result === null); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
| 		Configure::write('SomeName', array('someKey' => 'myvalue', 'otherKey' => 'otherValue')); | ||||
| 
 | ||||
|  | @ -171,10 +222,65 @@ class ConfigureTest extends CakeTestCase { | |||
| 		Configure::delete('SomeName'); | ||||
| 
 | ||||
| 		$result = Configure::read('SomeName.someKey'); | ||||
| 		$this->assertTrue($result === null); | ||||
| 		$this->assertNull($result); | ||||
| 
 | ||||
| 		$result = Configure::read('SomeName.otherKey'); | ||||
| 		$this->assertTrue($result === null); | ||||
| 		$this->assertNull($result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheck method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheck() { | ||||
| 		Configure::write('ConfigureTestCase', 'value'); | ||||
| 		$this->assertTrue(Configure::check('ConfigureTestCase')); | ||||
| 
 | ||||
| 		$this->assertFalse(Configure::check('NotExistingConfigureTestCase')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheckingSavedEmpty method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheckingSavedEmpty() { | ||||
| 		$this->assertTrue(Configure::write('ConfigureTestCase', 0)); | ||||
| 		$this->assertTrue(Configure::check('ConfigureTestCase')); | ||||
| 
 | ||||
| 		$this->assertTrue(Configure::write('ConfigureTestCase', '0')); | ||||
| 		$this->assertTrue(Configure::check('ConfigureTestCase')); | ||||
| 
 | ||||
| 		$this->assertTrue(Configure::write('ConfigureTestCase', false)); | ||||
| 		$this->assertTrue(Configure::check('ConfigureTestCase')); | ||||
| 
 | ||||
| 		$this->assertTrue(Configure::write('ConfigureTestCase', null)); | ||||
| 		$this->assertFalse(Configure::check('ConfigureTestCase')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheckKeyWithSpaces method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheckKeyWithSpaces() { | ||||
| 		$this->assertTrue(Configure::write('Configure Test', "test")); | ||||
| 		$this->assertTrue(Configure::check('Configure Test')); | ||||
| 		Configure::delete('Configure Test'); | ||||
| 
 | ||||
| 		$this->assertTrue(Configure::write('Configure Test.Test Case', "test")); | ||||
| 		$this->assertTrue(Configure::check('Configure Test.Test Case')); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testCheckEmpty | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCheckEmpty() { | ||||
| 		$this->assertFalse(Configure::check('')); | ||||
| 		$this->assertFalse(Configure::check(null)); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -185,7 +291,7 @@ class ConfigureTest extends CakeTestCase { | |||
|  */ | ||||
| 	public function testLoadExceptionOnNonExistantFile() { | ||||
| 		Configure::config('test', new PhpReader()); | ||||
| 		$result = Configure::load('non_existing_configuration_file', 'test'); | ||||
| 		Configure::load('non_existing_configuration_file', 'test'); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -345,10 +451,16 @@ class ConfigureTest extends CakeTestCase { | |||
|  * | ||||
|  * @expectedException PHPUnit_Framework_Error | ||||
|  * @return void | ||||
|  * @throws PHPUnit_Framework_Error | ||||
|  */ | ||||
| 	public function testReaderExceptionOnIncorrectClass() { | ||||
| 		$reader = new StdClass(); | ||||
| 		Configure::config('test', $reader); | ||||
| 
 | ||||
| 		try { | ||||
| 			Configure::config('test', $reader); | ||||
| 		} catch (TypeError $e) { | ||||
| 			throw new PHPUnit_Framework_Error('Raised an error', 100, __FILE__, __LINE__); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  | @ -364,7 +476,10 @@ class ConfigureTest extends CakeTestCase { | |||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testDumpNoAdapter | ||||
|  * | ||||
|  * @expectedException ConfigureException | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDumpNoAdapter() { | ||||
| 		Configure::dump(TMP . 'test.php', 'does_not_exist'); | ||||
|  | @ -391,7 +506,7 @@ class ConfigureTest extends CakeTestCase { | |||
| /** | ||||
|  * Test dumping only some of the data. | ||||
|  * | ||||
|  * @return | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testDumpPartial() { | ||||
| 		Configure::config('test_reader', new PhpReader(TMP)); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko