1 | <?php |
||
34 | class SemanticScribuntoJsonTestCaseScriptRunnerTest extends JsonTestCaseScriptRunner { |
||
35 | |||
36 | /** |
||
37 | * @var SemanticDataValidator |
||
38 | */ |
||
39 | private $semanticDataValidator; |
||
40 | |||
41 | /** |
||
42 | * @var StringValidator |
||
43 | */ |
||
44 | private $stringValidator; |
||
45 | |||
46 | /** |
||
47 | * @var HookRegistry |
||
48 | */ |
||
49 | private $hookRegistry; |
||
50 | |||
51 | protected function setUp() { |
||
64 | |||
65 | /** |
||
66 | * @see JsonTestCaseScriptRunner::getRequiredJsonTestCaseMinVersion |
||
67 | * @return string |
||
68 | */ |
||
69 | protected function getRequiredJsonTestCaseMinVersion() { |
||
72 | |||
73 | /** |
||
74 | * @see JsonTestCaseScriptRunner::getTestCaseLocation |
||
75 | * @return string |
||
76 | */ |
||
77 | protected function getTestCaseLocation() { |
||
80 | |||
81 | /** |
||
82 | * Returns a list of files, an empty list is a sign to run all registered |
||
83 | * tests. |
||
84 | * |
||
85 | * @see JsonTestCaseScriptRunner::getListOfAllowedTestCaseFiles |
||
86 | */ |
||
87 | protected function getAllowedTestCaseFiles() { |
||
90 | |||
91 | /** |
||
92 | * @see JsonTestCaseScriptRunner::getPermittedSettings |
||
93 | */ |
||
94 | protected function getPermittedSettings() { |
||
106 | |||
107 | /** |
||
108 | * @see JsonTestCaseScriptRunner::runTestCaseFile |
||
109 | * |
||
110 | * @param JsonTestCaseFileHandler $jsonTestCaseFileHandler |
||
111 | */ |
||
112 | protected function runTestCaseFile( JsonTestCaseFileHandler $jsonTestCaseFileHandler ) { |
||
122 | |||
123 | /** |
||
124 | * @param JsonTestCaseFileHandler $jsonTestCaseFileHandler |
||
125 | */ |
||
126 | private function doRunParserTests( JsonTestCaseFileHandler $jsonTestCaseFileHandler ) { |
||
140 | |||
141 | /** |
||
142 | * Prepares the test case: setting of global configuration changes (json section "settings", |
||
143 | * creation of defined pages (json section "setup") |
||
144 | * |
||
145 | * @param JsonTestCaseFileHandler $jsonTestCaseFileHandler |
||
146 | */ |
||
147 | private function prepareTest( JsonTestCaseFileHandler $jsonTestCaseFileHandler ) { |
||
164 | |||
165 | /** |
||
166 | * Assert the SemanticData object if available after a entity/page has been |
||
167 | * created. |
||
168 | * |
||
169 | * ``` |
||
170 | * "assert-store": { |
||
171 | * "semantic-data": { |
||
172 | * "strictPropertyValueMatch": false, |
||
173 | * "propertyCount": 4, |
||
174 | * "propertyKeys": [ |
||
175 | * "Testproperty1", |
||
176 | * "Testproperty2", |
||
177 | * "_SKEY", |
||
178 | * "_MDAT" |
||
179 | * ], |
||
180 | * "propertyValues": [ |
||
181 | * "200" |
||
182 | * ], |
||
183 | * "inproperty-keys": [ |
||
184 | * "roperty1", |
||
185 | * "EY", |
||
186 | * ], |
||
187 | * "inproperty-values": [ |
||
188 | * "Test Ca", |
||
189 | * "00", |
||
190 | * ] |
||
191 | * } |
||
192 | * ``` |
||
193 | * @param array $case |
||
194 | * @param bool $debugMode |
||
195 | */ |
||
196 | private function assertSemanticDataForCase( array $case, $debugMode ) { |
||
238 | |||
239 | /** |
||
240 | * Assert the text content if available from the parse process and |
||
241 | * accessible using the ParserOutput object. |
||
242 | * |
||
243 | * ``` |
||
244 | * "assert-output": { |
||
245 | * "to-contain": [ |
||
246 | * "Foo" |
||
247 | * ], |
||
248 | * "not-contain": [ |
||
249 | * "Bar" |
||
250 | * ] |
||
251 | * } |
||
252 | * ``` |
||
253 | * @param array $case |
||
254 | */ |
||
255 | private function assertParserOutputForCase( array $case ) { |
||
285 | |||
286 | /** |
||
287 | * @param DIWikiPage $subject |
||
288 | * @param array $semanticdata |
||
289 | * @param string $about |
||
290 | */ |
||
291 | private function assertInProperties( DIWikiPage $subject, array $semanticdata, $about ) { |
||
335 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: