PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/vendor/phing/tasks/ext/phpunit/FormatterElement.php

https://bitbucket.org/ealexandru/jobeet
PHP | 150 lines | 104 code | 19 blank | 27 comment | 13 complexity | 7469321b6c843d2fcf5c219db168d186 MD5 | raw file
Possible License(s): ISC, AGPL-3.0, LGPL-2.1, BSD-3-Clause, LGPL-3.0
  1. <?php
  2. /**
  3. * $Id: FormatterElement.php 325 2007-12-20 15:44:58Z hans $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. require_once 'phing/system/io/PhingFile.php';
  22. /**
  23. * A wrapper for the implementations of PHPUnit2ResultFormatter.
  24. *
  25. * @author Michiel Rook <michiel.rook@gmail.com>
  26. * @version $Id: FormatterElement.php 325 2007-12-20 15:44:58Z hans $
  27. * @package phing.tasks.ext.phpunit
  28. * @since 2.1.0
  29. */
  30. class FormatterElement
  31. {
  32. protected $formatter = NULL;
  33. protected $type = "";
  34. protected $useFile = true;
  35. protected $toDir = ".";
  36. protected $outfile = "";
  37. function setType($type)
  38. {
  39. $this->type = $type;
  40. if ($this->type == "summary")
  41. {
  42. if (PHPUnitUtil::$installedVersion == 3)
  43. {
  44. require_once 'phing/tasks/ext/phpunit/phpunit3/SummaryPHPUnit3ResultFormatter.php';
  45. $this->formatter = new SummaryPHPUnit3ResultFormatter();
  46. }
  47. else
  48. {
  49. require_once 'phing/tasks/ext/phpunit/phpunit2/SummaryPHPUnit2ResultFormatter.php';
  50. $this->formatter = new SummaryPHPUnit2ResultFormatter();
  51. }
  52. }
  53. else
  54. if ($this->type == "xml")
  55. {
  56. $destFile = new PhingFile($this->toDir, 'testsuites.xml');
  57. if (PHPUnitUtil::$installedVersion == 3)
  58. {
  59. require_once 'phing/tasks/ext/phpunit/phpunit3/XMLPHPUnit3ResultFormatter.php';
  60. $this->formatter = new XMLPHPUnit3ResultFormatter();
  61. }
  62. else
  63. {
  64. require_once 'phing/tasks/ext/phpunit/phpunit2/XMLPHPUnit2ResultFormatter.php';
  65. $this->formatter = new XMLPHPUnit2ResultFormatter();
  66. }
  67. }
  68. else
  69. if ($this->type == "plain")
  70. {
  71. if (PHPUnitUtil::$installedVersion == 3)
  72. {
  73. require_once 'phing/tasks/ext/phpunit/phpunit3/PlainPHPUnit3ResultFormatter.php';
  74. $this->formatter = new PlainPHPUnit3ResultFormatter();
  75. }
  76. else
  77. {
  78. require_once 'phing/tasks/ext/phpunit/phpunit2/PlainPHPUnit2ResultFormatter.php';
  79. $this->formatter = new PlainPHPUnit2ResultFormatter();
  80. }
  81. }
  82. else
  83. {
  84. throw new BuildException("Formatter '" . $this->type . "' not implemented");
  85. }
  86. }
  87. function setClassName($className)
  88. {
  89. $classNameNoDot = Phing::import($className);
  90. $this->formatter = new $classNameNoDot();
  91. }
  92. function setUseFile($useFile)
  93. {
  94. $this->useFile = $useFile;
  95. }
  96. function getUseFile()
  97. {
  98. return $this->useFile;
  99. }
  100. function setToDir($toDir)
  101. {
  102. $this->toDir = $toDir;
  103. }
  104. function getToDir()
  105. {
  106. return $this->toDir;
  107. }
  108. function setOutfile($outfile)
  109. {
  110. $this->outfile = $outfile;
  111. }
  112. function getOutfile()
  113. {
  114. if ($this->outfile)
  115. {
  116. return $this->outfile;
  117. }
  118. else
  119. {
  120. return $this->formatter->getPreferredOutfile() . $this->getExtension();
  121. }
  122. }
  123. function getExtension()
  124. {
  125. return $this->formatter->getExtension();
  126. }
  127. function getFormatter()
  128. {
  129. return $this->formatter;
  130. }
  131. }