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

Sql::invokeTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 16
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SimpleSAML\Module\Monitor\TestSuite\Store;
4
5
use SimpleSAML\Module\Monitor\TestConfiguration;
6
use SimpleSAML\Module\Monitor\TestCase;
7
use SimpleSAML\Module\Monitor\TestData;
8
use SimpleSAML\Module\Monitor\TestResult;
9
use SimpleSAML\Module\Monitor\State;
10
11
final class Sql extends \SimpleSAML\Module\Monitor\TestSuiteFactory
12
{
13
    /** var string */
14
    private $host;
15
16
17
    /**
18
     * @param \SimpleSAML\Module\Monitor\TestConfiguration $configuration
19
     */
20
    public function __construct(TestConfiguration $configuration)
21
    {
22
        $globalConfig = $configuration->getGlobalConfig();
23
        $this->host = $globalConfig->getString('store.sql.dsn');
24
25
        parent::__construct($configuration);
26
    }
27
28
29
    /**
30
     * @return void
31
     */
32
    public function invokeTest(): void
33
    {
34
        $testResult = new TestResult('SQL', 'Overall health');
35
36
        $input = [
37
            'host' => $this->host,
38
        ];
39
        $testData = new TestData($input);
40
        $test = new TestCase\Store\Sql($testData);
41
42
        $sqlResult = $test->getTestResult();
43
        $this->addTestResult($sqlResult);
44
45
        $state = $this->calculateState();
46
        $testResult->setState($state);
47
        $this->setTestResult($testResult);
48
    }
49
}
50