1 | <?php |
||
17 | trait AssertThrows |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * Asserts that callback throws an exception |
||
22 | * |
||
23 | * @param callable $callable |
||
24 | * @param $throws |
||
25 | * |
||
26 | * @throws Exception |
||
27 | */ |
||
28 | public function assertThrows(callable $callable, $throws) |
||
32 | |||
33 | /** |
||
34 | * Asserts that callback throws an exception with a message |
||
35 | * |
||
36 | * @param callable $callback |
||
37 | * @param $throws |
||
38 | * @param $message |
||
39 | * |
||
40 | * @throws Exception |
||
41 | */ |
||
42 | public function assertThrowsWithMessage(callable $callback, $throws, $message) |
||
76 | |||
77 | /** |
||
78 | * @param Exception $exception |
||
79 | * @param string|bool $expectedMsg |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | private function exceptionMessageDoesNotMatchExpected(Exception $exception, $expectedMsg) : bool |
||
87 | |||
88 | /** |
||
89 | * @param $throws |
||
90 | * @param $message |
||
91 | */ |
||
92 | private function parseThrows(&$throws, &$message) |
||
101 | |||
102 | /** |
||
103 | * @return TestResult |
||
104 | */ |
||
105 | abstract public function getTestResultObject(); |
||
106 | |||
107 | /** |
||
108 | * Asserts that a condition is true. |
||
109 | * |
||
110 | * @param bool $condition |
||
111 | * @param string $message |
||
112 | * |
||
113 | * @throws AssertionFailedError |
||
114 | */ |
||
115 | abstract public static function assertTrue($condition, $message = ''); |
||
116 | } |
||
117 |