Passed
Push — master ( 9792fc...04e5e0 )
by Tim
06:59
created

MonitorTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 28
c 2
b 0
f 0
dl 0
loc 41
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMonitor() 0 37 1
1
<?php
2
3
namespace SimpleSAML\Module\monitor\Test;
4
5
use SimpleSAML\Configuration;
6
use SimpleSAML\Module\monitor\DependencyInjection;
7
use SimpleSAML\Module\monitor\TestConfiguration;
8
use SimpleSAML\Module\monitor\Monitor;
9
10
/**
11
 * Tests for Monitor
12
 */
13
class MonitorTest extends \SimpleSAML\TestUtils\ClearStateTestCase
14
{
15
    private const FRAMEWORK = 'vendor/simplesamlphp/simplesamlphp-test-framework';
16
17
    public function testMonitor(): void
18
    {
19
        $_SERVER['REQUEST_URI'] = '/';
20
        $serverVars = new DependencyInjection(['SERVER_NAME' => 'localhost']);
21
        $requestVars = new DependencyInjection(['output' => 'travis']);
22
        $globalConfig_input = [
23
            'enable.saml20-idp' => true,
24
            'enable.shib13-idp' => true,
25
            'enable.adfs-idp' => true,
26
            'enable.wsfed-sp' => true,
27
            'metadata.sources' => [
28
                [
29
                    'type' => 'flatfile',
30
                    'file' => self::FRAMEWORK . '/metadata/simplesamlphp/saml20-idp-remote_cert_selfsigned.php',
31
                ],
32
            ],
33
            'database.dsn' => 'mysql:host=localhost;dbname=saml',
34
        ];
35
        $authSourceConfig_input = [
36
            'test' => 'travis'
37
        ];
38
        $moduleConfig_input = [
39
            'test' => 'travis'
40
        ];
41
        $globalConfig = Configuration::loadFromArray($globalConfig_input);
42
        $authSourceConfig = Configuration::loadFromArray($authSourceConfig_input);
43
        $moduleConfig = Configuration::loadFromArray($moduleConfig_input);
44
45
        Configuration::setPreLoadedConfig($globalConfig, 'config.php');
46
        Configuration::setPreLoadedConfig($moduleConfig, 'module_monitor.php');
47
        Configuration::setPreLoadedConfig($authSourceConfig, 'authsources.php');
48
49
        $testConf = new TestConfiguration($serverVars, $requestVars, $globalConfig, $authSourceConfig, $moduleConfig);
50
        $monitor = new Monitor($testConf);
51
        $this->assertEquals($testConf, $monitor->getTestConfiguration());
52
53
        $monitor->invokeTestSuites();
54
    }
55
}
56