SpMetaConfigProviderTest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 1
cbo 3
dl 0
loc 70
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldBeConstructed() 0 4 1
A shouldImplementSpMetaProviderInterface() 0 5 1
A shouldReturnSpMeta() 0 5 1
A shouldResolvePersistentNameIDFormat() 0 6 1
A shouldResolveTransientNameIDFormat() 0 6 1
A shouldResolvePostBinding() 0 7 1
A shouldResolveRedirectBinding() 0 7 1
1
<?php
2
3
namespace AerialShip\SamlSPBundle\Tests\Config;
4
5
use AerialShip\LightSaml\Bindings;
6
use AerialShip\LightSaml\NameIDPolicy;
7
use AerialShip\SamlSPBundle\Config\SpMetaConfigProvider;
8
9
class SpMetaConfigProviderTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @test
13
     */
14
    public function shouldBeConstructed()
15
    {
16
        new SpMetaConfigProvider(array());
17
    }
18
19
    /**
20
     * @test
21
     */
22
    public function shouldImplementSpMetaProviderInterface()
23
    {
24
        $rc = new \ReflectionClass('AerialShip\SamlSPBundle\Config\SpMetaConfigProvider');
25
        $this->assertTrue($rc->implementsInterface('AerialShip\SamlSPBundle\Config\SpMetaProviderInterface'));
26
    }
27
28
    /**
29
     * @test
30
     */
31
    public function shouldReturnSpMeta()
32
    {
33
        $provider = new SpMetaConfigProvider(array());
34
        $this->assertInstanceOf('AerialShip\LightSaml\Meta\SpMeta', $provider->getSpMeta());
35
    }
36
37
    /**
38
     * @test
39
     */
40
    public function shouldResolvePersistentNameIDFormat()
41
    {
42
        $provider = new SpMetaConfigProvider(array('name_id_format'=>'persistent'));
43
        $spMeta = $provider->getSpMeta();
44
        $this->assertEquals(NameIDPolicy::PERSISTENT, $spMeta->getNameIdFormat());
45
    }
46
47
    /**
48
     * @test
49
     */
50
    public function shouldResolveTransientNameIDFormat()
51
    {
52
        $provider = new SpMetaConfigProvider(array('name_id_format'=>'transient'));
53
        $spMeta = $provider->getSpMeta();
54
        $this->assertEquals(NameIDPolicy::TRANSIENT, $spMeta->getNameIdFormat());
55
    }
56
57
    /**
58
     * @test
59
     */
60
    public function shouldResolvePostBinding()
61
    {
62
        $provider = new SpMetaConfigProvider(array('binding'=>array('authn_request'=>'post', 'logout_request'=>'post')));
63
        $spMeta = $provider->getSpMeta();
64
        $this->assertEquals(Bindings::SAML2_HTTP_POST, $spMeta->getAuthnRequestBinding());
65
        $this->assertEquals(Bindings::SAML2_HTTP_POST, $spMeta->getLogoutRequestBinding());
66
    }
67
68
    /**
69
     * @test
70
     */
71
    public function shouldResolveRedirectBinding()
72
    {
73
        $provider = new SpMetaConfigProvider(array('binding'=>array('authn_request'=>'redirect', 'logout_request'=>'redirect')));
74
        $spMeta = $provider->getSpMeta();
75
        $this->assertEquals(Bindings::SAML2_HTTP_REDIRECT, $spMeta->getAuthnRequestBinding());
76
        $this->assertEquals(Bindings::SAML2_HTTP_REDIRECT, $spMeta->getLogoutRequestBinding());
77
    }
78
} 
79