Passed
Push — master ( a81e8f...fa2ff0 )
by Tim
01:51
created

TestSuiteInstance   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _dummy() 0 10 1
A invokeTest() 0 4 1
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 = ['travis'];
18
        $testData = new TestData([]);
19
        $testSuite = new TestSuiteInstance($config, $testData);
0 ignored issues
show
Bug introduced by
$config of type array<integer,string> is incompatible with the type null|SimpleSAML\Module\monitor\TestConfiguration expected by parameter $configuration of SimpleSAML\Module\monito...Instance::__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
        $testSuite = new TestSuiteInstance(/** @scrutinizer ignore-type */ $config, $testData);
Loading history...
20
        $results = $testSuite->_dummy();
21
22
        $this->assertEquals($config, $testSuite->getConfiguration());
23
        $this->assertEquals($results, $testSuite->getTestResults());
24
        $this->assertEquals([
25
            ['state' => State::NOSTATE, 'category' => 'a', 'subject' => 'b', 'message' => ''],
26
            ['state' => State::NOSTATE, 'category' => 'c', 'subject' => 'd', 'message' => ''],
27
            ['state' => State::NOSTATE, 'category' => 'e', 'subject' => 'f', 'message' => ''],
28
        ], $testSuite->getArrayizeTestResults());
29
30
        $this->assertEquals('travis', $testSuite->getCategory());
31
        $this->assertEquals('travis', $testSuite->getSubject());
32
33
        $this->assertEquals(State::NOSTATE, $testSuite->calculateState());
34
    }
35
}
36
37
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...
38
{
39
    public function _dummy()
40
    {
41
        $a = new TestResult('a', 'b');
42
        $b = new TestResult('c', 'd');
43
        $c = new TestResult('e', 'f');
44
45
        $this->addTestResults([$a, $b]);
46
        $this->addTestResult($c);
47
48
        return [$a, $b, $c];
49
    }
50
51
    public function invokeTest()
52
    {
53
        $this->setCategory('travis');
54
        $this->setSubject('travis');
55
    }
56
}
57