standardize EOLs to output diffs properly on Windows
[phpt.git] / src / PHPT / Section / SKIPIF.php
blobfb451152a3336c70ea086da00e11c31c7e30d2eb
1 <?php
3 class PHPT_Section_SKIPIF implements PHPT_Section_RunnableBefore
5 private $_data = null;
7 public function __construct($data)
9 $this->_data = $data;
12 public function run(PHPT_Case $case)
14 // @todo refactor this code into PHPT_Util class as its used in multiple places
15 $filename = dirname($case->filename) . '/' . basename($case->filename, '.php') . '.skip.php';
17 // @todo refactor to PHPT_CodeRunner
18 file_put_contents($filename, $this->_data);
19 $response = array();
20 exec('php -f ' . $filename, $response);
21 $response = implode(PHP_EOL, $response);
22 unlink($filename);
24 if (preg_match('/^skip( - (.*))?/', $response, $matches)) {
25 $message = !empty($matches[2]) ? $matches[2] : '';
26 throw new PHPT_Case_VetoException($message);
30 public function getPriority()
32 return 0;