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
				
			
		
							
								
								
									
										181
									
								
								lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										181
									
								
								lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,181 @@ | |||
| <?php | ||||
| /** | ||||
|  * FlashComponentTest file | ||||
|  * | ||||
|  * Series of tests for flash component. | ||||
|  * | ||||
|  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html> | ||||
|  * 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 (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 2.7.0-dev | ||||
|  * @license       http://www.opensource.org/licenses/mit-license.php MIT License | ||||
|  */ | ||||
| 
 | ||||
| App::uses('FlashComponent', 'Controller/Component'); | ||||
| App::uses('ComponentCollection', 'Controller'); | ||||
| 
 | ||||
| /** | ||||
|  * FlashComponentTest class | ||||
|  * | ||||
|  * @package		Cake.Test.Case.Controller.Component | ||||
|  */ | ||||
| class FlashComponentTest extends CakeTestCase { | ||||
| 
 | ||||
| /** | ||||
|  * setUp method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function setUp() { | ||||
| 		parent::setUp(); | ||||
| 		$this->Components = new ComponentCollection(); | ||||
| 		$this->Flash = new FlashComponent($this->Components); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * tearDown method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function tearDown() { | ||||
| 		parent::tearDown(); | ||||
| 		CakeSession::destroy(); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testSet method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSet() { | ||||
| 		$this->assertNull(CakeSession::read('Message.flash')); | ||||
| 
 | ||||
| 		$this->Flash->set('This is a test message'); | ||||
| 		$expected = array( | ||||
| 			'message' => 'This is a test message', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'Flash/default', | ||||
| 			'params' => array() | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->Flash->set('This is a test message', array( | ||||
| 			'element' => 'test', | ||||
| 			'params' => array('foo' => 'bar') | ||||
| 		)); | ||||
| 		$expected = array( | ||||
| 			'message' => 'This is a test message', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'Flash/test', | ||||
| 			'params' => array('foo' => 'bar') | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->Flash->set('This is a test message', array('element' => 'MyPlugin.alert')); | ||||
| 		$expected = array( | ||||
| 			'message' => 'This is a test message', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'MyPlugin.Flash/alert', | ||||
| 			'params' => array() | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->Flash->set('This is a test message', array('key' => 'foobar')); | ||||
| 		$expected = array( | ||||
| 			'message' => 'This is a test message', | ||||
| 			'key' => 'foobar', | ||||
| 			'element' => 'Flash/default', | ||||
| 			'params' => array() | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.foobar'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testSetWithException method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSetWithException() { | ||||
| 		$this->assertNull(CakeSession::read('Message.flash')); | ||||
| 
 | ||||
| 		$this->Flash->set(new Exception('This is a test message', 404)); | ||||
| 		$expected = array( | ||||
| 			'message' => 'This is a test message', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'Flash/default', | ||||
| 			'params' => array('code' => 404) | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * testSetWithComponentConfiguration method | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testSetWithComponentConfiguration() { | ||||
| 		$this->assertNull(CakeSession::read('Message.flash')); | ||||
| 
 | ||||
| 		$FlashWithSettings = $this->Components->load('Flash', array('element' => 'test')); | ||||
| 		$FlashWithSettings->set('This is a test message'); | ||||
| 		$expected = array( | ||||
| 			'message' => 'This is a test message', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'Flash/test', | ||||
| 			'params' => array() | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 	} | ||||
| 
 | ||||
| /** | ||||
|  * Test magic call method. | ||||
|  * | ||||
|  * @return void | ||||
|  */ | ||||
| 	public function testCall() { | ||||
| 		$this->assertNull(CakeSession::read('Message.flash')); | ||||
| 
 | ||||
| 		$this->Flash->success('It worked'); | ||||
| 		$expected = array( | ||||
| 			'message' => 'It worked', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'Flash/success', | ||||
| 			'params' => array() | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->Flash->alert('It worked', array('plugin' => 'MyPlugin')); | ||||
| 		$expected = array( | ||||
| 			'message' => 'It worked', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'MyPlugin.Flash/alert', | ||||
| 			'params' => array() | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result); | ||||
| 
 | ||||
| 		$this->Flash->error('It did not work', array('element' => 'error_thing')); | ||||
| 		$expected = array( | ||||
| 			'message' => 'It did not work', | ||||
| 			'key' => 'flash', | ||||
| 			'element' => 'Flash/error', | ||||
| 			'params' => array() | ||||
| 		); | ||||
| 		$result = CakeSession::read('Message.flash'); | ||||
| 		$this->assertEquals($expected, $result, 'Element is ignored in magic call.'); | ||||
| 	} | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brm Ko
						Brm Ko