diff options
author | Ciro Mattia Gonano <ciromattia@gmail.com> | 2013-09-11 15:56:48 +0200 |
---|---|---|
committer | Ciro Mattia Gonano <ciromattia@gmail.com> | 2013-09-11 15:57:07 +0200 |
commit | 3069eaf35e833ffe4a1c1c7829dd7e168ae27420 (patch) | |
tree | d0c2e4d934cc34ba7d4232f759923b5a257dcb21 /buildscripts/phing/classes/phing/tasks/ext/simpletest | |
parent | b833247ce597ec26159b46c8dfbea7f1e265950b (diff) |
Merge up to r3319
Diffstat (limited to 'buildscripts/phing/classes/phing/tasks/ext/simpletest')
8 files changed, 0 insertions, 989 deletions
diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php deleted file mode 100755 index 32fbc212..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - * $Id: ae09aa1a433f4de854fa7c27903e7eb0957bc90b $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; - -/** - * Dummy result formatter used to count SimpleTest results - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: ae09aa1a433f4de854fa7c27903e7eb0957bc90b $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -class SimpleTestCountResultFormatter extends SimpleTestResultFormatter -{ - const SUCCESS = 0; - const FAILURES = 1; - const ERRORS = 2; - - function getRetCode() - { - if ($this->getExceptionCount() != 0) - { - return self::ERRORS; - } - else if ($this->getFailCount() != 0) - { - return self::FAILURES; - } - - return self::SUCCESS; - } -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestDebugResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestDebugResultFormatter.php deleted file mode 100755 index de78ab24..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestDebugResultFormatter.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** - * $Id: d7e7e397e81588c3eafcb9e758666fec0fa166f5 $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; - -/** - * Prints plain text output of the test to a specified Writer. - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: d7e7e397e81588c3eafcb9e758666fec0fa166f5 $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -class SimpleTestDebugResultFormatter extends SimpleTestResultFormatter -{ - protected $current_case = ""; - protected $current_test = ""; - private $failingTests = array(); - - function printFailingTests() { - foreach ($this->failingTests as $test) { - $this->out->write($test . "\n"); - } - } - - function paintCaseStart($test_name) - { - parent::paintCaseStart($test_name); - $this->paint( "Testsuite: $test_name\n"); - $this->current_case = $test_name; - } - - function paintMethodStart($test_name) - { - parent::paintMethodStart($test_name); - $this->current_test = $test_name; - //$msg = "{$this->current_case} :: $test_name\n"; - $msg = " TestCase: $test_name"; - $this->paint($msg); - } - - function paint($msg) { - if ($this->out == null ) { - print $msg; - } else { - $this->out->write($msg); - } - } - - function paintMethodEnd($test_name) { - parent::paintMethodEnd($test_name); - $this->paint("\n"); - } - - function paintCaseEnd($test_name) - { - parent::paintCaseEnd($test_name); - $this->current_case = ""; - /* Only count suites where more than one test was run */ - - if ($this->getRunCount() && false) - { - $sb = ""; - $sb.= "Tests run: " . $this->getRunCount(); - $sb.= ", Failures: " . $this->getFailureCount(); - $sb.= ", Errors: " . $this->getErrorCount(); - $sb.= ", Time elapsed: " . $this->getElapsedTime(); - $sb.= " sec\n"; - $this->paint($sb); - } - - } - - function paintError($message) - { - parent::paintError($message); - $this->formatError("ERROR", $message); - $this->failingTests[] = $this->current_case . "->" . $this->current_test; - } - - function paintFail($message) - { - parent::paintFail($message); - $this->formatError("FAILED", $message); - $this->failingTests[] = $this->current_case . "->" . $this->current_test; - } - function paintException($message) - { - parent::paintException($message); - $this->failingTests[] = $this->current_case . "->" . $this->current_test; - $this->formatError("Exception", $message); - } - - - - private function formatError($type, $message) - { - $this->paint("ERROR: $type: $message"); - } - -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php deleted file mode 100755 index 5ae9ba23..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * $Id: 2441f1b83b9f9d1aeb2a4afd7e049c840d70bbd9 $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'phing/tasks/ext/phpunit/FormatterElement.php'; - -/** - * Child class of "FormatterElement", overrides setType to provide other - * formatter classes for SimpleTest - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: 2441f1b83b9f9d1aeb2a4afd7e049c840d70bbd9 $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -class SimpleTestFormatterElement extends FormatterElement -{ - function setType($type) - { - $this->type = $type; - - if ($this->type == "xml") - { - require_once 'phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php'; - $destFile = new PhingFile($this->toDir, 'testsuites.xml'); - $this->formatter = new SimpleTestXmlResultFormatter(); - } - else - if ($this->type == "plain") - { - require_once 'phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php'; - $this->formatter = new SimpleTestPlainResultFormatter(); - } - else - if ($this->type == "summary") - { - require_once 'phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php'; - $this->formatter = new SimpleTestSummaryResultFormatter(); - } - else - if ($this->type == "debug") - { - require_once 'phing/tasks/ext/simpletest/SimpleTestDebugResultFormatter.php'; - $this->formatter = new SimpleTestDebugResultFormatter(); - } - else - { - throw new BuildException("Formatter '" . $this->type . "' not implemented"); - } - } -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php deleted file mode 100755 index cfba9533..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php +++ /dev/null @@ -1,95 +0,0 @@ -<?php -/** - * $Id: c0fa060b8f439f7d0013a0ec016ede4c5a76b42d $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; - -/** - * Prints plain text output of the test to a specified Writer. - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: c0fa060b8f439f7d0013a0ec016ede4c5a76b42d $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter -{ - private $inner = ""; - - function getExtension() - { - return ".txt"; - } - - function getPreferredOutfile() - { - return "testresults"; - } - - function paintCaseStart($test_name) - { - parent::paintCaseStart($test_name); - - $this->inner = ""; - } - - function paintCaseEnd($test_name) - { - parent::paintCaseEnd($test_name); - - $sb = ""; - /* Only count suites where more than one test was run */ - if ($this->getRunCount()) - { - $sb.= "Testsuite: $test_name\n"; - $sb.= "Tests run: " . $this->getRunCount(); - $sb.= ", Failures: " . $this->getFailureCount(); - $sb.= ", Errors: " . $this->getErrorCount(); - $sb.= ", Time elapsed: " . $this->getElapsedTime(); - $sb.= " sec\n"; - - if ($this->out != NULL) - { - $this->out->write($sb); - $this->out->write($this->inner); - } - } - } - - function paintError($message) - { - parent::paintError($message); - - $this->formatError("ERROR", $message); - } - - function paintFail($message) - { - parent::paintFail($message); - - $this->formatError("FAILED", $message); - } - - private function formatError($type, $message) - { - $this->inner.= $this->getTestName() . " " . $type . "\n"; - $this->inner.= $message . "\n"; - } -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php deleted file mode 100755 index 8efcbb63..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php +++ /dev/null @@ -1,161 +0,0 @@ -<?php -/** - * $Id: b9fbde1e1a21cccbcf6c3bdc29765cf0cf681e31 $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'simpletest/scorer.php'; - -require_once 'phing/system/io/Writer.php'; - -/** - * This abstract class describes classes that format the results of a SimpleTest testrun. - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: b9fbde1e1a21cccbcf6c3bdc29765cf0cf681e31 $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -abstract class SimpleTestResultFormatter extends SimpleReporter -{ - protected $out = NULL; - - protected $project = NULL; - - private $timer = NULL; - - private $runCount = 0; - - private $failureCount = 0; - - private $errorCount = 0; - - private $currentTest = ""; - - /** - * Sets the writer the formatter is supposed to write its results to. - */ - function setOutput(Writer $out) - { - $this->out = $out; - } - - /** - * Returns the extension used for this formatter - * - * @return string the extension - */ - function getExtension() - { - return ""; - } - - /** - * Sets the project - * - * @param Project the project - */ - function setProject(Project $project) - { - $this->project = $project; - } - - function getPreferredOutfile() - { - return ""; - } - - function paintMethodStart($test_name) - { - parent::paintMethodStart($test_name); - - $this->currentTest = $test_name; - } - - function paintMethodEnd($test_name) - { - parent::paintMethodEnd($test_name); - - $this->runCount++; - } - - function paintCaseStart($test_name) - { - parent::paintCaseStart($test_name); - - $this->runCount = 0; - $this->failureCount = 0; - $this->errorCount = 0; - - $this->timer = new Timer(); - $this->timer->start(); - } - - function paintCaseEnd($test_name) - { - parent::paintCaseEnd($test_name); - - $this->timer->stop(); - } - - function paintError($message) - { - parent::paintError($message); - - $this->errorCount++; - } - - function paintFail($message) - { - parent::paintFail($message); - - $this->failureCount++; - } - - function getRunCount() - { - return $this->runCount; - } - - function getFailureCount() - { - return $this->failureCount; - } - - function getErrorCount() - { - return $this->errorCount; - } - - function getTestName() - { - return $this->currentTest; - } - - function getElapsedTime() - { - if ($this->timer) - { - return $this->timer->getElapsedTime(); - } - else - { - return 0; - } - } -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php deleted file mode 100755 index e0a78f11..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * $Id: cd15496bfbce39bfd20fe17d52f9348848df0706 $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; - -/** - * Prints short summary output of the test to Phing's logging system. - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: cd15496bfbce39bfd20fe17d52f9348848df0706 $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -class SimpleTestSummaryResultFormatter extends SimpleTestResultFormatter -{ - function paintCaseEnd($test_name) - { - parent::paintCaseEnd($test_name); - - /* Only count suites where more than one test was run */ - if ($this->getRunCount()) - { - $sb.= "Tests run: " . $this->getRunCount(); - $sb.= ", Failures: " . $this->getFailureCount(); - $sb.= ", Errors: " . $this->getErrorCount(); - $sb.= ", Time elapsed: " . $this->getElapsedTime(); - $sb.= " sec\n"; - - if ($this->out != NULL) - { - $this->out->write($sb); - } - } - } -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php deleted file mode 100755 index 8082e1ee..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php +++ /dev/null @@ -1,264 +0,0 @@ -<?php -/** - * $Id: d53b946f773798618069fe162d47ac5f6643662a $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'phing/Task.php'; -require_once 'phing/system/io/PhingFile.php'; -require_once 'phing/system/io/Writer.php'; -require_once 'phing/util/LogWriter.php'; - -/** - * Runs SimpleTest tests. - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: d53b946f773798618069fe162d47ac5f6643662a $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -class SimpleTestTask extends Task -{ - private $formatters = array(); - private $haltonerror = false; - private $haltonfailure = false; - private $failureproperty; - private $errorproperty; - private $printsummary = false; - private $testfailed = false; - private $debug = false; - - /** - * Initialize Task. - * This method includes any necessary SimpleTest libraries and triggers - * appropriate error if they cannot be found. This is not done in header - * because we may want this class to be loaded w/o triggering an error. - */ - function init() { - @include_once 'simpletest/scorer.php'; - - if (!class_exists('SimpleReporter')) { - throw new BuildException("SimpleTestTask depends on SimpleTest package being installed.", $this->getLocation()); - } - - require_once 'simpletest/reporter.php'; - require_once 'simpletest/xml.php'; - require_once 'simpletest/test_case.php'; - require_once 'phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php'; - require_once 'phing/tasks/ext/simpletest/SimpleTestDebugResultFormatter.php'; - require_once 'phing/tasks/ext/simpletest/SimpleTestFormatterElement.php'; - } - - function setFailureproperty($value) - { - $this->failureproperty = $value; - } - - function setErrorproperty($value) - { - $this->errorproperty = $value; - } - - function setHaltonerror($value) - { - $this->haltonerror = $value; - } - - function setHaltonfailure($value) - { - $this->haltonfailure = $value; - } - - function setPrintsummary($printsummary) - { - $this->printsummary = $printsummary; - } - - public function setDebug($debug) - { - $this->debug = $debug; - } - - public function getDebug() - { - return $this->debug; - } - - /** - * Add a new formatter to all tests of this task. - * - * @param SimpleTestFormatterElement formatter element - */ - function addFormatter(SimpleTestFormatterElement $fe) - { - $this->formatters[] = $fe; - } - - /** - * Add a new fileset containing the XML results to aggregate - * - * @param FileSet the new fileset containing XML results. - */ - function addFileSet(FileSet $fileset) - { - $this->filesets[] = $fileset; - } - - /** - * Iterate over all filesets and return the filename of all files - * that end with .php. - * - * @return array an array of filenames - */ - private function getFilenames() - { - $filenames = array(); - - foreach ($this->filesets as $fileset) - { - $ds = $fileset->getDirectoryScanner($this->project); - $ds->scan(); - - $files = $ds->getIncludedFiles(); - - foreach ($files as $file) - { - if (strstr($file, ".php")) - { - $filenames[] = $ds->getBaseDir() . "/" . $file; - } - } - } - - return $filenames; - } - - /** - * The main entry point - * - * @throws BuildException - */ - function main() - { - $suite= new TestSuite(); - - $filenames = $this->getFilenames(); - - foreach ($filenames as $testfile) - { - $suite->addFile($testfile); - } - - if ($this->debug) - { - $fe = new SimpleTestFormatterElement(); - $fe->setType('debug'); - $fe->setUseFile(false); - $this->formatters[] = $fe; - } - - if ($this->printsummary) - { - $fe = new SimpleTestFormatterElement(); - $fe->setType('summary'); - $fe->setUseFile(false); - $this->formatters[] = $fe; - } - - foreach ($this->formatters as $fe) - { - $formatter = $fe->getFormatter(); - $formatter->setProject($this->getProject()); - - if ($fe->getUseFile()) - { - $destFile = new PhingFile($fe->getToDir(), $fe->getOutfile()); - - $writer = new FileWriter($destFile->getAbsolutePath()); - - $formatter->setOutput($writer); - } - else - { - $formatter->setOutput($this->getDefaultOutput()); - } - } - - $this->execute($suite); - - if ($this->testfailed && $this->formatters[0]->getFormatter() instanceof SimpleTestDebugResultFormatter ) - { - $this->getDefaultOutput()->write("Failed tests: "); - $this->formatters[0]->getFormatter()->printFailingTests(); - } - - if ($this->testfailed) - { - throw new BuildException("One or more tests failed"); - } - } - - private function execute($suite) - { - $counter = new SimpleTestCountResultFormatter(); - $reporter = new MultipleReporter(); - $reporter->attachReporter($counter); - - foreach ($this->formatters as $fe) - { - // SimpleTest 1.0.1 workaround - $formatterList[] = $fe->getFormatter(); - - $reporter->attachReporter(end($formatterList)); - } - - $suite->run($reporter); - - $retcode = $counter->getRetCode(); - - if ($retcode == SimpleTestCountResultFormatter::ERRORS) - { - if ($this->errorproperty) - { - $this->project->setNewProperty($this->errorproperty, true); - } - - if ($this->haltonerror) - { - $this->testfailed = true; - } - } - elseif ($retcode == SimpleTestCountResultFormatter::FAILURES) - { - if ($this->failureproperty) - { - $this->project->setNewProperty($this->failureproperty, true); - } - - if ($this->haltonfailure) - { - $this->testfailed = true; - } - } - } - - private function getDefaultOutput() - { - return new LogWriter($this); - } -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php b/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php deleted file mode 100755 index 5ffa668b..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php +++ /dev/null @@ -1,178 +0,0 @@ -<?php -/** - * $Id: 03b9f976a961a2688d51c9429087a98c31326f42 $ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information please see - * <http://phing.info>. - */ - -require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; -require_once 'simpletest/xml.php'; - -/** - * Prints plain text output of the test to a specified Writer. - * - * @author Michiel Rook <mrook@php.net> - * @version $Id: 03b9f976a961a2688d51c9429087a98c31326f42 $ - * @package phing.tasks.ext.simpletest - * @since 2.2.0 - */ -class SimpleTestXmlResultFormatter extends SimpleTestResultFormatter -{ - /** - * @var XmlReporter - */ - private $logger = NULL; - - private $xmlData = ""; - - function __construct() - { - $this->logger = new XmlReporter(); - } - - function getExtension() - { - return ".xml"; - } - - function getPreferredOutfile() - { - return "testsuites"; - } - - private function captureStart() - { - ob_start(); - } - - private function captureStop() - { - $this->xmlData .= ob_get_contents(); - ob_end_clean(); - } - - function paintGroupStart($test_name, $size) - { - parent::paintGroupStart($test_name, $size); - - $this->captureStart(); - $this->logger->paintGroupStart($test_name, $size); - $this->captureStop(); - } - - function paintGroupEnd($test_name) - { - parent::paintGroupEnd($test_name); - - $this->captureStart(); - $this->logger->paintGroupEnd($test_name); - $this->captureStop(); - - if (count($this->_test_stack) == 0) - { - if ($this->out) - { - $this->out->write($this->xmlData); - $this->out->close(); - } - } - } - - function paintCaseStart($test_name) - { - $this->captureStart(); - $this->logger->paintCaseStart($test_name); - $this->captureStop(); - } - - function paintCaseEnd($test_name) - { - $this->captureStart(); - $this->logger->paintCaseEnd($test_name); - $this->captureStop(); - } - - function paintMethodStart($test_name) - { - $this->captureStart(); - $this->logger->paintMethodStart($test_name); - $this->captureStop(); - } - - function paintMethodEnd($test_name) - { - $this->captureStart(); - $this->logger->paintMethodEnd($test_name); - $this->captureStop(); - } - - function paintPass($message) - { - $this->captureStart(); - $this->logger->paintPass($message); - $this->captureStop(); - } - - function paintError($message) - { - $this->captureStart(); - $this->logger->paintError($message); - $this->captureStop(); - } - - function paintFail($message) - { - $this->captureStart(); - $this->logger->paintFail($message); - $this->captureStop(); - } - - function paintException($exception) - { - $this->captureStart(); - $this->logger->paintException($exception); - $this->captureStop(); - } - - function paintSkip($message) - { - $this->captureStart(); - $this->logger->paintSkip($message); - $this->captureStop(); - } - - function paintMessage($message) - { - $this->captureStart(); - $this->logger->paintMessage($message); - $this->captureStop(); - } - - function paintFormattedMessage($message) - { - $this->captureStart(); - $this->logger->paintFormattedMessage($message); - $this->captureStop(); - } - - function paintSignal($type, $payload) - { - $this->captureStart(); - $this->logger->paintSignal($type, $payload); - $this->captureStop(); - } -} |