|
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\PROCERGSNfgExtension; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; |
|
17
|
|
|
|
|
18
|
|
|
class PROCERGSNfgExtensionTest extends TestCase |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* @return ContainerBuilder |
|
22
|
|
|
*/ |
|
23
|
|
|
private function createContainer() |
|
24
|
|
|
{ |
|
25
|
|
|
$container = new ContainerBuilder( |
|
26
|
|
|
new ParameterBag( |
|
27
|
|
|
array( |
|
28
|
|
|
'kernel.cache_dir' => __DIR__, |
|
29
|
|
|
'kernel.root_dir' => __DIR__.'/Fixtures', |
|
30
|
|
|
'kernel.charset' => 'UTF-8', |
|
31
|
|
|
'kernel.debug' => false, |
|
32
|
|
|
'kernel.bundles' => array('PROCERGSLoginCidadaoMonitorBundle' => 'PROCERGS\\LoginCidadao\\MonitorBundle\\PROCERGSLoginCidadaoMonitorBundle'), |
|
33
|
|
|
) |
|
34
|
|
|
) |
|
35
|
|
|
); |
|
36
|
|
|
|
|
37
|
|
|
return $container; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
private function compileContainer(ContainerBuilder $container) |
|
41
|
|
|
{ |
|
42
|
|
|
$container->getCompilerPassConfig()->setOptimizationPasses(array()); |
|
43
|
|
|
$container->getCompilerPassConfig()->setRemovingPasses(array()); |
|
44
|
|
|
$container->compile(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function testParametersLoaded() |
|
48
|
|
|
{ |
|
49
|
|
|
$config = ConfigurationTest::getSampleConfig(); |
|
50
|
|
|
$config['circuit_breaker']['max_failures'] = 1; |
|
51
|
|
|
$config['circuit_breaker']['reset_timeout'] = 5; |
|
52
|
|
|
$container = $this->createContainer(); |
|
53
|
|
|
$container->registerExtension(new PROCERGSNfgExtension()); |
|
54
|
|
|
$container->loadFromExtension('procergs_nfg', $config); |
|
55
|
|
|
$this->compileContainer($container); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertEquals(1, $container->getParameter('procergs.nfg.circuit_breaker.max_failures')); |
|
58
|
|
|
$this->assertEquals(5, $container->getParameter('procergs.nfg.circuit_breaker.reset_timeout')); |
|
59
|
|
|
|
|
60
|
|
|
$endpoints = $config['endpoints']; |
|
61
|
|
|
$endpointsPrefix = 'procergs.nfg.endpoints.'; |
|
62
|
|
|
$this->assertEquals($endpoints['wsdl'], $container->getParameter($endpointsPrefix.'wsdl')); |
|
63
|
|
|
$this->assertEquals($endpoints['login'], $container->getParameter($endpointsPrefix.'login')); |
|
64
|
|
|
$this->assertEquals($endpoints['authorization'], $container->getParameter($endpointsPrefix.'authorization')); |
|
65
|
|
|
|
|
66
|
|
|
$authN = $config['authentication']; |
|
67
|
|
|
$authNPrefix = 'procergs.nfg.authentication.'; |
|
68
|
|
|
$this->assertEquals($authN['organization'], $container->getParameter($authNPrefix.'organization')); |
|
69
|
|
|
$this->assertEquals($authN['username'], $container->getParameter($authNPrefix.'username')); |
|
70
|
|
|
$this->assertEquals($authN['password'], $container->getParameter($authNPrefix.'password')); |
|
71
|
|
|
$this->assertEquals($authN['hmac_secret'], $container->getParameter($authNPrefix.'hmac_secret')); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|