public function tearDown() { Session::reset(); $cookies = array_keys($_COOKIE); foreach ($cookies as $cookie) { setcookie($cookie, "", time() - 1); } }
public function testSessionStateResetNamed() { Session::reset(); $this->expectException("Configuration `default` has not been defined."); $this->assertFalse(Session::isStarted('default')); }
public function testHmacStrategyWithPhpAdapter() { $this->skipIf(PHP_SAPI === 'cli', 'No PHP session support in cli SAPI.'); $config = array('name' => 'hmacInt'); Session::config(array($config['name'] => array('adapter' => 'Php', 'strategies' => array('Hmac' => array('secret' => 's3cr3t'))))); Session::clear($config); $key = 'test'; $value = 'value'; $this->assertTrue(Session::write($key, $value, $config)); $this->assertEqual($value, Session::read($key, $config)); $this->assertTrue(Session::delete($key, $config)); $this->assertNull(Session::read($key, $config)); Session::clear($config); $this->assertTrue(Session::write('foo', 'bar', $config)); $this->assertEqual('bar', Session::read('foo', $config)); $this->assertTrue(Session::write('foo', 'bar1', $config)); $this->assertEqual('bar1', Session::read('foo', $config)); Session::clear($config); $this->assertTrue(Session::write($key, $value, $config)); $this->assertEqual($value, Session::read($key, $config)); $cache = $_SESSION; $_SESSION['injectedkey'] = 'hax0r'; $expected = '/Possible data tampering: HMAC signature does not match data./'; $this->asssertException($expected, function () use($key, $config) { Session::read($key, $config); }); $_SESSION = $cache; Session::reset(); }