SessionSsoStateStoreTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 4
b 0
f 0
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGet() 0 8 1
A testGetNull() 0 12 1
A setUp() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DMK\MKSamlAuth\Tests\Unit\Store;
6
7
use DMK\MKSamlAuth\Session\PhpSession;
8
use DMK\MKSamlAuth\Store\SessionSsoStateStore;
9
use LightSaml\State\Sso\SsoState;
10
use PHPUnit\Framework\TestCase;
11
use Prophecy\Argument;
12
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
13
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
14
15
class SessionSsoStateStoreTest extends TestCase
16
{
17
    /**
18
     * @var SessionSsoStateStore
19
     */
20
    private $store;
21
    /**
22
     * @var \Prophecy\Prophecy\ObjectProphecy
23
     */
24
    private $session;
25
26
    protected function setUp()
27
    {
28
        $this->session = $this->prophesize(PhpSession::class);
29
30
        $this->store = new SessionSsoStateStore($this->session->reveal());
31
    }
32
    public function testGet()
33
    {
34
        $state = new SsoState();
35
36
        $this->session->get('sso_state')
37
            ->willReturn(serialize($state));
38
39
        self::assertEquals($state, $this->store->get());
40
    }
41
42
    public function testGetNull()
43
    {
44
        $this->session->get('sso_state')
45
            ->willReturn(null);
46
47
        $this->session->set('sso_state', Argument::type('string'))
48
            ->shouldBeCalled();
49
50
        $this->session->getId()->willReturn('foo');
51
52
        self::assertInstanceOf(SsoState::class, $state = $this->store->get());
53
        self::assertSame('foo', $state->getLocalSessionId());
54
    }
55
}
56