Permalink
Browse files

Initial import.

  • Loading branch information...
0 parents commit 117b619e14c4a31e9708faef233999558715d0fc @sebastianbergmann committed Jun 29, 2006
Showing with 10,558 additions and 0 deletions.
  1. +240 −0 Extensions/CodeCoverage/Renderer.php
  2. +175 −0 Extensions/CodeCoverage/Renderer/HTML.php
  3. +100 −0 Extensions/CodeCoverage/Renderer/Text.php
  4. +120 −0 Extensions/ExceptionTestCase.php
  5. +216 −0 Extensions/Log/PEAR.php
  6. +362 −0 Extensions/Log/XML.php
  7. +94 −0 Extensions/PerformanceTestCase.php
  8. +113 −0 Extensions/RepeatedTest.php
  9. +162 −0 Extensions/TestDecorator.php
  10. +147 −0 Extensions/TestDox/NamePrettifier.php
  11. +286 −0 Extensions/TestDox/ResultPrinter.php
  12. +97 −0 Extensions/TestDox/ResultPrinter/HTML.php
  13. +97 −0 Extensions/TestDox/ResultPrinter/Text.php
  14. +92 −0 Extensions/TestSetup.php
  15. +666 −0 Framework/Assert.php
  16. +48 −0 Framework/AssertionFailedError.php
  17. +127 −0 Framework/ComparisonFailure.php
  18. +43 −0 Framework/Error.php
  19. +36 −0 Framework/IncompleteTest.php
  20. +39 −0 Framework/IncompleteTestError.php
  21. +60 −0 Framework/Test.php
  22. +325 −0 Framework/TestCase.php
  23. +139 −0 Framework/TestFailure.php
  24. +121 −0 Framework/TestListener.php
  25. +480 −0 Framework/TestResult.php
  26. +494 −0 Framework/TestSuite.php
  27. +66 −0 Framework/Warning.php
  28. +296 −0 Runner/BaseTestRunner.php
  29. +151 −0 Runner/IncludePathTestCollector.php
  30. +97 −0 Runner/StandardTestSuiteLoader.php
  31. +45 −0 Runner/TestCollector.php
  32. +101 −0 Runner/TestRunListener.php
  33. +56 −0 Runner/TestSuiteLoader.php
  34. +61 −0 Runner/Version.php
  35. +61 −0 Tests/AllTests.php
  36. +55 −0 Tests/DoubleTestCase.php
  37. +38 −0 Tests/Error.php
  38. +83 −0 Tests/Extensions/AllTests.php
  39. +83 −0 Tests/Extensions/ExceptionTestCaseTest.php
  40. +84 −0 Tests/Extensions/ExtensionTest.php
  41. +52 −0 Tests/Extensions/PerformanceTestCaseTest.php
  42. +84 −0 Tests/Extensions/RepeatedTestTest.php
  43. +62 −0 Tests/Extensions/TestDox/AllTests.php
  44. +77 −0 Tests/Extensions/TestDox/NamePrettifierTest.php
  45. +38 −0 Tests/Failure.php
  46. +101 −0 Tests/Framework/AllTests.php
  47. +334 −0 Tests/Framework/AssertTest.php
  48. +134 −0 Tests/Framework/ComparisonFailureTest.php
  49. +159 −0 Tests/Framework/SuiteTest.php
  50. +157 −0 Tests/Framework/TestCaseTest.php
  51. +56 −0 Tests/Framework/TestImplementorTest.php
  52. +107 −0 Tests/Framework/TestListenerTest.php
  53. +38 −0 Tests/InheritedTestCase.php
  54. +59 −0 Tests/Iterator.php
  55. +48 −0 Tests/MockRunner.php
  56. +37 −0 Tests/NoArgTestCaseTest.php
  57. +35 −0 Tests/NoTestCaseClass.php
  58. +37 −0 Tests/NoTestCases.php
  59. +36 −0 Tests/NonStatic.php
  60. +40 −0 Tests/NotPublicTestCase.php
  61. +35 −0 Tests/NotVoidTestCase.php
  62. +40 −0 Tests/OneTestCase.php
  63. +38 −0 Tests/OverrideTestCase.php
  64. +69 −0 Tests/Runner/AllTests.php
  65. +42 −0 Tests/Runner/BaseTestRunnerTest.php
  66. +38 −0 Tests/SetupFailure.php
  67. +38 −0 Tests/Sleep.php
  68. +37 −0 Tests/Success.php
  69. +38 −0 Tests/TearDownFailure.php
  70. +38 −0 Tests/ThrowExceptionTestCase.php
  71. +37 −0 Tests/ThrowNoExceptionTestCase.php
  72. +40 −0 Tests/TornDown.php
  73. +44 −0 Tests/TornDown2.php
  74. +43 −0 Tests/TornDown3.php
  75. +38 −0 Tests/TornDown4.php
  76. +38 −0 Tests/TornDown5.php
  77. +40 −0 Tests/WasRun.php
  78. +383 −0 TextUI/ResultPrinter.php
  79. +635 −0 TextUI/TestRunner.php
  80. +246 −0 Util/Filter.php
  81. +89 −0 Util/Printer.php
  82. +287 −0 Util/Skeleton.php
  83. +340 −0 package.xml
  84. +20 −0 pear-phpunit
  85. +18 −0 pear-phpunit.bat
