Completed
Push — master ( 48b4f6...095d9f )
by Tim
11:31
created

TestCaseFactory::setTestSuite()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleSAML\Module\monitor;
4
5
abstract class TestCaseFactory extends TestFactory
6
{
7
    /**
8
     * @var TestSuiteFactory|null
9
     */
10
    private $testSuite = null;
11
12
    /**
13
     * @var TestResult|null
14
     */
15
    private $testResult = null;
16
17
    /**
18
     * @var string|null
19
     */
20
    private $category = null;
21
22
    /**
23
     * @var string|null
24
     */
25
    private $subject = null;
26
27
    /**
28
     * @param TestSuiteFactory|null $testSuite
29
     * @param TestData $testData
30
     */
31
    public function __construct($testSuite = null, $testData)
32
    {
33
        assert($testSuite instanceof TestSuiteFactory);
34
        assert($testData instanceof TestData);
35
36
        $this->setTestSuite($testSuite);
37
        $this->initialize($testData);
38
        $this->invokeTest();
39
    }
40
41
    /**
42
     * @param Testdata $testData
43
     *
44
     * @return void
45
     */
46
    protected function initialize($testData)
47
    {
48
        $this->setTestData($testData);
49
    }
50
51
    /**
52
     * @param TestSuiteFactory $testSuite
53
     *
54
     * @return void
55
     */
56
    private function setTestSuite($testSuite)
57
    {
58
        assert($testSuite instanceof TestSuiteFactory);
59
        $this->testSuite = $testSuite;
60
    }
61
62
63
    /**
64
     * @return TestSuiteFactory
65
     */
66
    public function getTestSuite()
67
    {
68
        assert($this->testSuite instanceof TestSuiteFactory);
69
        return $this->testSuite;
70
    }
71
72
73
    /**
74
     * @param TestResult $testResult
75
     *
76
     * @return void
77
     */
78
    private function setTestResult($testResult)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
79
    {
80
        assert($testResult instanceof TestResult);
81
        $this->testResult = $testResult;
82
    }
83
84
85
    /**
86
     * @return TestResult
87
     */
88
    public function getTestResult()
89
    {
90
        assert($this->testResult instanceof TestResult);
91
        return $this->testResult;
92
    }
93
94
95
    /**
96
     * @param string $subject
97
     *
98
     * @return void
99
     */
100
    protected function setSubject($subject)
101
    {
102
        assert(is_string($subject));
103
        $this->subject = $subject;
104
    }
105
106
107
    /**
108
     * @return string
109
     */
110
    public function getSubject()
111
    {
112
        assert(is_string($this->subject));
113
        return $this->subject;
114
    }
115
116
117
    /**
118
     * @param string $category
119
     *
120
     * @return void
121
     */
122
    protected function setCategory($category)
123
    {
124
        assert(is_string($category));
125
        $this->category = $category;
126
    }
127
128
129
    /**
130
     * @return string
131
     */
132
    public function getCategory()
133
    {
134
        assert(is_string($this->category));
135
        return $this->category;
136
    }
137
138
    
139
    /**
140
     * @return void
141
     */
142
    abstract protected function invokeTest();
143
}
144