LimeOutputRaw.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /*
  3. * This file is part of the Lime framework.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. * (c) Bernhard Schussek <bernhard.schussek@symfony-project.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. class LimeOutputRaw implements LimeOutputInterface
  12. {
  13. protected
  14. $initialized = false;
  15. protected function printCall($method, array $arguments = array())
  16. {
  17. foreach ($arguments as &$argument)
  18. {
  19. if (is_string($argument))
  20. {
  21. $argument = str_replace(array("\n", "\r"), array('\n', '\r'), $argument);
  22. }
  23. }
  24. if (!$this->initialized)
  25. {
  26. $this->initialized = true;
  27. print "\0raw\0";
  28. }
  29. print serialize(array($method, $arguments))."\n";
  30. }
  31. public function supportsThreading()
  32. {
  33. return true;
  34. }
  35. public function focus($file)
  36. {
  37. $this->printCall('focus', array($file));
  38. }
  39. public function close()
  40. {
  41. $this->printCall('close', array());
  42. }
  43. public function plan($amount)
  44. {
  45. $this->printCall('plan', array($amount));
  46. }
  47. public function pass($message, $file, $line)
  48. {
  49. $this->printCall('pass', array($message, $file, $line));
  50. }
  51. public function fail($message, $file, $line, $error = null)
  52. {
  53. $this->printCall('fail', array($message, $file, $line, $error));
  54. }
  55. public function skip($message, $file, $line)
  56. {
  57. $this->printCall('skip', array($message, $file, $line));
  58. }
  59. public function todo($message, $file, $line)
  60. {
  61. $this->printCall('todo', array($message, $file, $line));
  62. }
  63. public function warning($message, $file, $line)
  64. {
  65. $this->printCall('warning', array($message, $file, $line));
  66. }
  67. public function error(LimeError $error)
  68. {
  69. $this->printCall('error', array($error));
  70. }
  71. public function comment($message)
  72. {
  73. $this->printCall('comment', array($message));
  74. }
  75. public function flush()
  76. {
  77. $this->printCall('flush');
  78. }
  79. }