|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace PROCERGS\LoginCidadao\NfgBundle\Tests\DependencyInjection; |
|
12
|
|
|
|
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
use PROCERGS\LoginCidadao\NfgBundle\DependencyInjection\Configuration; |
|
15
|
|
|
use Symfony\Component\Config\Definition\Processor; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @codeCoverageIgnore |
|
19
|
|
|
*/ |
|
20
|
|
|
class ConfigurationTest extends TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
public static function getSampleConfig() |
|
23
|
|
|
{ |
|
24
|
|
|
return [ |
|
25
|
|
|
'verify_https' => true, |
|
26
|
|
|
'circuit_breaker' => [ |
|
27
|
|
|
'max_failures' => 2, |
|
28
|
|
|
'reset_timeout' => 30, |
|
29
|
|
|
], |
|
30
|
|
|
'endpoints' => [ |
|
31
|
|
|
'wsdl' => 'https://dum.my/service.wsdl', |
|
32
|
|
|
'login' => 'https://dum.my/login', |
|
33
|
|
|
'authorization' => 'https://dum.my/authorization', |
|
34
|
|
|
], |
|
35
|
|
|
'authentication' => [ |
|
36
|
|
|
'organization' => 'foobar', |
|
37
|
|
|
'username' => 'myUser', |
|
38
|
|
|
'password' => 'mySuperSecretPassword', |
|
39
|
|
|
'hmac_secret' => 'my very secret HMAC string', |
|
40
|
|
|
], |
|
41
|
|
|
]; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testGetConfigTreeBuilder() |
|
45
|
|
|
{ |
|
46
|
|
|
$configuration = new Configuration(); |
|
47
|
|
|
$this->assertInstanceOf( |
|
48
|
|
|
'Symfony\Component\Config\Definition\Builder\TreeBuilder', |
|
49
|
|
|
$configuration->getConfigTreeBuilder() |
|
50
|
|
|
); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testEmptyConfig() |
|
54
|
|
|
{ |
|
55
|
|
|
$processor = new Processor(); |
|
56
|
|
|
|
|
57
|
|
|
try { |
|
58
|
|
|
$processor->processConfiguration(new Configuration(), []); |
|
59
|
|
|
$this->fail('The configuration is not failing when receiving invalid data.'); |
|
60
|
|
|
} catch (\Exception $e) { |
|
61
|
|
|
$this->assertInstanceOf('Symfony\Component\Config\Definition\Exception\InvalidConfigurationException', $e); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function testFullConfig() |
|
66
|
|
|
{ |
|
67
|
|
|
$processor = new Processor(); |
|
68
|
|
|
|
|
69
|
|
|
$expected = $this->getSampleConfig(); |
|
70
|
|
|
$config = $processor->processConfiguration(new Configuration(), [$expected]); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertEquals($expected, $config); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|