public function testSessionRestore()
 {
     $session = UnitTestingSession::singleton();
     $session->TestValue = "abc123";
     $session->storeSession();
     Container::current()->clearSingleton(UnitTestingSession::class);
     $session = UnitTestingSession::singleton();
     $this->assertEquals("abc123", $session->TestValue);
 }
Example #2
0
 public function testSessionGetsProvider()
 {
     Container::current()->registerClass(SessionProvider::class, UnitTestingSessionProvider::class);
     $session = UnitTestingSession::singleton();
     $this->assertInstanceOf(UnitTestingSessionProvider::class, $session->testGetSessionProvider());
     Container::current()->registerClass(SessionProvider::class, PhpSessionProvider::class);
     // Although we have changed the default provider, we already instantiated the session so the provider will not
     // have changed
     $this->assertInstanceOf(UnitTestingSessionProvider::class, $session->testGetSessionProvider());
 }
 public function testSessionEncrypts()
 {
     $session = UnitTestEncryptedSession::singleton();
     $session->testValue = "123456";
     $provider = new UnitTestingSessionProvider();
     $provider->storeSession($session);
     $this->assertEquals("lu3RCzBb/lz4HIqFnlHc7A==", $_SESSION[UnitTestEncryptedSession::class]["testValue"]);
     Container::current()->clearSingleton(UnitTestEncryptedSession::class);
     $session = UnitTestEncryptedSession::singleton();
     $this->assertEquals("123456", $session->testValue);
 }