Passed
Branch monitor-2.5.x (1a1f16)
by Tim
03:17
created

TestCaseFactory::getTestResult()   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\Modules\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 TestResult
24
     */
25
    private $testResult;
26
27
    /**
28
     * @param TestData $testData
29
     */
30
    public function __construct($testData)
31
    {
32
        assert($testData instanceof TestData);
33
34
        $this->initialize($testData);
35
        $this->invokeTest();
36
    }
37
38
    /**
39
     * @param Testdata $testData
40
     *
41
     * @return void
42
     */
43
    protected function initialize($testData)
44
    {
45
        $this->setTestData($testData);
46
    }
47
48
    /**
49
     * @param string $category
50
     *
51
     * @return void
52
     */
53
    protected function setCategory($category)
54
    {
55
        assert(is_string($category));
56
        $this->category = $category;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getCategory()
63
    {
64
        assert(is_string($this->category));
65
        return $this->category;
66
    }
67
68
    /**
69
     * @return TestData|null
70
     */
71
    public function getTestData()
72
    {
73
        assert($this->testData instanceof TestData || is_null($this->testData));
74
        return $this->testData;
75
    }
76
77
    /**
78
     * @param TestData|null $testData
79
     *
80
     * @return void
81
     */
82
    protected function setTestData($testData = null)
83
    {
84
        assert($testData instanceof TestData || is_null($testData));
85
        if (!is_null($testData)) {
86
            $this->testData = $testData;
87
        }
88
    }
89
90
    /**
91
     * @param TestResult $testResult
92
     *
93
     * @return void
94
     */
95
    protected function setTestResult($testResult)
96
    {
97
        assert($testResult instanceof TestResult);
98
        $this->testResult = $testResult;
99
    }
100
101
    /**
102
     * @return TestResult
103
     */
104
    public function getTestResult()
105
    {
106
        assert($this->testResult instanceof TestResult);
107
        return $this->testResult;
108
    }
109
110
    /**
111
     * @param string $subject
112
     *
113
     * @return void
114
     */
115
    protected function setSubject($subject)
116
    {
117
        assert(is_string($subject));
118
        $this->subject = $subject;
119
    }
120
121
    /**
122
     * @return string
123
     */
124
    public function getSubject()
125
    {
126
        assert(is_string($this->subject));
127
        return $this->subject;
128
    }
129
130
    abstract public function invokeTest();
131
}
132