SessionStateHandlerTest.php in Auth0 Single Sign On 8.2
File
vendor/auth0/auth0-php/tests/API/Helpers/State/SessionStateHandlerTest.php
View source
<?php
namespace Auth0\Tests\Api\Helpers\State;
use Auth0\SDK\API\Helpers\State\SessionStateHandler;
use Auth0\SDK\Store\SessionStore;
class SessionStateHandlerTest extends \PHPUnit_Framework_TestCase {
private $sessionStore;
private $stateHandler;
public function __construct() {
parent::__construct();
$this->sessionStore = new SessionStore();
$this->stateHandler = new SessionStateHandler($this->sessionStore);
}
public function testStateStoredCorrectly() {
$uniqid = uniqid();
@$this->stateHandler
->store($uniqid);
$this
->assertEquals($uniqid, $this->sessionStore
->get(SessionStateHandler::STATE_NAME));
}
public function testStateIssuedCorrectly() {
$state_issued = $this->stateHandler
->issue();
$this
->assertEquals($state_issued, $this->sessionStore
->get(SessionStateHandler::STATE_NAME));
}
public function testStateValidatesCorrectly() {
$state_issued = $this->stateHandler
->issue();
$this
->assertTrue($this->stateHandler
->validate($state_issued));
$this
->assertNull($this->sessionStore
->get(SessionStateHandler::STATE_NAME));
}
public function testStateFailsWithIncorrectValue() {
$state_issued = $this->stateHandler
->issue();
$this
->assertFalse($this->stateHandler
->validate($state_issued . 'false'));
$this
->assertNull($this->sessionStore
->get(SessionStateHandler::STATE_NAME));
}
}