Passed
Branch master (4b23d6)
by Tim
04:40
created

MonitorTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 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\Test\Utils\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