EnricherRegistryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testProcess() 0 11 1
A testRegisterWithWrongClass() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace DMK\MKSamlAuth\Tests\Unit;
5
6
use DMK\MKSamlAuth\Enricher\SamlHostnameEnricher;
7
use DMK\MKSamlAuth\EnricherRegistry;
8
use DMK\MKSamlAuth\Model\FrontendUser;
9
use PHPUnit\Framework\TestCase;
10
use TYPO3\CMS\Core\Utility\GeneralUtility;
11
12
class EnricherRegistryTest extends TestCase
13
{
14
    /**
15
     * @var EnricherRegistry
16
     */
17
    private $registry;
18
19
    protected function setUp()
20
    {
21
        $this->registry = new EnricherRegistry();
22
    }
23
24
    public function testProcess()
25
    {
26
        $user = $this->prophesize(FrontendUser::class);
27
28
        $enricher = $this->prophesize(SamlHostnameEnricher::class);
29
        $enricher->process($user->reveal(), []);
30
31
        GeneralUtility::addInstance(SamlHostnameEnricher::class, $enricher->reveal());
32
        EnricherRegistry::register(SamlHostnameEnricher::class);
33
34
        $this->registry->process($user->reveal(), []);
35
    }
36
37
    /**
38
     * @expectedException LogicException
39
     * @expectedExceptionMessage The class "stdClass" does not implements "DMK\MKSamlAuth\Enricher\EnricherInterface".
40
     */
41
    public function testRegisterWithWrongClass()
42
    {
43
        EnricherRegistry::register(\stdClass::class);
44
    }
45
}
46