Passed
Push — master ( da9862...af1c4f )
by Tim
02:29
created

TestSuiteFactoryTest::testTestSuiteFactory()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 17
nc 1
nop 0
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
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\TestSuiteFactory as TestSuiteFactory;
9
10
/**
11
 * Tests for TestSuiteFactory
12
 */
13
class TestSuiteFactoryTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testTestSuiteFactory()
16
    {
17
        $config = new TestConfiguration(
18
            [],
19
            [],
20
            \SimpleSAML_Configuration::loadFromArray(['metadata.sources' => []]),
21
            \SimpleSAML_Configuration::loadFromArray([]),
22
            \SimpleSAML_Configuration::loadFromArray([])
23
        );
24
        $testData = new TestData([]);
25
        $testSuite = new TestSuiteInstance($config, $testData);
26
        $results = $testSuite->_dummy();
27
28
        $this->assertEquals($config, $testSuite->getConfiguration());
29
        $this->assertEquals($results, $testSuite->getTestResults());
30
        $this->assertEquals([
31
            ['state' => State::NOSTATE, 'category' => 'a', 'subject' => 'b', 'message' => ''],
32
            ['state' => State::NOSTATE, 'category' => 'c', 'subject' => 'd', 'message' => ''],
33
            ['state' => State::NOSTATE, 'category' => 'e', 'subject' => 'f', 'message' => ''],
34
        ], $testSuite->getArrayizeTestResults());
35
36
        $this->assertEquals('travis', $testSuite->getCategory());
37
        $this->assertEquals('travis', $testSuite->getSubject());
38
39
        $this->assertEquals(State::NOSTATE, $testSuite->calculateState());
40
    }
41
}
42
43
class TestSuiteInstance extends TestSuiteFactory
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
44
{
45
    public function _dummy()
46
    {
47
        $a = new TestResult('a', 'b');
48
        $b = new TestResult('c', 'd');
49
        $c = new TestResult('e', 'f');
50
51
        $this->addTestResults([$a, $b]);
52
        $this->addTestResult($c);
53
54
        return [$a, $b, $c];
55
    }
56
57
    public function invokeTest()
58
    {
59
        $this->setCategory('travis');
60
        $this->setSubject('travis');
61
    }
62
}
63