standardize EOLs to output diffs properly on Windows
[phpt.git] / src / PHPT / Section / FILE.php
blobc34089942f4d54b791f05aaf1ecbd28cbd2f4677
1 <?php
3 class PHPT_Section_FILE extends PHPT_Section_ModifiableAbstract
5 public $leave_file = false;
7 private $_contents = '';
8 private $_filename = '';
9 private $_runner_factory = null;
10 private $_result = null;
12 public function __construct($data)
14 parent::__construct($data);
15 $this->_contents = $data;
16 $this->_runner_factory = new PHPT_CodeRunner_Factory();
19 public function __destruct()
21 if ($this->leave_file == false) {
22 @unlink($this->_filename);
26 public function __set($key, $value)
28 $trigger_update = false;
29 if ($key == 'filename') {
30 $this->_filename = $value;
31 $trigger_update = true;
32 } elseif ($key == 'contents') {
33 $this->_contents = $value;
34 $trigger_update = true;
37 if ($trigger_update) {
38 file_put_contents($this->_filename, $this->contents);
42 public function __get($key)
44 if ($key == 'contents') {
45 return $this->_contents;
47 if ($key == 'filename') {
48 return $this->_filename;
50 if ($key == 'result') {
51 return $this->_result;
55 public function run(PHPT_Case $case)
57 parent::run($case);
58 $this->filename = dirname($case->filename) . '/' . basename($case->filename) . '.php';
59 $this->_result = $this->_runner_factory->factory($case)->run($this->_filename);
60 $case->output = $this->_result->output;
63 public function getPriority()