Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Close #248.

  • Loading branch information...
commit dc277fed61fb0071d561a5ea7f979ae6c9fe1420 1 parent eb3319d
@sebastianbergmann authored
View
9 PHPUnit/TextUI/TestRunner.php
@@ -246,6 +246,10 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) {
$arguments['xmlLogfile'] = $loggingConfiguration['test-xml'];
+
+ if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
+ $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
+ }
}
if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
@@ -267,6 +271,7 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
$arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5;
$arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70;
+ $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
$arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1';
$arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
$arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
@@ -355,7 +360,9 @@ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
if (isset($arguments['xmlLogfile'])) {
$result->addListener(
- new PHPUnit_Util_Log_XML($arguments['xmlLogfile'])
+ new PHPUnit_Util_Log_XML(
+ $arguments['xmlLogfile'], $arguments['logIncompleteSkipped']
+ )
);
}
View
32 PHPUnit/Util/Configuration.php
@@ -67,7 +67,7 @@
* <log type="plain" target="/tmp/logfile.txt"/>
* <log type="pmd-xml" target="/tmp/pmd.xml" cpdMinLines="5" cpdMinMatches="70"/>
* <log type="tap" target="/tmp/logfile.tap"/>
- * <log type="test-xml" target="/tmp/logfile.xml"/>
+ * <log type="test-xml" target="/tmp/logfile.xml" logIncompleteSkipped="false"/>
* <log type="testdox-html" target="/tmp/testdox.html"/>
* <log type="testdox-text" target="/tmp/testdox.txt"/>
*
@@ -141,16 +141,6 @@ public function getLoggingConfiguration()
$type = (string)$log->getAttribute('type');
$target = (string)$log->getAttribute('target');
- if ($type == 'pmd-xml') {
- if ($log->hasAttribute('cpdMinLines')) {
- $result['cpdMinLines'] = (string)$log->getAttribute('cpdMinLines');
- }
-
- if ($log->hasAttribute('cpdMinMatches')) {
- $result['cpdMinMatches'] = (string)$log->getAttribute('cpdMinMatches');
- }
- }
-
if ($type == 'coverage-html') {
if ($log->hasAttribute('charset')) {
$result['charset'] = (string)$log->getAttribute('charset');
@@ -173,6 +163,26 @@ public function getLoggingConfiguration()
}
}
+ else if ($type == 'pmd-xml') {
+ if ($log->hasAttribute('cpdMinLines')) {
+ $result['cpdMinLines'] = (string)$log->getAttribute('cpdMinLines');
+ }
+
+ if ($log->hasAttribute('cpdMinMatches')) {
+ $result['cpdMinMatches'] = (string)$log->getAttribute('cpdMinMatches');
+ }
+ }
+
+ else if ($type == 'test-xml') {
+ if ($log->hasAttribute('logIncompleteSkipped')) {
+ if ((string)$log->getAttribute('logIncompleteSkipped') == 'true') {
+ $result['logIncompleteSkipped'] = TRUE;
+ } else {
+ $result['logIncompleteSkipped'] = FALSE;
+ }
+ }
+ }
+
$result[$type] = $target;
}
View
105 PHPUnit/Util/Log/XML.php
@@ -82,6 +82,12 @@ class PHPUnit_Util_Log_XML extends PHPUnit_Util_Printer implements PHPUnit_Frame
* @var boolean
* @access protected
*/
+ protected $logIncompleteSkipeed = FALSE;
+
+ /**
+ * @var boolean
+ * @access protected
+ */
protected $writeDocument = TRUE;
/**
@@ -127,12 +133,19 @@ class PHPUnit_Util_Log_XML extends PHPUnit_Util_Printer implements PHPUnit_Frame
protected $currentTestCase = NULL;
/**
+ * @var boolean
+ * @access protected
+ */
+ protected $attachCurrentTestCase = TRUE;
+
+ /**
* Constructor.
*
- * @param mixed $out
+ * @param mixed $out
+ * @param boolean $logIncompleteSkipped
* @access public
*/
- public function __construct($out = NULL)
+ public function __construct($out = NULL, $logIncompleteSkipped = FALSE)
{
$this->document = new DOMDocument('1.0', 'UTF-8');
$this->document->formatOutput = TRUE;
@@ -141,6 +154,8 @@ public function __construct($out = NULL)
$this->document->appendChild($this->root);
parent::__construct($out);
+
+ $this->logIncompleteSkipped = $logIncompleteSkipped;
}
/**
@@ -233,21 +248,25 @@ public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_Asser
*/
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
- $error = $this->document->createElement('error');
- $error->setAttribute('type', get_class($e));
-
- $error->appendChild(
- $this->document->createCDATASection(
- utf8_encode(
- "Incomplete Test\n" .
- PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE)
- )
- )
- );
-
- $this->currentTestCase->appendChild($error);
-
- $this->testSuiteErrors[$this->testSuiteLevel]++;
+ if ($this->logIncompleteSkipped) {
+ $error = $this->document->createElement('error');
+ $error->setAttribute('type', get_class($e));
+
+ $error->appendChild(
+ $this->document->createCDATASection(
+ utf8_encode(
+ "Incomplete Test\n" .
+ PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE)
+ )
+ )
+ );
+
+ $this->currentTestCase->appendChild($error);
+
+ $this->testSuiteErrors[$this->testSuiteLevel]++;
+ } else {
+ $this->attachCurrentTestCase = FALSE;
+ }
}
/**
@@ -261,21 +280,25 @@ public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $t
*/
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{
- $error = $this->document->createElement('error');
- $error->setAttribute('type', get_class($e));
-
- $error->appendChild(
- $this->document->createCDATASection(
- utf8_encode(
- "Skipped Test\n" .
- PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE)
- )
- )
- );
-
- $this->currentTestCase->appendChild($error);
-
- $this->testSuiteErrors[$this->testSuiteLevel]++;
+ if ($this->logIncompleteSkipped) {
+ $error = $this->document->createElement('error');
+ $error->setAttribute('type', get_class($e));
+
+ $error->appendChild(
+ $this->document->createCDATASection(
+ utf8_encode(
+ "Skipped Test\n" .
+ PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE)
+ )
+ )
+ );
+
+ $this->currentTestCase->appendChild($error);
+
+ $this->testSuiteErrors[$this->testSuiteLevel]++;
+ } else {
+ $this->attachCurrentTestCase = FALSE;
+ }
}
/**
@@ -370,10 +393,7 @@ public function startTest(PHPUnit_Framework_Test $test)
$testCase->setAttribute('class', $class->getName());
$testCase->setAttribute('file', $class->getFileName());
- $this->testSuites[$this->testSuiteLevel]->appendChild($testCase);
$this->currentTestCase = $testCase;
-
- $this->testSuiteTests[$this->testSuiteLevel]++;
}
/**
@@ -385,10 +405,19 @@ public function startTest(PHPUnit_Framework_Test $test)
*/
public function endTest(PHPUnit_Framework_Test $test, $time)
{
- $this->currentTestCase->setAttribute('time', sprintf('%F', $time));
- $this->testSuiteTimes[$this->testSuiteLevel] += $time;
+ if ($this->attachCurrentTestCase) {
+ $this->currentTestCase->setAttribute('time', sprintf('%F', $time));
+
+ $this->testSuites[$this->testSuiteLevel]->appendChild(
+ $this->currentTestCase
+ );
+
+ $this->testSuiteTests[$this->testSuiteLevel]++;
+ $this->testSuiteTimes[$this->testSuiteLevel] += $time;
+ }
- $this->currentTestCase = NULL;
+ $this->currentTestCase = NULL;
+ $this->attachCurrentTestCase = TRUE;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.