1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use PHPUnit\Framework\Assert; |
4
|
|
|
use PHPUnit\Framework\Constraint\Exception as ConstraintException; |
5
|
|
|
use PHPUnit\Framework\Constraint\ExceptionMessage as ConstraintExceptionMessage; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Inherited Methods |
9
|
|
|
* @method void wantToTest($text) |
10
|
|
|
* @method void wantTo($text) |
11
|
|
|
* @method void execute($callable) |
12
|
|
|
* @method void expectTo($prediction) |
13
|
|
|
* @method void expect($prediction) |
14
|
|
|
* @method void amGoingTo($argumentation) |
15
|
|
|
* @method void am($role) |
16
|
|
|
* @method void lookForwardTo($achieveValue) |
17
|
|
|
* @method void comment($description) |
18
|
|
|
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) |
19
|
|
|
* |
20
|
|
|
* @SuppressWarnings(PHPMD) |
21
|
|
|
*/ |
22
|
|
|
class UnitTester extends \Codeception\Actor |
23
|
|
|
{ |
24
|
|
|
use _generated\UnitTesterActions; |
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param string $contents |
28
|
|
|
*/ |
29
|
|
|
public function dumpFile($contents) |
30
|
|
|
{ |
31
|
|
|
$name = preg_replace('/[^\w\d]/s', '-', $this->scenario->getFeature()); |
32
|
|
|
|
33
|
|
|
file_put_contents(dirname(__DIR__) . "/_output/mail.{$name}.txt", $contents); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param string $type |
38
|
|
|
* @param string|callable $message_or_function |
39
|
|
|
* @param callable|null $function |
40
|
|
|
*/ |
41
|
|
|
public function assertException(string $type, $message_or_function, ?callable $function = null) |
42
|
|
|
{ |
43
|
|
|
if (func_num_args() === 3) { |
44
|
|
|
$message = $message_or_function; |
45
|
|
|
} else { // 2 args |
46
|
|
|
$message = null; |
47
|
|
|
$function = $message_or_function; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$exception = null; |
51
|
|
|
|
52
|
|
|
try { |
53
|
|
|
call_user_func($function); |
|
|
|
|
54
|
|
|
} catch (Exception $e) { |
55
|
|
|
$exception = $e; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$exception_type = $exception ? get_class($exception) : 'null'; |
59
|
|
|
|
60
|
|
|
Assert::assertThat( |
61
|
|
|
$exception, |
62
|
|
|
new ConstraintException($type), |
63
|
|
|
$exception_type . " NOT EQUAL TO " . $type |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
if ($message !== null) { |
67
|
|
|
Assert::assertThat( |
68
|
|
|
$exception, |
69
|
|
|
new ConstraintExceptionMessage($message) |
70
|
|
|
); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths