Passed
Push — master ( 2daa70...c11796 )
by Tim
01:49
created

TestSuiteInstance::resetTestResults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
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\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
            [],
0 ignored issues
show
Bug introduced by
array() of type array is incompatible with the type SimpleSAML\Module\monitor\DependencyInjection expected by parameter $serverVars of SimpleSAML\Module\monito...guration::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
            /** @scrutinizer ignore-type */ [],
Loading history...
20
            [],
0 ignored issues
show
Bug introduced by
array() of type array is incompatible with the type SimpleSAML\Module\monitor\DependencyInjection expected by parameter $requestVars of SimpleSAML\Module\monito...guration::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

20
            /** @scrutinizer ignore-type */ [],
Loading history...
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
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...
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