/** * @runInSeparateProcess */ public function testClean() { Session::start(); Session::set('test1', 'testing1'); Session::set('test2', 'testing2'); $this->assertTrue(Session::exists('test1')); $this->assertTrue(Session::exists('test2')); Session::clean(); $this->assertTrue(Session::isStarted()); $this->assertFalse(Session::exists('test1')); $this->assertFalse(Session::exists('test2')); }
<?php /* * @author sudhir vishwakarma <*****@*****.**> * @copyright Sudhir Vishwakarma (www.itwebinfo.com) * * @version 0.1 20100602 * How to use : * Create your database in MySQL, and create a table in which * to store your session information. The example code below * uses a table called "session". Here is the SQL command * which created it: * * CREATE TABLE sessions (id varchar(32) NOT NULL,access * int(10) unsigned,data text,PRIMARY KEY (id)); */ require_once "session.class.php"; $oSession = new Session(); //$uid=$_SESSION['uid'] = "63"; //echo Session::read('4ec755f49559e17064802cf0964fb35f'); echo $oSession->read(session_id()); //print_r(Session::users()); $max = '5'; print_r($oSession->clean($max)); session_destroy(); //$_SESSION['uid'] = "63"; // Comment this Once sessoin is set //$_SESSION['test'] = "great"; // Comment this Once sessoin is set ?>
/** * Должен прекращать работу, если сессия не активна. */ public function testClean_shouldExitIfSessionNotAction() { $this->apiMock->expects($this->any())->method('session_status')->will($this->returnValue(PHP_SESSION_NONE)); $this->apiMock->expects($this->never())->method('session_unset'); $session = new Session(); $session->clean(); }