Completed
Push — master ( ed2a4c...b58772 )
by Tim
01:40
created

TestSuiteFactory::invokeTestSuite()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
nc 1
dl 0
loc 1
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleSAML\Module\monitor;
4
5
abstract class TestSuiteFactory extends TestFactory
6
{
7
    /**
8
     * @var array|null
9
     */
10
    private $tests = null;
11
12
    /**
13
     * @param TestConfiguration|null $configuration
14
     * @param TestData|null $testData
15
     */
16
    public function __construct($configuration = null, $testData = null)
17
    {
18
        assert($configuration instanceof TestConfiguration || is_null($configuration));
19
20
        $this->setConfiguration($configuration);
21
        $this->initialize($testData);
22
        $this->invokeTestSuite();
23
    }
24
25
26
    /**
27
     * @param TestData|null $testData
28
     *
29
     * @return void
30
     */
31
    protected function initialize($testData = null)
0 ignored issues
show
Unused Code introduced by
The parameter $testData is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
    }
34
35
    /**
36
     * @param TestFactory $test
37
     *
38
     * @return void
39
     */
40
    protected function addTest($test)
41
    {
42
        assert($test instanceof TestFactory);
43
        $this->tests[] = $test;
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    public function getTests()
50
    {
51
        assert(is_array($this->tests));
52
        return $this->tests;
53
    }
54
55
    /**
56
     * @return void
57
     */
58
    protected function calculateState()
59
    {
60
        $tests = $this->getTests();
61
62
        if (!empty($tests)) {
63
            $overall = array();
64
            foreach ($tests as $test) {
65
                $overall[] = $test->getState();
66
            }
67
            $this->setState(min($overall));
68
        }
69
    }
70
71
    /**
72
     * @return void
73
     */
74
    abstract protected function invokeTestSuite();
75
}
76