SamlHostnameEnricherTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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