ElggSessionTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Many methods for \ElggSession pass through to the storage class so we
  4. * don't test them here.
  5. */
  6. class ElggSessionTest extends \PHPUnit_Framework_TestCase {
  7. public function testStart() {
  8. $session = \ElggSession::getMock();
  9. $this->assertTrue($session->start());
  10. $this->assertTrue($session->has('__elgg_session'));
  11. }
  12. public function testInvalidate() {
  13. $session = \ElggSession::getMock();
  14. $session->start();
  15. $session->set('foo', 5);
  16. $id = $session->getId();
  17. $this->assertTrue($session->invalidate());
  18. $this->assertFalse($session->has('foo'));
  19. $this->assertNotEquals($id, $session->getId());
  20. $this->assertTrue($session->has('__elgg_session'));
  21. }
  22. public function testMigrate() {
  23. $session = \ElggSession::getMock();
  24. $session->start();
  25. $session->set('foo', 5);
  26. $id = $session->getId();
  27. $this->assertTrue($session->migrate());
  28. $this->assertTrue($session->has('foo'));
  29. $this->assertNotEquals($id, $session->getId());
  30. $this->assertTrue($session->has('__elgg_session'));
  31. }
  32. }