Passed
Branch monitor-2.5.x (32aff2)
by Tim
01:33
created

TestConfigurationTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testTestConfiguration() 0 46 1
1
<?php
2
3
namespace SimpleSAML\Modules\Monitor\Test;
4
5
use \SimpleSAML\Modules\Monitor\DependencyInjection as DependencyInjection;
6
use \SimpleSAML\Modules\Monitor\TestConfiguration as TestConfiguration;
7
8
// This test relies on \SimpleSAML_Configuration::setPreLoadedConfig(), which is not available until after 1.15.4
9
if (method_exists('SimpleSAML_Configuration', 'setPreLoadedConfig')) {
10
11
/**
12
 * Tests for TestConfiguration
13
 */
14
class TestConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase
15
{
16
    public function testTestConfiguration()
17
    {
18
        $serverVars = new DependencyInjection(['SERVER_NAME' => 'localhost']);
19
        $requestVars = new DependencyInjection(['output' => 'travis']);
20
21
        $globalConfig_input = [
22
            'enable.saml20-idp' => true,
23
            'enable.shib13-idp' => true,
24
            'enable.adfs-idp' => true,
25
            'enable.wsfed-sp' => true,
26
            'metadata.sources' => [
27
                [
28
                    'type' => 'xml',
29
                    'file' => 'modules/monitor/tests/files/metadata.xml',
30
                ],
31
            ],
32
        ];
33
        $authSourceConfig_input = [
34
            'test' => 'travis'
35
        ];
36
        $moduleConfig_input = [
37
            'test' => 'travis'
38
        ];
39
40
        $globalConfig = \SimpleSAML_Configuration::loadFromArray($globalConfig_input);
41
        $authSourceConfig = \SimpleSAML_Configuration::loadFromArray($authSourceConfig_input);
42
        $moduleConfig = \SimpleSAML_Configuration::loadFromArray($moduleConfig_input);
43
44
        \SimpleSAML_Configuration::setPreLoadedConfig($globalConfig, 'config.php');
0 ignored issues
show
Bug introduced by
The method setPreLoadedConfig() does not exist on SimpleSAML_Configuration. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
        \SimpleSAML_Configuration::/** @scrutinizer ignore-call */ 
45
                                   setPreLoadedConfig($globalConfig, 'config.php');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        \SimpleSAML_Configuration::setPreLoadedConfig($moduleConfig, 'module_monitor.php');
46
        \SimpleSAML_Configuration::setPreLoadedConfig($authSourceConfig, 'authsources.php');
47
48
        $testConf = new TestConfiguration($serverVars, $requestVars, $globalConfig, $authSourceConfig, $moduleConfig);
49
50
        $this->assertEquals($serverVars, $testConf->getServerVars());
51
        $this->assertEquals($requestVars, $testConf->getRequestVars());
52
53
        $this->assertEquals($globalConfig, $testConf->getGlobalConfig());
54
        $this->assertEquals($authSourceConfig, $testConf->getAuthSourceConfig());
55
        $this->assertEquals($moduleConfig, $testConf->getModuleConfig());
56
57
        $metadataConfig = $testConf->getMetadataConfig();
58
        $this->assertArrayHasKey('https://engine.surfconext.nl/authentication/idp/metadata', $metadataConfig['saml20-idp-remote']);
59
60
        $this->assertNotEmpty($testConf->getAvailableApacheModules());
61
        $this->assertNotEmpty($testConf->getAvailablePhpModules());
62
    }
63
}
64
65
}
66