Completed
Branch master (d4e26c)
by Tim
01:59
created

TestCaseFactory::getCategory()   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 0
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 implements TestInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    private $category;
11
12
    /**
13
     * @var string
14
     */
15
    private $subject;
16
17
    /**
18
     * @var TestData
19
     */
20
    private $testData;
21
22
    /**
23
     * @var TestConfiguration
24
     * @deprecated
25
     */
26
    private $configuration;
27
28
    /**
29
     * @var TestResult
30
     */
31
    private $testResult;
32
33
    /**
34
     * @var TestSuiteFactory
35
     * @deprecated
36
     */
37
    private $testSuite;
38
39
    /**
40
     * @param TestSuiteFactory $testSuite
41
     * @param TestData $testData
42
     */
43
    public function __construct($testSuite, $testData)
44
    {
45
        assert($testSuite instanceof TestSuiteFactory);
46
        assert($testData instanceof TestData);
47
48
        $this->setTestSuite($testSuite);
49
        $this->initialize($testData);
50
        $this->invokeTest();
51
    }
52
53
    /**
54
     * @param Testdata $testData
55
     *
56
     * @return void
57
     */
58
    protected function initialize($testData)
59
    {
60
        $this->setTestData($testData);
61
    }
62
63
    /**
64
     * @param TestSuiteFactory $testSuite
65
     *
66
     * @return void
67
     */
68
    private function setTestSuite($testSuite)
69
    {
70
        assert($testSuite instanceof TestSuiteFactory);
71
        $this->testSuite = $testSuite;
0 ignored issues
show
Deprecated Code introduced by
The property SimpleSAML\Module\monito...CaseFactory::$testSuite has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
72
    }
73
74
    /**
75
     * @return TestSuiteFactory
76
     */
77
    protected function getTestSuite()
78
    {
79
        assert($this->testSuite instanceof TestSuiteFactory);
0 ignored issues
show
Deprecated Code introduced by
The property SimpleSAML\Module\monito...CaseFactory::$testSuite has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
80
        return $this->testSuite;
0 ignored issues
show
Deprecated Code introduced by
The property SimpleSAML\Module\monito...CaseFactory::$testSuite has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
81
    }
82
83
    /**
84
     * @param string $category
85
     *
86
     * @return void
87
     */
88
    protected function setCategory($category)
89
    {
90
        assert(is_string($category));
91
        $this->category = $category;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getCategory()
98
    {
99
        assert(is_string($this->category));
100
        return $this->category;
101
    }
102
103
    /**
104
     * @param TestConfiguration|null $configuration
105
     *
106
     * @return void
107
     */
108
    protected function setConfiguration($configuration = null)
109
    {
110
        assert($configuration instanceof TestConfiguration);
111
        if (!is_null($configuration)) {
112
            $this->configuration = $configuration;
0 ignored issues
show
Deprecated Code introduced by
The property SimpleSAML\Module\monito...Factory::$configuration has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
113
        }
114
    }
115
116
    /**
117
     * @return TestConfiguration
118
     */
119
    public function getConfiguration()
120
    {
121
        assert($this->configuration instanceof TestConfiguration);
0 ignored issues
show
Deprecated Code introduced by
The property SimpleSAML\Module\monito...Factory::$configuration has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
122
        return $this->configuration;
0 ignored issues
show
Deprecated Code introduced by
The property SimpleSAML\Module\monito...Factory::$configuration has been deprecated.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
123
    }
124
125
    /**
126
     * @return TestData|null
127
     */
128
    public function getTestData()
129
    {
130
        assert($this->testData instanceof TestData || is_null($this->testData));
131
        return $this->testData;
132
    }
133
134
    /**
135
     * @param TestData|null $testData
136
     *
137
     * @return void
138
     */
139
    protected function setTestData($testData = null)
140
    {
141
        assert($testData instanceof TestData || is_null($testData));
142
        if (!is_null($testData)) {
143
            $this->testData = $testData;
144
        }
145
    }
146
147
    /**
148
     * @param TestResult $testResult
149
     *
150
     * @return void
151
     */
152
    protected function setTestResult($testResult)
153
    {
154
        assert($testResult instanceof TestResult);
155
        $this->testResult = $testResult;
156
    }
157
158
    /**
159
     * @return TestResult
160
     */
161
    public function getTestResult()
162
    {
163
        assert($this->testResult instanceof TestResult);
164
        return $this->testResult;
165
    }
166
167
    /**
168
     * @param string $subject
169
     *
170
     * @return void
171
     */
172
    protected function setSubject($subject)
173
    {
174
        assert(is_string($subject));
175
        $this->subject = $subject;
176
    }
177
178
    /**
179
     * @return string
180
     */
181
    public function getSubject()
182
    {
183
        assert(is_string($this->subject));
184
        return $this->subject;
185
    }
186
187
    abstract public function invokeTest();
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
188
}
189