Permalink
Browse files

Fixes #751 - add initial support for import of phpunit.xml

  • Loading branch information...
1 parent ce4b503 commit 3a9d905109e4f85947edb3faf2d6a551c5f195e6 @mrook mrook committed Aug 14, 2012
View
67 classes/phing/tasks/ext/phpunit/PHPUnitTask.php
@@ -54,6 +54,11 @@ class PHPUnitTask extends Task
private $excludeGroups = array();
private $processIsolation = false;
private $usecustomerrorhandler = true;
+
+ /**
+ * @var PhingFile
+ */
+ private $configuration = null;
/**
* Initialize Task.
@@ -212,6 +217,62 @@ public function addFormatter(FormatterElement $fe)
$fe->setParent($this);
$this->formatters[] = $fe;
}
+
+ /**
+ * @param PhingFile $configuration
+ */
+ public function setConfiguration(PhingFile $configuration)
+ {
+ $this->configuration = $configuration;
+ }
+
+ /**
+ * Load and processes the PHPUnit configuration
+ */
+ protected function handlePHPUnitConfiguration($configuration)
+ {
+ if (!$configuration->exists()) {
+ throw new BuildException("Unable to find PHPUnit configuration file '" . (string) $configuration . "'");
+ }
+
+ $config = PHPUnit_Util_Configuration::getInstance($configuration->getAbsolutePath());
+
+ if (empty($configuration)) {
+ return;
+ }
+
+ $phpunit = $config->getPHPUnitConfiguration();
+
+ if (empty($phpunit)) {
+ return;
+ }
+
+ $config->handlePHPConfiguration();
+
+ if (isset($phpunit['bootstrap'])) {
+ $this->setBootstrap($phpunit['bootstrap']);
+ }
+
+ if (isset($phpunit['stopOnFailure'])) {
+ $this->setHaltonfailure($phpunit['stopOnFailure']);
+ }
+
+ if (isset($phpunit['stopOnError'])) {
+ $this->setHaltonerror($phpunit['stopOnError']);
+ }
+
+ if (isset($phpunit['stopOnFailure'])) {
+ $this->setHaltonskipped($phpunit['stopOnSkipped']);
+ }
+
+ if (isset($phpunit['stopOnIncomplete'])) {
+ $this->setHaltonincomplete($phpunit['stopOnIncomplete']);
+ }
+
+ if (isset($phpunit['processIsolation'])) {
+ $this->setProcessIsolation($phpunit['processIsolation']);
+ }
+ }
/**
* The main entry point
@@ -224,7 +285,11 @@ public function main()
{
throw new Exception("PHPUnitTask depends on Xdebug being installed to gather code coverage information.");
}
-
+
+ if ($this->configuration) {
+ $this->handlePHPUnitConfiguration($this->configuration);
+ }
+
if ($this->printsummary)
{
$fe = new FormatterElement();
View
15 docs/docbook5/en/source/appendixes/optionaltasks.xml
@@ -7093,6 +7093,21 @@ Note that you can omit both startpoint and track attributes in this case
<entry><literal>false</literal></entry>
<entry>No</entry>
</row>
+ <row>
+ <entry><literal>configuration</literal></entry>
+ <entry><literal role="type">String</literal></entry>
+ <entry>Path to a PHPUnit configuration file (such as
+ <literal>phpunit.xml</literal>). Supported elements are:
+ <literal>bootstrap</literal>,
+ <literal>processIsolation</literal>,
+ <literal>stopOnFailure</literal>,
+ <literal>stopOnError</literal>,
+ <literal>stopOnIncomplete</literal> and
+ <literal>stopOnSkipped</literal>. Values provided
+ <emphasis role="bold">overwrite</emphasis> other attributes!</entry>
+ <entry>n/a</entry>
+ <entry>No</entry>
+ </row>
</tbody>
</tgroup>
</table>
View
11 docs/phing_guide/book/chapters/appendixes/AppendixC-OptionalTasks.html
@@ -6303,6 +6303,17 @@
<td>false</td>
<td>No</td>
</tr>
+ <tr>
+ <td>configuration</td>
+ <td>String</td>
+ <td>Path to a PHPUnit configuration file (such as
+ <em>phpunit.xml</em>). Supported
+ elements are: <em>bootstrap</em>, <em>processIsolation</em>, <em>stopOnFailure</em>,
+ <em>stopOnError</em>, <em>stopOnIncomplete</em> and <em>stopOnSkipped</em>.
+ Values provided <b>overwrite</b> other attributes!</td>
+ <td>n/a</td>
+ <td>No</td>
+ </tr>
</tbody>
</table>
<h3>Supported Nested Tags</h3>

0 comments on commit 3a9d905

Please sign in to comment.