2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* SessionComponentTest file
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2010-05-19 01:15:13 +00:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
|
2010-01-26 19:18:20 +00:00
|
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2010-01-26 19:18:20 +00:00
|
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-05-19 01:15:13 +00:00
|
|
|
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5436
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2009-07-26 01:27:02 +00:00
|
|
|
App::import('Controller', 'Controller', false);
|
2008-06-10 22:38:05 +00:00
|
|
|
App::import('Component', 'Session');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* SessionTestController class
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
2008-06-02 19:22:55 +00:00
|
|
|
*/
|
2008-09-19 00:55:42 +00:00
|
|
|
class SessionTestController extends Controller {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-18 17:55:58 +00:00
|
|
|
/**
|
|
|
|
* uses property
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $uses = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-18 17:55:58 +00:00
|
|
|
/**
|
|
|
|
* session_id method
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function session_id() {
|
2008-09-19 00:55:42 +00:00
|
|
|
return $this->Session->id();
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-09-19 00:55:42 +00:00
|
|
|
/**
|
|
|
|
* OrangeSessionTestController class
|
|
|
|
*
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
2008-09-19 00:55:42 +00:00
|
|
|
*/
|
|
|
|
class OrangeSessionTestController extends Controller {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-18 17:55:58 +00:00
|
|
|
/**
|
|
|
|
* uses property
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $uses = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-18 17:55:58 +00:00
|
|
|
/**
|
|
|
|
* session_id method
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2010-04-05 03:19:38 +00:00
|
|
|
public function session_id() {
|
2008-09-19 00:55:42 +00:00
|
|
|
return $this->Session->id();
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* SessionComponentTest class
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
class SessionComponentTest extends CakeTestCase {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-21 23:55:39 +00:00
|
|
|
/**
|
|
|
|
* setUp method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
$this->_session = Configure::read('Session');
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-21 23:55:39 +00:00
|
|
|
/**
|
|
|
|
* tearDown method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function tearDown() {
|
|
|
|
Configure::write('Session', $this->_session);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* testSessionAutoStart method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testSessionAutoStart() {
|
|
|
|
Configure::write('Session.start', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
|
|
|
$this->assertFalse($Session->active());
|
2010-03-26 03:29:27 +00:00
|
|
|
$this->assertFalse($Session->started());
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->startup(new SessionTestController());
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', true);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
|
|
|
$this->assertTrue($Session->active());
|
2010-03-26 03:29:27 +00:00
|
|
|
$this->assertFalse($Session->started());
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->startup(new SessionTestController());
|
|
|
|
$this->assertTrue(isset($_SESSION));
|
2008-09-19 00:55:42 +00:00
|
|
|
|
|
|
|
$Object = new Object();
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-09-19 00:55:42 +00:00
|
|
|
$Session->start();
|
|
|
|
$expected = $Session->id();
|
|
|
|
|
|
|
|
$result = $Object->requestAction('/session_test/session_id');
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
|
|
|
$result = $Object->requestAction('/orange_session_test/session_id');
|
|
|
|
$this->assertEqual($result, $expected);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-02 19:22:55 +00:00
|
|
|
* testSessionActivate method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testSessionActivate() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2010-06-09 21:15:34 +00:00
|
|
|
$this->assertTrue($Session->active());
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertNull($Session->activate());
|
2010-06-09 21:15:34 +00:00
|
|
|
$this->assertTrue($Session->active());
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
|
|
|
$this->assertFalse($Session->active());
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertNull($Session->activate());
|
2010-06-09 21:15:34 +00:00
|
|
|
$this->assertTrue($Session->active());
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', true);
|
2008-06-10 22:38:05 +00:00
|
|
|
$Session->destroy();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-02 19:22:55 +00:00
|
|
|
* testSessionValid method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-06-20 20:17:23 +00:00
|
|
|
function testSessionValid() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
|
|
|
$this->assertTrue($Session->valid());
|
|
|
|
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session->userAgent('rweerw');
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->valid());
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
|
|
|
$this->assertFalse($Session->active());
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->valid());
|
|
|
|
Configure::write('Session.start', true);
|
2008-09-19 02:57:58 +00:00
|
|
|
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-09-19 02:57:58 +00:00
|
|
|
$Session->time = $Session->read('Config.time') + 1;
|
|
|
|
$this->assertFalse($Session->valid());
|
|
|
|
|
|
|
|
Configure::write('Session.checkAgent', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-09-19 02:57:58 +00:00
|
|
|
$Session->time = $Session->read('Config.time') + 1;
|
|
|
|
$this->assertFalse($Session->valid());
|
|
|
|
Configure::write('Session.checkAgent', true);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-02 19:22:55 +00:00
|
|
|
* testSessionError method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-06-20 20:17:23 +00:00
|
|
|
function testSessionError() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->error());
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
|
|
|
$this->assertFalse($Session->active());
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->error());
|
|
|
|
Configure::write('Session.start', true);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-02 19:22:55 +00:00
|
|
|
* testSessionReadWrite method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testSessionReadWrite() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2010-06-09 21:15:34 +00:00
|
|
|
$this->assertNull($Session->read('Test'));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertTrue($Session->write('Test', 'some value'));
|
|
|
|
$this->assertEqual($Session->read('Test'), 'some value');
|
|
|
|
$this->assertFalse($Session->write('Test.key', 'some value'));
|
2009-09-01 02:50:46 +00:00
|
|
|
$Session->delete('Test');
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertTrue($Session->write('Test.key.path', 'some value'));
|
|
|
|
$this->assertEqual($Session->read('Test.key.path'), 'some value');
|
|
|
|
$this->assertEqual($Session->read('Test.key'), array('path' => 'some value'));
|
|
|
|
$this->assertTrue($Session->write('Test.key.path2', 'another value'));
|
|
|
|
$this->assertEqual($Session->read('Test.key'), array('path' => 'some value', 'path2' => 'another value'));
|
2009-09-01 02:50:46 +00:00
|
|
|
$Session->delete('Test');
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$array = array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3');
|
|
|
|
$this->assertTrue($Session->write('Test', $array));
|
|
|
|
$this->assertEqual($Session->read('Test'), $array);
|
2009-09-01 02:50:46 +00:00
|
|
|
$Session->delete('Test');
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->write(array('Test'), 'some value'));
|
|
|
|
$this->assertTrue($Session->write(array('Test' => 'some value')));
|
|
|
|
$this->assertEqual($Session->read('Test'), 'some value');
|
2009-09-01 02:50:46 +00:00
|
|
|
$Session->delete('Test');
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->write('Test', 'some value'));
|
|
|
|
$Session->write('Test', 'some value');
|
|
|
|
$this->assertFalse($Session->read('Test'));
|
|
|
|
Configure::write('Session.start', true);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-02 19:22:55 +00:00
|
|
|
* testSessionDelete method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testSessionDelete() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->delete('Test'));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->write('Test', 'some value');
|
|
|
|
$this->assertTrue($Session->delete('Test'));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->write('Test', 'some value');
|
|
|
|
$this->assertFalse($Session->delete('Test'));
|
|
|
|
Configure::write('Session.start', true);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-05 15:20:45 +00:00
|
|
|
* testSessionCheck method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-05 15:20:45 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-06-20 20:17:23 +00:00
|
|
|
function testSessionCheck() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertFalse($Session->check('Test'));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->write('Test', 'some value');
|
|
|
|
$this->assertTrue($Session->check('Test'));
|
|
|
|
$Session->delete('Test');
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
Configure::write('Session.start', false);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->write('Test', 'some value');
|
|
|
|
$this->assertFalse($Session->check('Test'));
|
|
|
|
Configure::write('Session.start', true);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-05 15:20:45 +00:00
|
|
|
* testSessionFlash method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-05 15:20:45 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-06-20 20:17:23 +00:00
|
|
|
function testSessionFlash() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->assertNull($Session->read('Message.flash'));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->setFlash('This is a test message');
|
2009-09-01 03:59:40 +00:00
|
|
|
$this->assertEqual($Session->read('Message.flash'), array('message' => 'This is a test message', 'element' => 'default', 'params' => array()));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->setFlash('This is a test message', 'test', array('name' => 'Joel Moss'));
|
2009-09-01 03:59:40 +00:00
|
|
|
$this->assertEqual($Session->read('Message.flash'), array('message' => 'This is a test message', 'element' => 'test', 'params' => array('name' => 'Joel Moss')));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->setFlash('This is a test message', 'default', array(), 'myFlash');
|
2009-09-01 03:59:40 +00:00
|
|
|
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'element' => 'default', 'params' => array()));
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-31 03:06:07 +00:00
|
|
|
$Session->setFlash('This is a test message', 'non_existing_layout');
|
2009-09-01 03:59:40 +00:00
|
|
|
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'element' => 'default', 'params' => array()));
|
2009-03-21 23:55:39 +00:00
|
|
|
|
2009-09-01 02:50:46 +00:00
|
|
|
$Session->delete('Message');
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
|
|
|
* testSessionId method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testSessionId() {
|
|
|
|
unset($_SESSION);
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
$this->assertNull($Session->id());
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-10 22:38:05 +00:00
|
|
|
/**
|
2008-06-05 15:20:45 +00:00
|
|
|
* testSessionDestroy method
|
2008-06-10 22:38:05 +00:00
|
|
|
*
|
2008-06-05 15:20:45 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testSessionDestroy() {
|
2010-06-09 21:15:34 +00:00
|
|
|
$Session = new SessionComponent();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$Session->write('Test', 'some value');
|
|
|
|
$this->assertEqual($Session->read('Test'), 'some value');
|
|
|
|
$Session->destroy('Test');
|
|
|
|
$this->assertNull($Session->read('Test'));
|
|
|
|
}
|
2010-06-27 16:17:37 +00:00
|
|
|
|
2010-04-28 23:45:20 +00:00
|
|
|
/**
|
|
|
|
* testSessionTimeout method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testSessionTimeout() {
|
2010-07-19 02:56:57 +00:00
|
|
|
Configure::write('debug', 2);
|
2010-04-28 23:45:20 +00:00
|
|
|
Configure::write('Security.level', 'low');
|
|
|
|
|
|
|
|
session_destroy();
|
2010-05-07 06:37:14 +00:00
|
|
|
$Session =& new SessionComponent();
|
2010-07-19 02:56:57 +00:00
|
|
|
$Session->destroy();
|
2010-04-28 23:45:20 +00:00
|
|
|
$Session->write('Test', 'some value');
|
2010-07-19 02:56:57 +00:00
|
|
|
$this->assertEqual($Session->sessionTime, time() + (300 * Configure::read('Session.timeout')));
|
2010-07-01 02:51:21 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['timeout'], 10);
|
2010-04-28 23:45:20 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
2010-07-19 02:56:57 +00:00
|
|
|
$this->assertEqual($Session->time, time());
|
|
|
|
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (300 * Configure::read('Session.timeout')));
|
2010-05-07 06:37:14 +00:00
|
|
|
|
2010-04-28 23:45:20 +00:00
|
|
|
Configure::write('Security.level', 'medium');
|
2010-05-07 06:37:14 +00:00
|
|
|
$Session =& new SessionComponent();
|
2010-07-19 02:56:57 +00:00
|
|
|
$Session->destroy();
|
2010-04-28 23:45:20 +00:00
|
|
|
$Session->write('Test', 'some value');
|
2010-06-27 16:52:18 +00:00
|
|
|
$this->assertEqual($Session->sessionTime, mktime() + (100 * Configure::read('Session.timeout')));
|
2010-07-01 02:51:21 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['timeout'], 10);
|
2010-04-28 23:45:20 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
2010-07-19 02:56:57 +00:00
|
|
|
$this->assertEqual($Session->time, time());
|
2010-06-27 16:52:18 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
|
2010-06-27 16:17:37 +00:00
|
|
|
|
2010-04-28 23:45:20 +00:00
|
|
|
Configure::write('Security.level', 'high');
|
2010-05-07 06:37:14 +00:00
|
|
|
$Session =& new SessionComponent();
|
2010-07-19 02:56:57 +00:00
|
|
|
$Session->destroy();
|
2010-04-28 23:45:20 +00:00
|
|
|
$Session->write('Test', 'some value');
|
2010-07-19 02:56:57 +00:00
|
|
|
$this->assertEqual($Session->sessionTime, time() + (10 * Configure::read('Session.timeout')));
|
2010-07-01 02:51:21 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['timeout'], 10);
|
2010-04-28 23:45:20 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
2010-07-19 02:56:57 +00:00
|
|
|
$this->assertEqual($Session->time, time());
|
2010-05-07 06:37:14 +00:00
|
|
|
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
|
2010-04-28 23:45:20 +00:00
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|