Passed
Branch monitor-2.5.x (32aff2)
by Tim
01:33
created

TestSuiteFactoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testTestSuiteFactory() 0 28 1
1
<?php
2
3
namespace SimpleSAML\Modules\Monitor\Test;
4
5
use \SimpleSAML\Modules\Monitor\State as State;
6
use \SimpleSAML\Modules\Monitor\TestData as TestData;
7
use \SimpleSAML\Modules\Monitor\TestResult as TestResult;
8
use \SimpleSAML\Modules\Monitor\DependencyInjection as DependencyInjection;
9
use \SimpleSAML\Modules\Monitor\TestConfiguration as TestConfiguration;
10
use \SimpleSAML\Modules\Monitor\TestSuiteFactory as TestSuiteFactory;
11
use \Tests\SimpleSAML\Modules\Monitor\TestFiles\TestSuiteImplementation as TestSuiteImplementation;
12
13
/**
14
 * Tests for TestSuiteFactory
15
 */
16
class TestSuiteFactoryTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testTestSuiteFactory()
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