DefaultGroupEnricherTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 49
rs 10
wmc 4

4 Methods

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