Passed
Push — master ( 6c0a4d...b3ea01 )
by Tim
01:44
created

TestSuiteInstance::invokeTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
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\DependencyInjection as DependencyInjection;
9
use \SimpleSAML\Module\monitor\TestConfiguration as TestConfiguration;
10
use \SimpleSAML\Module\monitor\TestSuiteFactory as TestSuiteFactory;
11
12
/**
13
 * Tests for TestSuiteFactory
14
 */
15
class TestSuiteFactoryTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function testTestSuiteFactory()
18
    {
19
        $config = new TestConfiguration(
20
            new DependencyInjection([]),
21
            new DependencyInjection([]),
22
            \SimpleSAML_Configuration::loadFromArray(['metadata.sources' => []]),
23
            \SimpleSAML_Configuration::loadFromArray([]),
24
            \SimpleSAML_Configuration::loadFromArray([])
25
        );
26
        $testData = new TestData(['travis']);
27
        $testSuite = new TestSuiteInstance($config, $testData);
0 ignored issues
show
Bug introduced by
The type SimpleSAML\Module\monitor\Test\TestSuiteInstance was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
        $this->assertEquals(State::NOSTATE, $testSuite->calculateState());
29
        $this->assertEquals($testData, $testSuite->getTestData());
30
31
        $results = $testSuite->prepareTests();
32
33
        $this->assertEquals($config, $testSuite->getConfiguration());
34
        $this->assertEquals($results, $testSuite->getTestResults());
35
        $this->assertEquals([
36
            ['state' => State::ERROR, 'category' => 'a', 'subject' => 'b', 'message' => ''],
37
            ['state' => State::WARNING, 'category' => 'c', 'subject' => 'd', 'message' => ''],
38
            ['state' => State::OK, 'category' => 'e', 'subject' => 'f', 'message' => ''],
39
        ], $testSuite->getArrayizeTestResults());
40
41
        $this->assertEquals('travis', $testSuite->getCategory());
42
        $this->assertEquals('travis', $testSuite->getSubject());
43
44
        $this->assertEquals(State::ERROR, $testSuite->calculateState());
45
    }
46
}
47