2010-01-15 04:42:40 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests to cover the {@link Session} class
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
|
|
|
|
class SessionTest extends SapphireTest {
|
|
|
|
|
|
|
|
function testGetSetBasics() {
|
|
|
|
Session::set('Test', 'Test');
|
|
|
|
|
|
|
|
$this->assertEquals(Session::get('Test'), 'Test');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testClearElement() {
|
|
|
|
Session::set('Test', 'Test');
|
|
|
|
Session::clear('Test');
|
|
|
|
|
|
|
|
$this->assertEquals(Session::get('Test'), '');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testClearAllElements() {
|
|
|
|
Session::set('Test', 'Test');
|
|
|
|
Session::set('Test-1', 'Test-1');
|
|
|
|
|
2010-05-27 04:12:32 +02:00
|
|
|
Session::clear_all();
|
2010-01-15 04:42:40 +01:00
|
|
|
|
|
|
|
// should session get return null? The array key should probably be
|
|
|
|
// unset from the data array
|
|
|
|
$this->assertEquals(Session::get('Test'), '');
|
|
|
|
$this->assertEquals(Session::get('Test-1'), '');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetAllElements() {
|
2010-09-21 22:29:10 +02:00
|
|
|
Session::clear_all(); // Remove all session that might've been set by the test harness
|
|
|
|
|
2010-01-15 04:42:40 +01:00
|
|
|
Session::set('Test', 'Test');
|
|
|
|
Session::set('Test-2', 'Test-2');
|
|
|
|
|
2010-05-27 04:12:32 +02:00
|
|
|
$session = Session::get_all();
|
2010-01-15 04:42:40 +01:00
|
|
|
|
|
|
|
$this->assertEquals($session, array('Test' => 'Test', 'Test-2' => 'Test-2'));
|
|
|
|
}
|
|
|
|
}
|