SamlHostnameEnricherTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testProcess() 0 11 1
A setUp() 0 3 1
A testProcessExisting() 0 11 1
1
<?php
2
declare(strict_types=1);
3
4
namespace DMK\MKSamlAuth\Tests\Unit\Enricher;
5
6
use DMK\MKSamlAuth\Enricher\SamlHostnameEnricher;
7
use DMK\MKSamlAuth\Model\FrontendUser;
8
use PHPUnit\Framework\TestCase;
9
use Prophecy\Argument;
10
11
class SamlHostnameEnricherTest extends TestCase
12
{
13
    /**
14
     * @var SamlHostnameEnricher
15
     */
16
    private $enricher;
17
18
    protected function setUp()
19
    {
20
        $this->enricher = new SamlHostnameEnricher();
21
    }
22
23
    public function testProcess()
24
    {
25
        $user = new FrontendUser([]);
26
27
        $this->enricher->process($user, [
28
            'idp' => [
29
                'name' => 'foo'
30
            ]
31
        ]);
32
33
        static::assertSame('foo', $user->getProperty('mksamlauth_host'));
34
    }
35
36
    public function testProcessExisting()
37
    {
38
        $user = $this->prophesize(FrontendUser::class);
39
        $user->getUid()->willReturn('1');
40
41
        $user->setProperty('mksamlauth_host', Argument::any())
42
            ->shouldNotBeCalled();
43
44
        $this->enricher->process($user->reveal(), [
45
            'idp' => [
46
                'name' => 'foo'
47
            ]
48
        ]);
49
    }
50
}
51