public function test_serialization_and_deserialization() { $state = new SsoSessionState(); $state->setIdpEntityId($idp = 'IDP')->setSpEntityId($sp = 'SP')->setNameId($nameId = 'name.id')->setNameIdFormat($nameIdFormat = 'name.id.format')->setSessionIndex($sessionIndex = 'session.index')->setFirstAuthOn($firstAuthOn = new \DateTime('2015-10-27 08:00:00'))->setLastAuthOn($lastAuthOn = new \DateTime('2015-10-27 10:00:00'))->setSessionInstant($sessionInstant = new \DateTime('2015-10-27 06:00:00')); $data = $state->serialize(); $otherState = new SsoSessionState(); $otherState->unserialize($data); $this->assertEquals($state->getIdpEntityId(), $otherState->getIdpEntityId()); $this->assertEquals($state->getSpEntityId(), $otherState->getSpEntityId()); $this->assertEquals($state->getNameId(), $otherState->getNameId()); $this->assertEquals($state->getNameIdFormat(), $otherState->getNameIdFormat()); $this->assertEquals($state->getSessionIndex(), $otherState->getSessionIndex()); $this->assertEquals($state->getFirstAuthOn(), $otherState->getFirstAuthOn()); $this->assertEquals($state->getLastAuthOn(), $otherState->getLastAuthOn()); $this->assertEquals($state->getSessionInstant(), $otherState->getSessionInstant()); }
public function test_modify() { $state = new SsoState(); $state->addSsoSession($session1 = new SsoSessionState()); $session1->setIdpEntityId('idp-1'); $state->addSsoSession($session2 = new SsoSessionState()); $session2->setIdpEntityId('idp-2'); $state->modify(function (SsoSessionState $session) use($session1) { return $session->getIdpEntityId() != $session1->getIdpEntityId(); }); $sessions = $state->getSsoSessions(); $this->assertCount(1, $sessions); $this->assertEquals($session2->getIdpEntityId(), $sessions[0]->getIdpEntityId()); }