From 6d7ea751912b488c1447368cf7e9922099fa0bd2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 28 Jul 2007 17:43:46 +0000 Subject: [PATCH] * tools/ISI_PHPUnit2_Output_HTML_Listener.php: Removed because we added it already. --- tools/ISI_PHPUnit2_Output_HTML_Listener.php | 546 -------------------- 1 file changed, 546 deletions(-) delete mode 100755 tools/ISI_PHPUnit2_Output_HTML_Listener.php diff --git a/tools/ISI_PHPUnit2_Output_HTML_Listener.php b/tools/ISI_PHPUnit2_Output_HTML_Listener.php deleted file mode 100755 index b713fd5..0000000 --- a/tools/ISI_PHPUnit2_Output_HTML_Listener.php +++ /dev/null @@ -1,546 +0,0 @@ -$result = new PHPUnit2_Framework_TestResult; -* $result->addListener(new ISI_PHPUnit2_Output_HTML_Listener); -* $suite->run($result); -* -* @author Iris Studios, Inc. -* @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc. -* @version $Revision$ -* -*/ -class ISI_PHPUnit2_Output_HTML_Listener implements PHPUnit2_Framework_TestListener -{ - /** - * A successful test - * @var integer - */ - const TEST_SUCCESS = 1; - - /** - * An incomplete test - * @var integer - */ - const TEST_INCOMPLETE = 2; - - /** - * A failed test - * @var integer - */ - const TEST_FAIL = 3; - - /** - * An array of all the tests run in a given suite - * @var array - */ - protected $tests = array(); - - /** - * An array of arrays of all the errors in a given failed test in a suite - * @var array - */ - protected $errors = array(); - - /** - * An array of all the incomplete test messages for a test in a suite - * @var array - */ - protected $incompletes = array(); - - /** - * Statistics for a given test suite - * @var array - */ - protected $stats = array(); - - /** - * The name of the currently-running test suite - * @var string - */ - private $currentSuite; - - /** - * The name of the currently-running individual test - * @var string - */ - private $currentTest; - - // ################################################################### - /** - * A test errored out - * - * @param object PHPUnit2_Framework_Test - * @param except Thrown execption - */ - public function addError(PHPUnit2_Framework_Test $test, Exception $e) - { - $this->errors[ $this->currentSuite ][ $this->currentTest ][] = new ISI_Private_Exception($e); - } - - // ################################################################### - /** - * A test failed - * - * @param object PHPUnit2_Framework_Test - * @param object PHPUnit2_Framework_AssertionFailedError - */ - public function addFailure(PHPUnit2_Framework_Test $test, PHPUnit2_Framework_AssertionFailedError $e) - { - $this->errors[ $this->currentSuite ][ $this->currentTest ][] = new ISI_Private_Exception($e); - $this->tests[ $this->currentSuite ][ $this->currentTest ] = self::TEST_FAIL; - $this->stats[ $this->currentSuite ]['fail']++; - } - - // ################################################################### - /** - * A test reported being an incomplete implementation - * - * @param object PHPUnit2_Framework_Test - * @param except The thrown exception notice - */ - public function addIncompleteTest(PHPUnit2_Framework_Test $test, Exception $e) - { - $this->incompletes[ $this->currentSuite ][ $this->currentTest ] = new ISI_Private_Exception($e); - $this->tests[ $this->currentSuite ][ $this->currentTest ] = self::TEST_INCOMPLETE; - $this->stats[ $this->currentSuite ]['incomplete']++; - } - - // ################################################################### - /** - * Start test suite - * - * @param object A PHPUnit2_Framework_TestSuite - */ - public function startTestSuite(PHPUnit2_Framework_TestSuite $suite) - { - $this->currentSuite = $suite->getName(); - if ($this->currentSuite == '') - { - return; - } - - $this->tests[ $this->currentSuite ] = array(); - $this->stats[ $this->currentSuite ] = array('total' => 0, 'fail' => 0, 'incomplete' => 0); - } - - // ################################################################### - /** - * Test suite ended - * - * @param object PHPUnit2_Framework_TestSuite - */ - public function endTestSuite(PHPUnit2_Framework_TestSuite $suite) - { - $this->currentSuite = null; - } - - // ################################################################### - /** - * An individual test started - * - * @param object The PHPUnit2_Framework_Test - */ - public function startTest(PHPUnit2_Framework_Test $test) - { - $this->currentTest = $test->getName(); - if ($this->currentTest == '') - { - return; - } - - $this->tests[ $this->currentSuite ][ $this->currentTest ] = self::TEST_SUCCESS; - $this->stats[ $this->currentSuite ]['total']++; - } - - // ################################################################### - /** - * An individual test ended - * - * @param object The PHPUnit2_Framework_Test - */ - public function endTest(PHPUnit2_Framework_Test $test) - { - $this->currentTest = null; - } - - // ################################################################### - /** - * Destructor: create the HTML output - */ - public function __destruct() - { - $stats = array('total' => 0, 'incomplete' => 0, 'fail' => 0, 'success' => 0); - foreach ($this->stats AS $statGroup) - { - foreach ($statGroup AS $statType => $count) - { - $stats["$statType"] += $count; - } - } - $stats['success'] = $stats['total'] - ($stats['incomplete'] + $stats['fail']); - - $output = ' - - - - Unit Test Results - - - - - -

Unit Test Results

- -
-
The following is a report of how each unit test performed. If any errors or exceptions were thrown, they have been recorded below. Tests have been broken down into their test suite groups. Your overall statistics are here:
- -
- -
Total Tests: ' . $stats['total'] . '
-
Number Success: ' . $stats['success'] . '
-
Number Fail: ' . $stats['fail'] . '
-
Number Incomplete: ' . $stats['incomplete'] . '
- -
- -
Total Success Rate: ' . round(100 * ($stats['success'] / $stats['total']), 1) . '%
-
- -
- -'; - - foreach ($this->tests AS $suite => $tests) - { - $successPercent = round(100 * (($this->stats["$suite"]['total'] - ($this->stats["$suite"]['fail'] + $this->stats["$suite"]['incomplete'])) / $this->stats["$suite"]['total']), 1); - - $output .= '
'; - $output .= "\n\t" . '
'; - $output .= "\n\t\t" . '' . $this->stats["$suite"]['total'] . ' Tests, ' . $successPercent . '% Success' . ''; - $output .= "\n\t\t" . $suite; - $output .= "\n\t" . '
'; - $output .= "\n\t" . '
'; - foreach ($tests AS $name => $statusCode) - { - switch ($statusCode) - { - case self::TEST_SUCCESS: - $cssName = 'Success'; - $cssColor = 'green'; - - $info = ''; - break; - - case self::TEST_INCOMPLETE: - $cssName = 'Incomplete'; - $cssColor = 'blue'; - - $info = $this->formatInfo($this->incompletes["$suite"]["$name"]); - break; - - case self::TEST_FAIL: - $cssName = 'Fail'; - $cssColor = 'red'; - - $info = $this->formatInfo($this->errors["$suite"]["$name"]); - break; - } - - $output .= "\n\t\t" . '
'; - $output .= "\n\t\t\t" . '
' . $name . '
'; - - if ($info) - { - $output .= "\n\t\t\t" . '
'; - $output .= $info; - $output .= "\n\t\t\t" . '
'; - } - - $output .= "\n\t\t" . '
'; - } - $output .= "\n\t" . '
'; - $output .= "\n" . '
'; - $output .= "\n\n" . '
' . "\n\n"; - } - - $output .= ' - -'; - - file_put_contents('./UnitTestReport.html', $output); - } - - // ################################################################### - /** - * Formats an error array into a bulleted list - * - * @param mixed Error/information list - * - * @return string Formatted HTML - */ - private function formatInfo($list) - { - if (!is_array($list)) - { - $list = array($list); - } - - $count = sizeof($list); - foreach ($list AS $exc) - { - $i++; - - if ($exc->getMessage() != '') - { - $output = "\n\t\t\t\t" . '
'; - $output .= "\n\t\t\t\t\t" . '
• ' . htmlspecialchars($exc->getMessage()) . '
'; - } - - $output .= "\n\t\t\t\t\t" . '
in ' . $exc->getPath() . ' at line ' . $exc->getLine() . '
'; - - if ($exc->getMessage() != '') - { - $output .= "\n\t\t\t\t" . '
'; - } - } - - return $output; - } -} - -/** -* Iris Studios Private Exception Handler -* -* This class is just a form of an exception that ignores the stack trace -* because it's too long. -* -* @author Iris Studios, Inc. -* @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc. -* @version $Revision$ -* -*/ -class ISI_Private_Exception -{ - /** - * Exception context message - * @var string - */ - private $message = ''; - - /** - * File path - * @var string - */ - private $path = ''; - - /** - * Line number of the exception - * @var integer - */ - private $line = 0; - - // ################################################################### - /** - * Constructor: accept exception - * - * @param except A given exception - */ - public function __construct(Exception $e) - { - $this->message = $e->getMessage(); - $this->path = $e->getFile(); - $this->line = $e->getLine(); - } - - // ################################################################### - /** - * Returns the context message - * - * @return string Context message - */ - public function getMessage() - { - return $this->message; - } - - // ################################################################### - /** - * Returns the file path - * - * @return string File path - */ - public function getPath() - { - return $this->path; - } - - // ################################################################### - /** - * Returns the line number - * - * @return integer Line number - */ - public function getLine() - { - return $this->line; - } -} - -/*=====================================================================*\ -|| ################################################################### -|| # $HeadURL$ -|| # $Id$ -|| ################################################################### -\*=====================================================================*/ -?> \ No newline at end of file -- 2.43.5