1 | <?php |
||
5 | class SaveOnFailure implements \PHPUnit\Framework\TestListener |
||
6 | { |
||
7 | /** |
||
8 | * Convert an attribute strigng from a relative to absolute, by providing a base_url. |
||
9 | * |
||
10 | * @param string $attribute name of the attribute, e.g. src, href |
||
11 | * @param string $content the string where to do the change |
||
12 | * @param string $base_url |
||
13 | * |
||
14 | * @return string |
||
15 | */ |
||
16 | 8 | public static function to_absolute_attribute($attribute, $content, $base_url = null) |
|
20 | |||
21 | /** |
||
22 | * Check if a directory does not exist, create it, otherwise check if it is writable. |
||
23 | * |
||
24 | * @param string $directory |
||
25 | * |
||
26 | * @throws Exception If directory is not writable |
||
27 | */ |
||
28 | 2 | public static function autocreate_directory($directory) |
|
38 | |||
39 | /** |
||
40 | * Delete all the files from a directory. |
||
41 | * |
||
42 | * @param string $directory |
||
43 | */ |
||
44 | 2 | public static function clear_directory($directory) |
|
52 | |||
53 | /** |
||
54 | * Execute a php script and get the output of that script as a string, optionally pass variables as an associative array to be converted to local variables inside of the file. |
||
55 | * |
||
56 | * @param string $filename |
||
57 | * @param array $data |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 1 | public static function render_file($filename, array $data = []) |
|
70 | |||
71 | protected $_directory; |
||
72 | protected $_base_url; |
||
73 | |||
74 | 1 | public function __construct($directory, $base_url) |
|
86 | |||
87 | /** |
||
88 | * Save the current content of the driver into an html file. Add javascript errors, messages and a title to the html content. |
||
89 | * |
||
90 | * @param \Openbuildings\Spiderling\Driver $driver |
||
91 | * @param string $filename |
||
92 | * @param string $title |
||
93 | */ |
||
94 | 1 | public function save_driver_content(\Openbuildings\Spiderling\Driver $driver, $filename, $title) |
|
118 | |||
119 | /** |
||
120 | * Implement PHPUnit\Framework\TestListener, save driver content if there was an error. |
||
121 | * |
||
122 | * @param \PHPUnit\Framework\Test $test |
||
123 | * @param \Exception $exception |
||
124 | * @param int $time |
||
125 | */ |
||
126 | 1 | public function addError(\PHPUnit\Framework\Test $test, \Exception $exception, $time) |
|
136 | |||
137 | /** |
||
138 | * Implement PHPUnit\Framework\TestListener, save driver content if there was an error. |
||
139 | * |
||
140 | * @param \PHPUnit\Framework\Test $test |
||
141 | * @param \PHPUnit\Framework\AssertionFailedError $failure |
||
142 | * @param int $time |
||
143 | */ |
||
144 | 1 | public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $failure, $time) |
|
154 | |||
155 | // @codeCoverageIgnoreStart |
||
156 | public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, $time) |
||
159 | |||
160 | public function addRiskyTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) |
||
163 | |||
164 | public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) |
||
167 | |||
168 | public function addSkippedTest(\PHPUnit\Framework\Test $test, \Exception $e, $time) |
||
171 | |||
172 | public function startTest(\PHPUnit\Framework\Test $test) |
||
175 | |||
176 | public function endTest(\PHPUnit\Framework\Test $test, $time) |
||
179 | |||
180 | public function startTestSuite(\PHPUnit\Framework\TestSuite $suite) |
||
183 | |||
184 | public function endTestSuite(\PHPUnit\Framework\TestSuite $suite) |
||
187 | |||
188 | // @codeCoverageIgnoreEnd |
||
189 | } |
||
190 |