1 | <?php //[STAMP] 8f32029e1b73bcd2cf1109d17c7d8cd3 |
||
11 | trait UnitTesterActions |
||
12 | { |
||
13 | /** |
||
14 | * @return \Codeception\Scenario |
||
15 | */ |
||
16 | abstract protected function getScenario(); |
||
17 | |||
18 | |||
19 | /** |
||
20 | * [!] Method is generated. Documentation taken from corresponding module. |
||
21 | * |
||
22 | * Checks that two variables are equal. |
||
23 | * |
||
24 | * @param $expected |
||
25 | * @param $actual |
||
26 | * @param string $message |
||
27 | * @see \Codeception\Module\Asserts::assertEquals() |
||
28 | */ |
||
29 | public function assertEquals($expected, $actual, $message = null) |
||
30 | { |
||
31 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args())); |
||
32 | } |
||
33 | |||
34 | |||
35 | /** |
||
36 | * [!] Method is generated. Documentation taken from corresponding module. |
||
37 | * |
||
38 | * Checks that two variables are not equal |
||
39 | * |
||
40 | * @param $expected |
||
41 | * @param $actual |
||
42 | * @param string $message |
||
43 | * @see \Codeception\Module\Asserts::assertNotEquals() |
||
44 | */ |
||
45 | public function assertNotEquals($expected, $actual, $message = null) |
||
46 | { |
||
47 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args())); |
||
48 | } |
||
49 | |||
50 | |||
51 | /** |
||
52 | * [!] Method is generated. Documentation taken from corresponding module. |
||
53 | * |
||
54 | * Checks that two variables are same |
||
55 | * |
||
56 | * @param $expected |
||
57 | * @param $actual |
||
58 | * @param string $message |
||
59 | * @return mixed|void |
||
60 | * @see \Codeception\Module\Asserts::assertSame() |
||
61 | */ |
||
62 | public function assertSame($expected, $actual, $message = null) |
||
63 | { |
||
64 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args())); |
||
65 | } |
||
66 | |||
67 | |||
68 | /** |
||
69 | * [!] Method is generated. Documentation taken from corresponding module. |
||
70 | * |
||
71 | * Checks that two variables are not same |
||
72 | * |
||
73 | * @param $expected |
||
74 | * @param $actual |
||
75 | * @param string $message |
||
76 | * @see \Codeception\Module\Asserts::assertNotSame() |
||
77 | */ |
||
78 | public function assertNotSame($expected, $actual, $message = null) |
||
79 | { |
||
80 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args())); |
||
81 | } |
||
82 | |||
83 | |||
84 | /** |
||
85 | * [!] Method is generated. Documentation taken from corresponding module. |
||
86 | * |
||
87 | * Checks that actual is greater than expected |
||
88 | * |
||
89 | * @param $expected |
||
90 | * @param $actual |
||
91 | * @param string $message |
||
92 | * @see \Codeception\Module\Asserts::assertGreaterThan() |
||
93 | */ |
||
94 | public function assertGreaterThan($expected, $actual, $message = null) |
||
95 | { |
||
96 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args())); |
||
97 | } |
||
98 | |||
99 | |||
100 | /** |
||
101 | * [!] Method is generated. Documentation taken from corresponding module. |
||
102 | * |
||
103 | * Checks that actual is greater or equal than expected |
||
104 | * |
||
105 | * @param $expected |
||
106 | * @param $actual |
||
107 | * @param string $message |
||
108 | * @see \Codeception\Module\Asserts::assertGreaterThanOrEqual() |
||
109 | */ |
||
110 | public function assertGreaterThanOrEqual($expected, $actual, $message = null) |
||
111 | { |
||
112 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args())); |
||
113 | } |
||
114 | |||
115 | |||
116 | /** |
||
117 | * [!] Method is generated. Documentation taken from corresponding module. |
||
118 | * |
||
119 | * Checks that actual is less than expected |
||
120 | * |
||
121 | * @param $expected |
||
122 | * @param $actual |
||
123 | * @param string $message |
||
124 | * @see \Codeception\Module\Asserts::assertLessThan() |
||
125 | */ |
||
126 | public function assertLessThan($expected, $actual, $message = null) |
||
127 | { |
||
128 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args())); |
||
129 | } |
||
130 | |||
131 | |||
132 | /** |
||
133 | * [!] Method is generated. Documentation taken from corresponding module. |
||
134 | * |
||
135 | * Checks that actual is less or equal than expected |
||
136 | * |
||
137 | * @param $expected |
||
138 | * @param $actual |
||
139 | * @param string $message |
||
140 | * @see \Codeception\Module\Asserts::assertLessThanOrEqual() |
||
141 | */ |
||
142 | public function assertLessThanOrEqual($expected, $actual, $message = null) |
||
143 | { |
||
144 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args())); |
||
145 | } |
||
146 | |||
147 | |||
148 | /** |
||
149 | * [!] Method is generated. Documentation taken from corresponding module. |
||
150 | * |
||
151 | * Checks that haystack contains needle |
||
152 | * |
||
153 | * @param $needle |
||
154 | * @param $haystack |
||
155 | * @param string $message |
||
156 | * @see \Codeception\Module\Asserts::assertContains() |
||
157 | */ |
||
158 | public function assertContains($needle, $haystack, $message = null) |
||
159 | { |
||
160 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args())); |
||
161 | } |
||
162 | |||
163 | |||
164 | /** |
||
165 | * [!] Method is generated. Documentation taken from corresponding module. |
||
166 | * |
||
167 | * Checks that haystack doesn't contain needle. |
||
168 | * |
||
169 | * @param $needle |
||
170 | * @param $haystack |
||
171 | * @param string $message |
||
172 | * @see \Codeception\Module\Asserts::assertNotContains() |
||
173 | */ |
||
174 | public function assertNotContains($needle, $haystack, $message = null) |
||
175 | { |
||
176 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args())); |
||
177 | } |
||
178 | |||
179 | |||
180 | /** |
||
181 | * [!] Method is generated. Documentation taken from corresponding module. |
||
182 | * |
||
183 | * Checks that string match with pattern |
||
184 | * |
||
185 | * @param string $pattern |
||
186 | * @param string $string |
||
187 | * @param string $message |
||
188 | * @see \Codeception\Module\Asserts::assertRegExp() |
||
189 | */ |
||
190 | public function assertRegExp($pattern, $string, $message = null) |
||
191 | { |
||
192 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertRegExp', func_get_args())); |
||
193 | } |
||
194 | |||
195 | |||
196 | /** |
||
197 | * [!] Method is generated. Documentation taken from corresponding module. |
||
198 | * |
||
199 | * Checks that string not match with pattern |
||
200 | * |
||
201 | * @param string $pattern |
||
202 | * @param string $string |
||
203 | * @param string $message |
||
204 | * @see \Codeception\Module\Asserts::assertNotRegExp() |
||
205 | */ |
||
206 | public function assertNotRegExp($pattern, $string, $message = null) |
||
207 | { |
||
208 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotRegExp', func_get_args())); |
||
209 | } |
||
210 | |||
211 | |||
212 | /** |
||
213 | * [!] Method is generated. Documentation taken from corresponding module. |
||
214 | * |
||
215 | * Checks that variable is empty. |
||
216 | * |
||
217 | * @param $actual |
||
218 | * @param string $message |
||
219 | * @see \Codeception\Module\Asserts::assertEmpty() |
||
220 | */ |
||
221 | public function assertEmpty($actual, $message = null) |
||
222 | { |
||
223 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args())); |
||
224 | } |
||
225 | |||
226 | |||
227 | /** |
||
228 | * [!] Method is generated. Documentation taken from corresponding module. |
||
229 | * |
||
230 | * Checks that variable is not empty. |
||
231 | * |
||
232 | * @param $actual |
||
233 | * @param string $message |
||
234 | * @see \Codeception\Module\Asserts::assertNotEmpty() |
||
235 | */ |
||
236 | public function assertNotEmpty($actual, $message = null) |
||
237 | { |
||
238 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args())); |
||
239 | } |
||
240 | |||
241 | |||
242 | /** |
||
243 | * [!] Method is generated. Documentation taken from corresponding module. |
||
244 | * |
||
245 | * Checks that variable is NULL |
||
246 | * |
||
247 | * @param $actual |
||
248 | * @param string $message |
||
249 | * @see \Codeception\Module\Asserts::assertNull() |
||
250 | */ |
||
251 | public function assertNull($actual, $message = null) |
||
252 | { |
||
253 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args())); |
||
254 | } |
||
255 | |||
256 | |||
257 | /** |
||
258 | * [!] Method is generated. Documentation taken from corresponding module. |
||
259 | * |
||
260 | * Checks that variable is not NULL |
||
261 | * |
||
262 | * @param $actual |
||
263 | * @param string $message |
||
264 | * @see \Codeception\Module\Asserts::assertNotNull() |
||
265 | */ |
||
266 | public function assertNotNull($actual, $message = null) |
||
267 | { |
||
268 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args())); |
||
269 | } |
||
270 | |||
271 | |||
272 | /** |
||
273 | * [!] Method is generated. Documentation taken from corresponding module. |
||
274 | * |
||
275 | * Checks that condition is positive. |
||
276 | * |
||
277 | * @param $condition |
||
278 | * @param string $message |
||
279 | * @see \Codeception\Module\Asserts::assertTrue() |
||
280 | */ |
||
281 | public function assertTrue($condition, $message = null) |
||
282 | { |
||
283 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args())); |
||
284 | } |
||
285 | |||
286 | |||
287 | /** |
||
288 | * [!] Method is generated. Documentation taken from corresponding module. |
||
289 | * |
||
290 | * Checks that condition is negative. |
||
291 | * |
||
292 | * @param $condition |
||
293 | * @param string $message |
||
294 | * @see \Codeception\Module\Asserts::assertFalse() |
||
295 | */ |
||
296 | public function assertFalse($condition, $message = null) |
||
297 | { |
||
298 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args())); |
||
299 | } |
||
300 | |||
301 | |||
302 | /** |
||
303 | * [!] Method is generated. Documentation taken from corresponding module. |
||
304 | * |
||
305 | * Checks if file exists |
||
306 | * |
||
307 | * @param string $filename |
||
308 | * @param string $message |
||
309 | * @see \Codeception\Module\Asserts::assertFileExists() |
||
310 | */ |
||
311 | public function assertFileExists($filename, $message = null) |
||
312 | { |
||
313 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileExists', func_get_args())); |
||
314 | } |
||
315 | |||
316 | |||
317 | /** |
||
318 | * [!] Method is generated. Documentation taken from corresponding module. |
||
319 | * |
||
320 | * Checks if file doesn't exist |
||
321 | * |
||
322 | * @param string $filename |
||
323 | * @param string $message |
||
324 | * @see \Codeception\Module\Asserts::assertFileNotExists() |
||
325 | */ |
||
326 | public function assertFileNotExists($filename, $message = null) |
||
327 | { |
||
328 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFileNotExists', func_get_args())); |
||
329 | } |
||
330 | |||
331 | |||
332 | /** |
||
333 | * [!] Method is generated. Documentation taken from corresponding module. |
||
334 | * |
||
335 | * @param $expected |
||
336 | * @param $actual |
||
337 | * @param $description |
||
338 | * @see \Codeception\Module\Asserts::assertGreaterOrEquals() |
||
339 | */ |
||
340 | public function assertGreaterOrEquals($expected, $actual, $description = null) |
||
341 | { |
||
342 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args())); |
||
343 | } |
||
344 | |||
345 | |||
346 | /** |
||
347 | * [!] Method is generated. Documentation taken from corresponding module. |
||
348 | * |
||
349 | * @param $expected |
||
350 | * @param $actual |
||
351 | * @param $description |
||
352 | * @see \Codeception\Module\Asserts::assertLessOrEquals() |
||
353 | */ |
||
354 | public function assertLessOrEquals($expected, $actual, $description = null) |
||
355 | { |
||
356 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args())); |
||
357 | } |
||
358 | |||
359 | |||
360 | /** |
||
361 | * [!] Method is generated. Documentation taken from corresponding module. |
||
362 | * |
||
363 | * @param $actual |
||
364 | * @param $description |
||
365 | * @see \Codeception\Module\Asserts::assertIsEmpty() |
||
366 | */ |
||
367 | public function assertIsEmpty($actual, $description = null) |
||
368 | { |
||
369 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args())); |
||
370 | } |
||
371 | |||
372 | |||
373 | /** |
||
374 | * [!] Method is generated. Documentation taken from corresponding module. |
||
375 | * |
||
376 | * @param $key |
||
377 | * @param $actual |
||
378 | * @param $description |
||
379 | * @see \Codeception\Module\Asserts::assertArrayHasKey() |
||
380 | */ |
||
381 | public function assertArrayHasKey($key, $actual, $description = null) |
||
382 | { |
||
383 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args())); |
||
384 | } |
||
385 | |||
386 | |||
387 | /** |
||
388 | * [!] Method is generated. Documentation taken from corresponding module. |
||
389 | * |
||
390 | * @param $key |
||
391 | * @param $actual |
||
392 | * @param $description |
||
393 | * @see \Codeception\Module\Asserts::assertArrayNotHasKey() |
||
394 | */ |
||
395 | public function assertArrayNotHasKey($key, $actual, $description = null) |
||
396 | { |
||
397 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args())); |
||
398 | } |
||
399 | |||
400 | |||
401 | /** |
||
402 | * [!] Method is generated. Documentation taken from corresponding module. |
||
403 | * |
||
404 | * @param $class |
||
405 | * @param $actual |
||
406 | * @param $description |
||
407 | * @see \Codeception\Module\Asserts::assertInstanceOf() |
||
408 | */ |
||
409 | public function assertInstanceOf($class, $actual, $description = null) |
||
410 | { |
||
411 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args())); |
||
412 | } |
||
413 | |||
414 | |||
415 | /** |
||
416 | * [!] Method is generated. Documentation taken from corresponding module. |
||
417 | * |
||
418 | * @param $class |
||
419 | * @param $actual |
||
420 | * @param $description |
||
421 | * @see \Codeception\Module\Asserts::assertNotInstanceOf() |
||
422 | */ |
||
423 | public function assertNotInstanceOf($class, $actual, $description = null) |
||
424 | { |
||
425 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args())); |
||
426 | } |
||
427 | |||
428 | |||
429 | /** |
||
430 | * [!] Method is generated. Documentation taken from corresponding module. |
||
431 | * |
||
432 | * @param $type |
||
433 | * @param $actual |
||
434 | * @param $description |
||
435 | * @see \Codeception\Module\Asserts::assertInternalType() |
||
436 | */ |
||
437 | public function assertInternalType($type, $actual, $description = null) |
||
438 | { |
||
439 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args())); |
||
440 | } |
||
441 | |||
442 | |||
443 | /** |
||
444 | * [!] Method is generated. Documentation taken from corresponding module. |
||
445 | * |
||
446 | * Fails the test with message. |
||
447 | * |
||
448 | * @param $message |
||
449 | * @see \Codeception\Module\Asserts::fail() |
||
450 | */ |
||
451 | public function fail($message) |
||
452 | { |
||
453 | return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); |
||
454 | } |
||
455 | |||
456 | |||
457 | /** |
||
458 | * [!] Method is generated. Documentation taken from corresponding module. |
||
459 | * |
||
460 | * Handles and checks exception called inside callback function. |
||
461 | * Either exception class name or exception instance should be provided. |
||
462 | * |
||
463 | * ```php |
||
464 | * <?php |
||
465 | * $I->expectException(MyException::class, function() { |
||
466 | * $this->doSomethingBad(); |
||
467 | * }); |
||
468 | * |
||
469 | * $I->expectException(new MyException(), function() { |
||
470 | * $this->doSomethingBad(); |
||
471 | * }); |
||
472 | * ``` |
||
473 | * If you want to check message or exception code, you can pass them with exception instance: |
||
474 | * ```php |
||
475 | * <?php |
||
476 | * // will check that exception MyException is thrown with "Don't do bad things" message |
||
477 | * $I->expectException(new MyException("Don't do bad things"), function() { |
||
478 | * $this->doSomethingBad(); |
||
479 | * }); |
||
480 | * ``` |
||
481 | * |
||
482 | * @param $exception string or \Exception |
||
483 | * @param $callback |
||
484 | * @see \Codeception\Module\Asserts::expectException() |
||
485 | */ |
||
486 | public function expectException($exception, $callback) |
||
487 | { |
||
488 | return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args())); |
||
489 | } |
||
490 | } |
||
491 |