@@ -0,0 +1,240 @@
+<?php
+//
+// +------------------------------------------------------------------------+
+// | PEAR :: PHPUnit2 |
+// +------------------------------------------------------------------------+
+// | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
+// +------------------------------------------------------------------------+
+// | This source file is subject to version 3.00 of the PHP License, |
+// | that is available at http://www.php.net/license/3_0.txt. |
+// | If you did not receive a copy of the PHP license and are unable to |
+// | obtain it through the world-wide-web, please send a note to |
+// | license@php.net so we can mail you a copy immediately. |
+// +------------------------------------------------------------------------+
+//
+// $Id: Renderer.php 539 2006-02-13 16:08:42Z sb $
+//
+
+/**
+ * Abstract base class for Code Coverage renderers.
+ *
+ * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @copyright Copyright &copy; 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
+ * @category Testing
+ * @package PHPUnit2
+ * @subpackage Extensions
+ * @since 2.1.0
+ * @abstract
+ */
+abstract class PHPUnit2_Extensions_CodeCoverage_Renderer {
+ // {{{ Instance Variables
+
+ /**
+ * @var array
+ * @access protected
+ */
+ protected $codeCoverageInformation;
+
+ /**
+ * @var boolean
+ * @access protected
+ */
+ protected $useSummary = TRUE;
+
+ // }}}
+ // {{{ protected function __construct($codeCoverageInformation)
+
+ /**
+ * Constructor.
+ *
+ * @param array $codeCoverageInformation
+ * @access protected
+ */
+ protected function __construct($codeCoverageInformation) {
+ $this->codeCoverageInformation = $codeCoverageInformation;
+ }
+
+ // }}}
+ // {{{ public function factory($rendererName, $codeCoverageInformation)
+
+ /**
+ * Abstract Factory.
+ *
+ * @param string $rendererName
+ * @param array $codeCoverageInformation
+ * @access public
+ */
+ public function factory($rendererName, $codeCoverageInformation) {
+ $class = 'PHPUnit2_Extensions_CodeCoverage_Renderer_' . $rendererName;
+
+ @require_once 'PHPUnit2/Extensions/CodeCoverage/Renderer/' . $rendererName . '.php';
+
+ if (class_exists($class)) {
+ return new $class($codeCoverageInformation);
+ } else {
+ throw new Exception(
+ sprintf(
+ 'Could not load class %s.',
+ $class
+ )
+ );
+ }
+ }
+
+ // }}}
+ // {{{ public final function render()
+
+ /**
+ * Visualizes the result array of
+ * PHPUnit2_Framework_TestResult::getCodeCoverageInformation().
+ *
+ * @return string
+ * @access public
+ * @final
+ */
+ public final function render() {
+ $buffer = $this->header();
+
+ if ($this->useSummary) {
+ foreach ($this->getSummary() as $sourceFile => $executedLines) {
+ $buffer .= $this->startSourceFile($sourceFile);
+ $buffer .= $this->renderSourceFile(file($sourceFile), $executedLines);
+ $buffer .= $this->endSourceFile($sourceFile);
+ }
+ } else {
+ }
+
+ return $buffer . $this->footer();
+ }
+
+ // }}}
+ // {{{ public function renderToFile($filename)
+
+ /**
+ * Visualizes the result array of
+ * PHPUnit2_Framework_TestResult::getCodeCoverageInformation()
+ * and writes it to a file.
+ *
+ * @param string $filename
+ * @access public
+ * @since 2.2.0
+ */
+ public function renderToFile($filename) {
+ if ($fp = fopen($filename, 'w')) {
+ fputs(
+ $fp,
+ $this->render()
+ );
+
+ fclose($fp);
+ }
+ }
+
+ // }}}
+ // {{{ protected function getSummary()
+
+ /**
+ * Returns summarized Code Coverage data.
+ *
+ * Format of the result array:
+ *
+ * <code>
+ * array(
+ * "/tested/code.php" => array(
+ * linenumber => flag
+ * )
+ * )
+ * </code>
+ *
+ * flag > 1: line was executed.
+ * flag < 1: line is executable but was not executed.
+ *
+ * @return array
+ * @access protected
+ * @since 2.2.0
+ */
+ protected function getSummary() {
+ $summary = array();
+
+ foreach ($this->codeCoverageInformation as $testCaseName => $sourceFiles) {
+ foreach ($sourceFiles as $sourceFile => $executedLines) {
+ foreach ($executedLines as $lineNumber => $flag) {
+ if (!isset($summary[$sourceFile][$lineNumber])) {
+ $summary[$sourceFile][$lineNumber] = $flag;
+ }
+
+ else if ($flag > 0) {
+ $summary[$sourceFile][$lineNumber] = $flag;
+ }
+ }
+ }
+ }
+
+ return $summary;
+ }
+
+ // }}}
+ // {{{ protected function header()
+
+ /**
+ * @return string
+ * @access protected
+ * @since 2.1.1
+ */
+ protected function header() {
+ }
+
+ // }}}
+ // {{{ protected function footer()
+
+ /**
+ * @return string
+ * @access protected
+ * @since 2.1.1
+ */
+ protected function footer() {
+ }
+
+ // }}}
+ // {{{ protected function startSourceFile($sourceFile)
+
+ /**
+ * @param string $sourceFile
+ * @return string
+ * @access protected
+ */
+ protected function startSourceFile($sourceFile) {
+ }
+
+ // }}}
+ // {{{ protected function endSourceFile($sourceFile)
+
+ /**
+ * @param string $sourceFile
+ * @return string
+ * @access protected
+ */
+ protected function endSourceFile($sourceFile) {
+ }
+
+ // }}}
+ // {{{ abstract protected function renderSourceFile($codeLines, $executedLines)
+
+ /**
+ * @param array $codeLines
+ * @param array $executedLines
+ * @return string
+ * @access protected
+ * @abstract
+ */
+ abstract protected function renderSourceFile($codeLines, $executedLines);
+
+ // }}}
+}
+
+/*
+ * vim600: et sw=2 ts=2 fdm=marker
+ * vim<600: et sw=2 ts=2
+ */
+?>
Oops, something went wrong.

0 comments on commit 117b619

Please sign in to comment.