1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AerialShip\SamlSPBundle\Tests\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use AerialShip\SamlSPBundle\DependencyInjection\Configuration; |
6
|
|
|
use Symfony\Component\Config\Definition\Processor; |
7
|
|
|
|
8
|
|
|
class ConfigurationTest extends \PHPUnit_Framework_TestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @test |
12
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
13
|
|
|
*/ |
14
|
|
|
public function shouldRequireSSOStateEntityClass() |
15
|
|
|
{ |
16
|
|
|
$configs = array(); |
17
|
|
|
$this->processConfiguration($configs); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @test |
23
|
|
|
*/ |
24
|
|
|
public function shouldAllowUsageWithSSOStateEntityClassOnly() |
25
|
|
|
{ |
26
|
|
|
$configs = array('aerial_ship_saml_sp' => array( |
27
|
|
|
'sso_state_entity_class' => 'Some\Class' |
28
|
|
|
)); |
29
|
|
|
$this->processConfiguration($configs); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @test |
34
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException |
35
|
|
|
*/ |
36
|
|
|
public function throwIfNonScalarSSOStateEntityClass() |
37
|
|
|
{ |
38
|
|
|
$configs = array('aerial_ship_saml_sp' => array( |
39
|
|
|
'sso_state_entity_class' => array() |
40
|
|
|
)); |
41
|
|
|
$this->processConfiguration($configs); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @test |
47
|
|
|
*/ |
48
|
|
|
public function shouldAllowOrmDbDriver() |
49
|
|
|
{ |
50
|
|
|
$configs = array('aerial_ship_saml_sp' => array( |
51
|
|
|
'driver' => 'orm', |
52
|
|
|
'sso_state_entity_class' => 'Some\Class' |
53
|
|
|
)); |
54
|
|
|
$this->processConfiguration($configs); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @test |
59
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException |
60
|
|
|
*/ |
61
|
|
|
public function throwIfUnknownDbDriver() |
62
|
|
|
{ |
63
|
|
|
$configs = array('aerial_ship_saml_sp' => array( |
64
|
|
|
'driver' => 'something_unknown', |
65
|
|
|
'sso_state_entity_class' => 'Some\Class' |
66
|
|
|
)); |
67
|
|
|
$this->processConfiguration($configs); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @test |
73
|
|
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException |
74
|
|
|
*/ |
75
|
|
|
public function throwIfNonScalarDbDriver() |
76
|
|
|
{ |
77
|
|
|
$configs = array('aerial_ship_saml_sp' => array( |
78
|
|
|
'driver' => array(), |
79
|
|
|
'sso_state_entity_class' => 'Some\Class' |
80
|
|
|
)); |
81
|
|
|
$this->processConfiguration($configs); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
|
86
|
|
|
|
87
|
|
|
|
88
|
|
|
protected function processConfiguration(array $configs) |
89
|
|
|
{ |
90
|
|
|
$configuration = new Configuration(); |
91
|
|
|
$processor = new Processor(); |
92
|
|
|
|
93
|
|
|
return $processor->processConfiguration($configuration, $configs); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|