/** * The main entry point * * @throws BuildException */ public function main() { if ($this->codecoverage && !extension_loaded('xdebug')) { throw new Exception("PHPUnitTask depends on Xdebug being installed to gather code coverage information."); } $this->loadPHPUnit(); $suite = new PHPUnit_Framework_TestSuite('AllTests'); if ($this->configuration) { $arguments = $this->handlePHPUnitConfiguration($this->configuration); if ($arguments['backupGlobals'] === false) { $suite->setBackupGlobals(false); } if ($arguments['backupStaticAttributes'] === true) { $suite->setBackupStaticAttributes(true); } } if ($this->printsummary) { $fe = new FormatterElement(); $fe->setParent($this); $fe->setType("summary"); $fe->setUseFile(false); $this->formatters[] = $fe; } $autoloadSave = spl_autoload_functions(); if ($this->bootstrap) { require $this->bootstrap; } foreach ($this->batchtests as $batchTest) { $this->appendBatchTestToTestSuite($batchTest, $suite); } $this->execute($suite); if ($this->testfailed) { throw new BuildException($this->testfailuremessage); } $autoloadNew = spl_autoload_functions(); foreach ($autoloadNew as $autoload) { spl_autoload_unregister($autoload); } foreach ($autoloadSave as $autoload) { spl_autoload_register($autoload); } }
/** * The main entry point * * @throws BuildException */ public function main() { if ($this->codecoverage && !extension_loaded('xdebug')) { throw new Exception("PHPUnitTask depends on Xdebug being installed to gather code coverage information."); } if ($this->printsummary) { $fe = new FormatterElement(); $fe->setParent($this); $fe->setType("summary"); $fe->setUseFile(false); $this->formatters[] = $fe; } $autoloadSave = spl_autoload_functions(); if ($this->bootstrap) { require_once $this->bootstrap; } $suite = new PHPUnit_Framework_TestSuite('AllTests'); foreach ($this->batchtests as $batchtest) { $batchtest->addToTestSuite($suite); } $this->execute($suite); if ($this->testfailed) { throw new BuildException($this->testfailuremessage); } $autoloadNew = spl_autoload_functions(); foreach ($autoloadNew as $autoload) { spl_autoload_unregister($autoload); } foreach ($autoloadSave as $autoload) { spl_autoload_register($autoload); } }
/** * The main entry point * * @throws BuildException */ function main() { $tests = array(); if ($this->printsummary) { $fe = new FormatterElement(); $fe->setType("summary"); $fe->setUseFile(false); $this->formatters[] = $fe; } foreach ($this->batchtests as $batchtest) { $tests = array_merge($tests, $batchtest->elements()); } 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()); } $formatter->startTestRun(); } foreach ($tests as $test) { $suite = NULL; if (PHPUnitUtil::$installedVersion == 3 && is_subclass_of($test, 'PHPUnit_Framework_TestSuite') || PHPUnitUtil::$installedVersion == 2 && is_subclass_of($test, 'PHPUnit2_Framework_TestSuite')) { if (is_object($test)) { $suite = $test; } else { $suite = new $test(); } } else { if (PHPUnitUtil::$installedVersion == 3) { require_once 'PHPUnit/Framework/TestSuite.php'; $suite = new PHPUnit_Framework_TestSuite(new ReflectionClass($test)); } else { require_once 'PHPUnit2/Framework/TestSuite.php'; $suite = new PHPUnit2_Framework_TestSuite(new ReflectionClass($test)); } } $this->execute($suite); } foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); $formatter->endTestRun(); } if ($this->testfailed) { throw new BuildException("One or more tests failed"); } }
/** * The main entry point * * @throws BuildException */ function main() { $tests = array(); if ($this->printsummary) { $fe = new FormatterElement(); $fe->setClassName('SummaryPHPUnit2ResultFormatter'); $fe->setUseFile(false); $this->formatters[] = $fe; } foreach ($this->batchtests as $batchtest) { $tests = array_merge($tests, $batchtest->elements()); } 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()); } $formatter->startTestRun(); } foreach ($tests as $test) { $this->execute(new PHPUnit2_Framework_TestSuite(new ReflectionClass($test))); } foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); $formatter->endTestRun(); } if ($this->testfailed) { throw new BuildException("One or more tests failed"); } }
/** * The main entry point * * @throws BuildException */ public function main() { if ($this->codecoverage && !extension_loaded('xdebug')) { throw new Exception("PHPUnitTask depends on Xdebug being installed to gather code coverage information."); } if ($this->printsummary) { $fe = new FormatterElement(); $fe->setParent($this); $fe->setType("summary"); $fe->setUseFile(false); $this->formatters[] = $fe; } if ($this->bootstrap) { require_once $this->bootstrap; } foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); if ($fe->getUseFile()) { $destFile = new PhingFile($fe->getToDir(), $fe->getOutfile()); $writer = new FileWriter($destFile->getAbsolutePath()); $formatter->setOutput($writer); } else { $formatter->setOutput($this->getDefaultOutput()); } $formatter->startTestRun(); } foreach ($this->batchtests as $batchtest) { $this->execute($batchtest->getTestSuite()); } foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); $formatter->endTestRun(); } if ($this->testfailed) { throw new BuildException($this->testfailuremessage); } }
/** * The main entry point * * @throws BuildException */ function main() { $tests = array(); if ($this->printsummary) { $fe = new FormatterElement(); $fe->setType("summary"); $fe->setUseFile(false); $this->formatters[] = $fe; } foreach ($this->batchtests as $batchtest) { $tests = array_merge($tests, $batchtest->elements()); } 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()); } $formatter->startTestRun(); } foreach ($tests as $test) { $this->execute($test); } foreach ($this->formatters as $fe) { $formatter = $fe->getFormatter(); $formatter->endTestRun(); } if ($this->testfailed) { throw new BuildException($this->testfailuremessage); } }