You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.0KB

  1. <?php
  2. class PHPT_Section_PRESKIPIF implements PHPT_Section_RunnableBefore
  3. {
  4. private $_data = null;
  5. private $_runner_factory = null;
  6. public function __construct($data)
  7. {
  8. $this->_data = $data;
  9. $this->_runner_factory = new PHPT_CodeRunner_Factory();
  10. }
  11. public function run(PHPT_Case $case)
  12. {
  13. // @todo refactor this code into PHPT_Util class as its used in multiple places
  14. $filename = dirname($case->filename) . '/' . basename($case->filename, '.php') . '.skip.php';
  15. // @todo refactor to PHPT_CodeRunner
  16. file_put_contents($filename, $this->_data);
  17. $runner = $this->_runner_factory->factory($case);
  18. $runner->ini = "";
  19. $response = $runner->run($filename)->output;
  20. unlink($filename);
  21. if (preg_match('/^skip( - (.*))?/', $response, $matches)) {
  22. $message = !empty($matches[2]) ? $matches[2] : '';
  23. throw new PHPT_Case_VetoException($message);
  24. }
  25. }
  26. public function getPriority()
  27. {
  28. return -2;
  29. }
  30. }