1 | <?php |
||
18 | abstract class BaseTestCase extends \PHPUnit_Framework_TestCase |
||
19 | { |
||
20 | private $expectException = false; |
||
21 | |||
22 | /** |
||
23 | * Wraps the default #runTest() method to provide an exception hook. |
||
24 | * |
||
25 | * @return mixed|null |
||
26 | * |
||
27 | * @throws \Exception |
||
28 | */ |
||
29 | 617 | protected function runTest() |
|
47 | |||
48 | /** |
||
49 | * Sets the flag indicating that an exception is expected. |
||
50 | */ |
||
51 | 61 | protected function expectException() |
|
55 | |||
56 | /** |
||
57 | * @codeCoverageIgnore (shouldn't happen in a green test suite) |
||
58 | * |
||
59 | * Hook called when an unexpected exception is thrown. |
||
60 | * |
||
61 | * Override this hook to make custom assertions on exceptions. |
||
62 | * |
||
63 | * @param \Exception $ex |
||
64 | * |
||
65 | * @throws \Exception |
||
66 | */ |
||
67 | protected function exceptionHook(\Exception $ex) |
||
71 | |||
72 | /** |
||
73 | * Returns the JSON-decoded content of a file. |
||
74 | * |
||
75 | * @param string $file |
||
76 | * |
||
77 | * @return mixed |
||
78 | */ |
||
79 | 93 | protected function loadJsonFromFile($file) |
|
83 | |||
84 | /** |
||
85 | * Returns a JSON-decoded schema from tests/Data/schemas. |
||
86 | * |
||
87 | * @param string $name Name of the file without the extension |
||
88 | * |
||
89 | * @return mixed |
||
90 | */ |
||
91 | 93 | protected function loadSchema($name) |
|
97 | |||
98 | /** |
||
99 | * Asserts the validation results equal the expected one and make |
||
100 | * a full report otherwise. |
||
101 | * |
||
102 | * @param string $file |
||
103 | * @param string $title |
||
104 | * @param mixed $instance |
||
105 | * @param \stdClass $schema |
||
106 | * @param bool $isInstanceValid |
||
107 | * @param array $expectedErrors |
||
108 | * @param array $actualErrors |
||
109 | */ |
||
110 | 478 | protected function assertValidationResult( |
|
135 | |||
136 | /** |
||
137 | * Returns a mock object, bypassing original constructor. |
||
138 | * |
||
139 | * @param string $class |
||
140 | * |
||
141 | * @return \PHPUnit_Framework_MockObject_MockObject |
||
142 | */ |
||
143 | 83 | protected function mock($class) |
|
149 | |||
150 | /** |
||
151 | * Returns URI to local file system. |
||
152 | * |
||
153 | * @param string $path |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | 298 | protected function getLocalUri($path) |
|
165 | |||
166 | /** |
||
167 | * @codeCoverageIgnore (cannot cover code whose behaviour depends on PHP version) |
||
168 | * |
||
169 | * @param mixed $variable |
||
170 | * |
||
171 | * @return string |
||
172 | */ |
||
173 | private function dump($variable) |
||
191 | |||
192 | 153 | private function assertHasError(array $errors, array $reportParameters) |
|
200 | |||
201 | 325 | private function assertErrorsAreEqual(array $actual, array $expected, array $reportParameters) |
|
219 | |||
220 | 325 | private function getFailureReportMask() |
|
240 | } |
||
241 |