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 | * @param string $attribute name of the attribute, e.g. src, href |
||
10 | * @param string $content the string where to do the change |
||
11 | * @param string $base_url |
||
12 | * @return string |
||
13 | */ |
||
14 | public static function to_absolute_attribute($attribute, $content, $base_url = NULL) |
||
18 | |||
19 | /** |
||
20 | * Check if a directory does not exist, create it, otherwise check if it is writable |
||
21 | * @param string $directory |
||
22 | * @throws Exception If directory is not writable |
||
23 | */ |
||
24 | public static function autocreate_directory($directory) |
||
34 | |||
35 | /** |
||
36 | * Delete all the files from a directory |
||
37 | * @param string $directory |
||
38 | */ |
||
39 | public static function clear_directory($directory) |
||
49 | |||
50 | /** |
||
51 | * 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 |
||
52 | * @param string $filename |
||
53 | * @param array $data |
||
54 | * @return string |
||
55 | */ |
||
56 | public static function render_file($filename, array $data = array()) |
||
64 | |||
65 | protected $_directory; |
||
66 | protected $_base_url; |
||
67 | |||
68 | function __construct($directory, $base_url) |
||
79 | |||
80 | /** |
||
81 | * Save the current content of the driver into an html file. Add javascript errors, messages and a title to the html content |
||
82 | * @param \Openbuildings\Spiderling\Driver $driver |
||
83 | * @param string $filename |
||
84 | * @param string $title |
||
85 | */ |
||
86 | public function save_driver_content(\Openbuildings\Spiderling\Driver $driver, $filename, $title) |
||
112 | |||
113 | /** |
||
114 | * Implement PHPUnit\Framework\TestListener, save driver content if there was an error |
||
115 | * @param \PHPUnit\Framework\Test $test |
||
116 | * @param \Exception $exception |
||
117 | * @param integer $time |
||
118 | */ |
||
119 | public function addError(\PHPUnit\Framework\Test $test, \Exception $exception, $time) |
||
130 | |||
131 | /** |
||
132 | * Implement PHPUnit\Framework\TestListener, save driver content if there was an error |
||
133 | * @param \PHPUnit\Framework\Test $test |
||
134 | * @param \PHPUnit\Framework\AssertionFailedError $failure |
||
135 | * @param integer $time |
||
136 | */ |
||
137 | public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $failure, $time) |
||
149 | |||
150 | // @codeCoverageIgnoreStart |
||
151 | public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, $time) {} |
||
159 | // @codeCoverageIgnoreEnd |
||
160 | } |
||
161 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.