/**
  * Proves that invalid sessions will be destroyed and re-created
  * if invalid
  *
  * @return void
  */
 public function testInvalidSessionRenew()
 {
     TestCakeSession::start();
     $this->assertNotEmpty($_SESSION['Config']);
     $data = $_SESSION;
     session_write_close();
     $_SESSION = null;
     TestCakeSession::start();
     $this->assertEquals($data, $_SESSION);
     TestCakeSession::write('Foo', 'Bar');
     session_write_close();
     $_SESSION = null;
     TestCakeSession::userAgent('bogus!');
     TestCakeSession::start();
     $this->assertNotEquals($data, $_SESSION);
     $this->assertEquals('bogus!', $_SESSION['Config']['userAgent']);
 }
Пример #2
0
 /**
  * testReadAndWriteWithDatabaseStorage method
  *
  * @return void
  */
 public function testReadAndWriteWithDatabaseStorage()
 {
     Configure::write('Session.defaults', 'database');
     Configure::write('Session.handler.table', 'sessions');
     Configure::write('Session.handler.model', 'Session');
     Configure::write('Session.handler.database', 'test');
     TestCakeSession::init();
     TestCakeSession::start();
     TestCakeSession::write('SessionTestCase', 0);
     $this->assertEquals(0, TestCakeSession::read('SessionTestCase'));
     TestCakeSession::write('SessionTestCase', '0');
     $this->assertEquals('0', TestCakeSession::read('SessionTestCase'));
     $this->assertFalse(TestCakeSession::read('SessionTestCase') === 0);
     TestCakeSession::write('SessionTestCase', false);
     $this->assertFalse(TestCakeSession::read('SessionTestCase'));
     TestCakeSession::write('SessionTestCase', null);
     $this->assertEquals(null, TestCakeSession::read('SessionTestCase'));
     TestCakeSession::write('SessionTestCase', 'This is a Test');
     $this->assertEquals('This is a Test', TestCakeSession::read('SessionTestCase'));
     TestCakeSession::write('SessionTestCase', 'Some additional data');
     $this->assertEquals('Some additional data', TestCakeSession::read('SessionTestCase'));
     TestCakeSession::destroy();
     $this->assertNull(TestCakeSession::read('SessionTestCase'));
     Configure::write('Session', array('defaults' => 'php'));
     TestCakeSession::init();
 }
Пример #3
0
/**
 * Test that cookieTimeout matches timeout when unspecified.
 *
 * @return void
 */
	public function testCookieTimeoutFallback() {
		$_SESSION = null;
		Configure::write('Session', array(
			'defaults' => 'cake',
			'timeout' => 400,
		));
		TestCakeSession::start();
		$this->assertEquals(400, Configure::read('Session.cookieTimeout'));
		$this->assertEquals(400, Configure::read('Session.timeout'));
		$this->assertEquals(400 * 60, ini_get('session.cookie_lifetime'));
		$this->assertEquals(400 * 60, ini_get('session.gc_maxlifetime'));

		$_SESSION = null;
		Configure::write('Session', array(
			'defaults' => 'cake',
			'timeout' => 400,
			'cookieTimeout' => 600
		));
		TestCakeSession::start();
		$this->assertEquals(600, Configure::read('Session.cookieTimeout'));
		$this->assertEquals(400, Configure::read('Session.timeout'));
	}
Пример #4
0
 /**
  * Test that cookieTimeout matches timeout when unspecified.
  *
  * @return void
  */
 public function testCookieTimeoutFallback()
 {
     $_SESSION = null;
     Configure::write('Session', array('defaults' => 'php', 'timeout' => 400));
     TestCakeSession::start();
     $this->assertEquals(400, Configure::read('Session.cookieTimeout'));
     $this->assertEquals(400, Configure::read('Session.timeout'));
     $_SESSION = null;
     Configure::write('Session', array('defaults' => 'php', 'timeout' => 400, 'cookieTimeout' => 600));
     TestCakeSession::start();
     $this->assertEquals(600, Configure::read('Session.cookieTimeout'));
     $this->assertEquals(400, Configure::read('Session.timeout'));
 }