1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\monitor\Test; |
4
|
|
|
|
5
|
|
|
use \SimpleSAML\Module\monitor\State as State; |
6
|
|
|
use \SimpleSAML\Module\monitor\TestData as TestData; |
7
|
|
|
use \SimpleSAML\Module\monitor\TestResult as TestResult; |
8
|
|
|
use \SimpleSAML\Module\monitor\TestConfiguration as TestConfiguration; |
9
|
|
|
use \SimpleSAML\Module\monitor\TestSuiteFactory as TestSuiteFactory; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Tests for TestSuiteFactory |
13
|
|
|
*/ |
14
|
|
|
class TestSuiteFactoryTest extends \PHPUnit_Framework_TestCase |
15
|
|
|
{ |
16
|
|
|
public function testTestSuiteFactory() |
17
|
|
|
{ |
18
|
|
|
$config = new TestConfiguration( |
19
|
|
|
[], |
|
|
|
|
20
|
|
|
[], |
|
|
|
|
21
|
|
|
\SimpleSAML_Configuration::loadFromArray(['metadata.sources' => []]), |
22
|
|
|
\SimpleSAML_Configuration::loadFromArray([]), |
23
|
|
|
\SimpleSAML_Configuration::loadFromArray([]) |
24
|
|
|
); |
25
|
|
|
$testData = new TestData([]); |
26
|
|
|
$testSuite = new TestSuiteInstance($config, $testData); |
27
|
|
|
$this->assertEquals(State::NOSTATE, $testSuite->calculateState()); |
28
|
|
|
|
29
|
|
|
$results = $testSuite->prepareTests(); |
30
|
|
|
|
31
|
|
|
$this->assertEquals($config, $testSuite->getConfiguration()); |
32
|
|
|
$this->assertEquals($results, $testSuite->getTestResults()); |
33
|
|
|
$this->assertEquals([ |
34
|
|
|
['state' => State::OK, 'category' => 'a', 'subject' => 'b', 'message' => ''], |
35
|
|
|
['state' => State::OK, 'category' => 'c', 'subject' => 'd', 'message' => ''], |
36
|
|
|
['state' => State::OK, 'category' => 'e', 'subject' => 'f', 'message' => ''], |
37
|
|
|
], $testSuite->getArrayizeTestResults()); |
38
|
|
|
|
39
|
|
|
$this->assertEquals('travis', $testSuite->getCategory()); |
40
|
|
|
$this->assertEquals('travis', $testSuite->getSubject()); |
41
|
|
|
|
42
|
|
|
$this->assertEquals(State::OK, $testSuite->calculateState()); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
class TestSuiteInstance extends TestSuiteFactory |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
public function prepareTests() |
49
|
|
|
{ |
50
|
|
|
$a = new TestResult('a', 'b'); |
51
|
|
|
$b = new TestResult('c', 'd'); |
52
|
|
|
$c = new TestResult('e', 'f'); |
53
|
|
|
|
54
|
|
|
$this->addTestResults([$a, $b]); |
55
|
|
|
$this->addTestResult($c); |
56
|
|
|
|
57
|
|
|
return [$a, $b, $c]; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function invokeTest() |
61
|
|
|
{ |
62
|
|
|
$this->setCategory('travis'); |
63
|
|
|
$this->setSubject('travis'); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|