* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * * Licensed under The Open Group Test Suite License * Redistributions of files must retain the above copyright notice. * * @filesource * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests * @package cake * @subpackage cake.tests.cases.libs.view.helpers * @since CakePHP(tm) v 1.2.0.4206 * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { define('CAKEPHP_UNIT_TEST_EXECUTION', 1); } App::import('Core', array('Helper', 'AppHelper', 'Controller', 'View')); App::import('Helper', array('Session')); /** * SessionHelperTest class * * @package cake * @subpackage cake.tests.cases.libs.view.helpers */ class SessionHelperTest extends CakeTestCase { /** * setUp method * * @access public * @return void */ function setUp() { $this->Session = new SessionHelper(); $this->Session->__start(); $_SESSION = array( 'test' => 'info', 'Message' => array( 'flash' => array( 'element' => 'default', 'params' => array(), 'message' => 'This is a calling' ), 'notification' => array( 'element' => 'session_helper', 'params' => array('title' => 'Notice!', 'name' => 'Alert!'), 'message' => 'This is a test of the emergency broadcasting system', ), 'classy' => array( 'element' => 'default', 'params' => array('class' => 'positive'), 'message' => 'Recorded' ), 'bare' => array( 'element' => null, 'message' => 'Bare message', 'params' => array(), ), ), 'Deeply' => array('nested' => array('key' => 'value')), ); } /** * tearDown method * * @access public * @return void */ function tearDown() { $_SESSION = array(); unset($this->Session); } /** * endTest * * @access public * @return void */ function endTest() { App::build(); } /** * testRead method * * @access public * @return void */ function testRead() { $result = $this->Session->read('Deeply.nested.key'); $this->assertEqual($result, 'value'); $result = $this->Session->read('test'); $this->assertEqual($result, 'info'); } /** * testCheck method * * @access public * @return void */ function testCheck() { $this->assertTrue($this->Session->check('test')); $this->assertTrue($this->Session->check('Message.flash.element')); $this->assertFalse($this->Session->check('Does.not.exist')); $this->assertFalse($this->Session->check('Nope')); } /** * testWrite method * * @access public * @return void */ function testWrite() { $this->expectError(); $this->Session->write('NoWay', 'AccessDenied'); } /** * testFlash method * * @access public * @return void */ function testFlash() { ob_start(); $this->Session->flash(); $result = ob_get_contents(); ob_clean(); $expected = '
'; $this->assertEqual($result, $expected); $this->assertFalse($this->Session->check('Message.flash')); $expected = 'This is a test of the emergency broadcasting system
\n