1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\Monitor\Test; |
4
|
|
|
|
5
|
|
|
use SimpleSAML\Module\Monitor\State; |
6
|
|
|
use SimpleSAML\Module\Monitor\TestData; |
7
|
|
|
use SimpleSAML\Module\Monitor\TestResult; |
8
|
|
|
use SimpleSAML\Module\Monitor\DependencyInjection; |
9
|
|
|
use SimpleSAML\Module\Monitor\TestConfiguration; |
10
|
|
|
use SimpleSAML\Module\Monitor\TestSuiteFactory; |
11
|
|
|
use Tests\SimpleSAML\Module\Monitor\TestFiles\TestSuiteImplementation; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Tests for TestSuiteFactory |
15
|
|
|
*/ |
16
|
|
|
class TestSuiteFactoryTest extends \PHPUnit\Framework\TestCase |
17
|
|
|
{ |
18
|
|
|
public function testTestSuiteFactory(): void |
19
|
|
|
{ |
20
|
|
|
$config = new TestConfiguration( |
21
|
|
|
new DependencyInjection([]), |
22
|
|
|
new DependencyInjection([]), |
23
|
|
|
\SimpleSAML\Configuration::loadFromArray(['metadata.sources' => []]), |
24
|
|
|
\SimpleSAML\Configuration::loadFromArray([]), |
25
|
|
|
\SimpleSAML\Configuration::loadFromArray([]) |
26
|
|
|
); |
27
|
|
|
$testData = new TestData(['travis' => 'travis', 'test' => 'travis']); |
28
|
|
|
$testSuite = new TestSuiteImplementation($config, $testData); |
29
|
|
|
$this->assertEquals(State::NOSTATE, $testSuite->calculateState()); |
30
|
|
|
$this->assertEquals($testData, $testSuite->getTestData()); |
31
|
|
|
|
32
|
|
|
$results = $testSuite->prepareTests(); |
33
|
|
|
|
34
|
|
|
$this->assertEquals($config, $testSuite->getConfiguration()); |
35
|
|
|
$this->assertEquals($results, $testSuite->getTestResults()); |
36
|
|
|
$this->assertEquals([ |
37
|
|
|
['state' => State::ERROR, 'category' => 'a', 'subject' => 'b', 'message' => ''], |
38
|
|
|
['state' => State::WARNING, 'category' => 'c', 'subject' => 'd', 'message' => ''], |
39
|
|
|
['state' => State::OK, 'category' => 'e', 'subject' => 'f', 'message' => ''], |
40
|
|
|
], $testSuite->getArrayizeTestResults()); |
41
|
|
|
|
42
|
|
|
$this->assertEquals('travis', $testSuite->getCategory()); |
43
|
|
|
$this->assertEquals('travis', $testSuite->getSubject()); |
44
|
|
|
|
45
|
|
|
$this->assertEquals(State::ERROR, $testSuite->calculateState()); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|