本文整理汇总了PHP中PHPUnit_TextUI_TestRunner::doRun方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_TextUI_TestRunner::doRun方法的具体用法?PHP PHPUnit_TextUI_TestRunner::doRun怎么用?PHP PHPUnit_TextUI_TestRunner::doRun使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_TextUI_TestRunner
的用法示例。
在下文中一共展示了PHPUnit_TextUI_TestRunner::doRun方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
public static function dispatch($arguments = array())
{
$GLOBALS['__PHPUNIT_BOOTSTRAP'] = dirname(__FILE__) . '/templates/AgaviBootstrap.tpl.php';
$suites = (include AgaviConfigCache::checkConfig(AgaviConfig::get('core.testing_dir') . '/config/suites.xml'));
$master_suite = new AgaviTestSuite('Master');
if (!empty($arguments['include-suite'])) {
$names = explode(',', $arguments['include-suite']);
unset($arguments['include-suite']);
foreach ($names as $name) {
if (empty($suites[$name])) {
throw new InvalidArgumentException(sprintf('Invalid suite name %1$s.', $name));
}
$master_suite->addTest(self::createSuite($name, $suites[$name]));
}
} else {
$excludes = array();
if (!empty($arguments['exclude-suite'])) {
$excludes = explode(',', $arguments['exclude-suite']);
unset($arguments['exclude-suite']);
}
foreach ($suites as $name => $suite) {
if (!in_array($name, $excludes)) {
$master_suite->addTest(self::createSuite($name, $suite));
}
}
}
$runner = new PHPUnit_TextUI_TestRunner();
$runner->doRun($master_suite, $arguments);
}
示例2: main
public function main()
{
if (!is_dir(realpath($this->testdirectory))) {
throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '" . $this->testdirectory . "' given.");
}
set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path());
$printer = new NativePhpunitPrinter();
$arguments = array('configuration' => $this->configuration, 'coverageClover' => $this->coverageClover, 'junitLogfile' => $this->junitlogfile, 'printer' => $printer);
require_once "PHPUnit/TextUI/TestRunner.php";
$runner = new PHPUnit_TextUI_TestRunner();
$suite = $runner->getTest($this->test, $this->testfile, true);
try {
$result = $runner->doRun($suite, $arguments);
/* @var $result PHPUnit_Framework_TestResult */
if ($this->haltonfailure && $result->failureCount() > 0 || $this->haltonerror && $result->errorCount() > 0) {
throw new BuildException("PHPUnit: " . $result->failureCount() . " Failures and " . $result->errorCount() . " Errors, " . "last failure message: " . $printer->getMessages());
}
$this->log("PHPUnit Success: " . count($result->passed()) . " tests passed, no " . "failures (" . $result->skippedCount() . " skipped, " . $result->notImplementedCount() . " not implemented)");
// Hudson for example doesn't like the backslash in class names
if (file_exists($this->coverageClover)) {
$this->log("Generated Clover Coverage XML to: " . $this->coverageClover);
$content = file_get_contents($this->coverageClover);
$content = str_replace("\\", ".", $content);
file_put_contents($this->coverageClover, $content);
unset($content);
}
} catch (\Exception $e) {
throw new BuildException("NativePhpunitTask failed: " . $e->getMessage());
}
}
示例3: doRun
/**
* Uses a random test suite to randomize the given test suite, and in case that no printer
* has been selected, uses printer that shows the random seed used to randomize.
*
* @param PHPUnit_Framework_Test $suite TestSuite to execute
* @param array $arguments Arguments to use
*/
public function doRun(\PHPUnit_Framework_Test $suite, array $arguments = array())
{
$this->handleConfiguration($arguments);
if (isset($arguments['order'])) {
$this->addPrinter($arguments);
$randomizer = new Randomizer();
$randomizer->randomizeTestSuite($suite, $arguments['seed']);
}
return parent::doRun($suite, $arguments);
}
示例4: execute
protected function execute($arguments = array(), $options = array())
{
// $initTask = new sfPhpunitInitTask($this->dispatcher, $this->formatter);
// $initTask->run();
chdir(sfConfig::get('sf_root_dir'));
shell_exec('./symfony phpunit:init');
$path = $arguments['test'];
sfBasePhpunitTestSuite::setProjectConfiguration($this->configuration);
$runner = new PHPUnit_TextUI_TestRunner();
$runner->doRun(sfPhpunitSuiteLoader::factory($path)->getSuite());
}
示例5: run
/**
* @param PHPUnit_Framework_Test|ReflectionClass $test
* @param array $arguments
* @return PHPUnit_Framework_TestResult
* @throws PHPUnit_Framework_Exception
*/
public static function run($test, array $arguments = array())
{
if ($test instanceof ReflectionClass) {
$test = new PHPUnit_Framework_TestSuite($test);
}
if ($test instanceof PHPUnit_Framework_Test) {
$aTestRunner = new PHPUnit_TextUI_TestRunner();
return $aTestRunner->doRun($test, $arguments);
} else {
throw new PHPUnit_Framework_Exception('No test case or test suite found.');
}
}
示例6: doRun
/**
* @param PHPUnit_Framework_Test $suite
* @param array $arguments
* @return PHPUnit_Framework_TestResult
*/
public function doRun(\PHPUnit_Framework_Test $suite, array $arguments = array())
{
$this->handleConfiguration($arguments);
if ($this->printer === NULL) {
if (isset($arguments['printer']) && $arguments['printer'] instanceof \PHPUnit_Util_Printer) {
$this->printer = $arguments['printer'];
} else {
$this->printer = new ResultPrinter(NULL, !$arguments['verbose'], $arguments['colors'], $arguments['debug']);
}
}
// supress the version string if we're not verbose
if (!$arguments['verbose']) {
self::$versionStringPrinted = true;
}
return parent::doRun($suite, $arguments);
}
示例7: run
public function run(rex_test_locator $locator, $colors = false)
{
$suite = new PHPUnit_Framework_TestSuite();
// disable backup of globals, since we have some rex_sql objectes referenced from variables in global space.
// PDOStatements are not allowed to be serialized
$suite->setBackupGlobals(false);
$suite->addTestFiles($locator->getIterator());
rex_error_handler::unregister();
$runner = new PHPUnit_TextUI_TestRunner();
$backtrace = debug_backtrace(false);
array_unshift($backtrace, ['file' => __FILE__, 'line' => __LINE__ + 3]);
$runner->setPrinter(new rex_tests_result_printer($backtrace, $colors));
$result = $runner->doRun($suite);
rex_error_handler::register();
return $result;
}
示例8: doRun
/**
* Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager
*
* @param PHPUnit_Framework_Test $suite
* @param array $arguments
* @return void
*/
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
{
if (isset($arguments['printer'])) {
self::$versionStringPrinted = true;
}
$fixture = $this->_getFixtureManager($arguments);
foreach ($suite->getIterator() as $test) {
if ($test instanceof CakeTestCase) {
$fixture->fixturize($test);
$test->fixtureManager = $fixture;
}
}
$return = parent::doRun($suite, $arguments);
$fixture->shutdown();
return $return;
}
示例9: runTest
private static function runTest(PHPUnit_Framework_TestSuite $test, $arguments)
{
$test->setName('eCamp UnitTests');
global $doConvertErrorToExceptions;
$doConvertErrorToExceptions = true;
// Create a xml listener object
$listener = new PHPUnit_Util_Log_JUnit();
// Create TestResult object and pass the xml listener to it
$testResult = new PHPUnit_Framework_TestResult();
$testResult->addListener($listener);
$arguments['printer'] = new SilentTestListener();
$runner = new PHPUnit_TextUI_TestRunner();
$runner->doRun($test, $arguments);
// Run the TestSuite
$result = $test->run($testResult);
// Get the results from the listener
$xml_result = $listener->getXML();
return $xml_result;
$doConvertErrorToExceptions = false;
}
示例10: doRun
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
{
$handlesArguments = $arguments;
$this->handleConfiguration($handlesArguments);
$this->_retryOnError = $handlesArguments['retryOnError'];
if (!$handlesArguments['noProgress'] && file_exists('/www/testtimes')) {
$expectedTimes = array();
$unknownTimes = 0;
$tests = $suite->getFilteredTests($handlesArguments['filter'], $handlesArguments['groups'], $handlesArguments['excludeGroups']);
foreach ($tests as $test) {
$app = Kwf_Registry::get('config')->application->id;
$f = "/www/testtimes/{$app}/{$test->toString()}";
if (isset($expectedTimes[$test->toString()])) {
throw new Kwf_Exception("same test exists twice?!");
}
if (file_exists($f)) {
$expectedTimes[$test->toString()] = (double) file_get_contents($f);
} else {
if ($test instanceof PHPUnit_Extensions_SeleniumTestCase) {
$expectedTimes[$test->toString()] = 15;
} else {
$expectedTimes[$test->toString()] = 1;
}
$unknownTimes++;
}
}
if (!$expectedTimes || $unknownTimes / count($expectedTimes) > 0.2) {
$expectedTimes = array();
}
$printer = new Kwf_Test_ProgressResultPrinter($expectedTimes, null, $handlesArguments['verbose'], true);
$this->setPrinter($printer);
} else {
if ($handlesArguments['verbose']) {
$printer = new Kwf_Test_VerboseResultPrinter(null, true);
$this->setPrinter($printer);
}
}
return parent::doRun($suite, $arguments);
}
示例11: runHtml
/**
* Run the tests
*
* @param array $arguments arguments, options, for the PHPUnit::TestRunner
*/
public function runHtml($arguments = array())
{
try {
echo '<pre>';
$runner = new PHPUnit_TextUI_TestRunner();
$result = $runner->doRun($this->suite, $arguments);
if (isset($arguments['reportDirectory'])) {
echo 'Code covarage reports can be found ';
echo '<a href="', str_replace(TESTS_ROOT . DS, '', $arguments['reportDirectory']), '">here</a>.';
}
echo '</pre>';
} catch (Exception $e) {
throw new RuntimeException("Could not create and run test suite: {$e->getMessage()}");
}
if ($result->wasSuccessful()) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} else {
if ($result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}
}
示例12: _doRunTests
/** Initialize the PHPUnit test runner and run tests.
*
* @param string[] $options
*
* @return void
*/
private function _doRunTests(array $options)
{
if (empty($options['plugin'])) {
$basedir = null;
} else {
try {
/* @var $config sfPluginConfiguration */
/** @noinspection PhpUndefinedMethodInspection */
$config = $this->configuration->getPluginConfiguration($options['plugin']);
} catch (InvalidArgumentException $e) {
throw new sfException(sprintf('Plugin "%s" does not exist or is not enabled.', $options['plugin']));
}
$basedir = implode(DIRECTORY_SEPARATOR, array($config->getRootDir(), 'test', ''));
unset($options['plugin']);
}
if ($files = $this->_findTestFiles($this->_type, (array) $this->_paths, $basedir)) {
/** @noinspection PhpIncludeInspection */
require_once 'PHPUnit' . DIRECTORY_SEPARATOR . 'TextUI' . DIRECTORY_SEPARATOR . 'TestRunner.php';
$Runner = new PHPUnit_TextUI_TestRunner();
$Suite = new PHPUnit_Framework_TestSuite(ucfirst($this->name) . ' Tests');
$Suite->addTestFiles($files);
/* Inject the command application controller so that it is accessible to
* test cases.
*/
Test_Case::setController($this->commandApplication);
/* Ignition... */
try {
$Runner->doRun($Suite, $options);
} catch (PHPUnit_Framework_Exception $e) {
$this->logSection('phpunit', $e->getMessage());
}
} else {
$this->logSection('phpunit', 'No tests found.');
}
}
示例13: exit
#!/usr/bin/env php
<?php
chdir(__DIR__);
$returnStatus = null;
passthru('composer install', $returnStatus);
if ($returnStatus !== 0) {
exit(1);
}
require 'vendor/autoload.php';
$phpcsCLI = new PHP_CodeSniffer_CLI();
$phpcsArguments = ['standard' => ['PSR1'], 'files' => ['src', 'tests', 'build.php'], 'warningSeverity' => 0];
$phpcsViolations = $phpcsCLI->process($phpcsArguments);
if ($phpcsViolations > 0) {
exit(1);
}
$phpunitConfiguration = PHPUnit_Util_Configuration::getInstance(__DIR__ . '/phpunit.xml');
$phpunitArguments = ['coverageHtml' => __DIR__ . '/coverage', 'configuration' => $phpunitConfiguration];
$testRunner = new PHPUnit_TextUI_TestRunner();
$result = $testRunner->doRun($phpunitConfiguration->getTestSuiteConfiguration(), $phpunitArguments);
if (!$result->wasSuccessful()) {
exit(1);
}
$cloverCoverage = new PHP_CodeCoverage_Report_Clover();
file_put_contents('clover.xml', $cloverCoverage->process($result->getCodeCoverage()));
$coverageFactory = new PHP_CodeCoverage_Report_Factory();
$coverageReport = $coverageFactory->create($result->getCodeCoverage());
if ($coverageReport->getNumExecutedLines() !== $coverageReport->getNumExecutableLines()) {
file_put_contents('php://stderr', "Code coverage was NOT 100%\n");
exit(1);
}
echo "Code coverage was 100%\n";
示例14: createTestSuiteForFile
echo "-> running standalone test units {$entry}\n";
try {
$suite = createTestSuiteForFile($entry);
$runner = new PHPUnit_TextUI_TestRunner();
$runner->doRun($suite);
} catch (Exception $e) {
echo "Exception during execution of {$entry}: " . $e->getMessage() . "\n\n";
}
}
exit(0);
}
$alltests = new PHPUnit_Framework_TestSuite();
foreach (new DirectoryIterator(dirname(__FILE__)) as $f) {
if ($f->isDot() || !$f->isFile()) {
continue;
}
if (preg_match('/(.*?Test).php$/', $f->getFileName())) {
$alltests->addTestSuite(createTestSuiteForFile($f->getPathName()));
}
}
$runner = new PHPUnit_TextUI_TestRunner();
$runner->doRun($alltests);
function createTestSuiteForFile($path)
{
require_once $path;
$classname = basename($path, '.php');
if (version_compare(PHP_VERSION, '5.3', '>=') && __NAMESPACE__) {
$classname = __NAMESPACE__ . '\\' . $classname;
}
return new PHPUnit_Framework_TestSuite($classname);
}
示例15:
+----------------------------------------------------------------------+
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you |
| may not use this file except in compliance with the License. You may |
| obtain a copy of the License at |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| implied. See the License for the specific language governing |
| permissions and limitations under the License. |
+----------------------------------------------------------------------+
| Author: Matthew Peters |
+----------------------------------------------------------------------+
*/
/**********************************************************
* Get a TestRunner
**********************************************************/
require_once "PHPUnit/TextUI/TestRunner.php";
$aTestRunner = new PHPUnit_TextUI_TestRunner();
/**********************************************************
* Get our test suite
/**********************************************************/
require_once 'TestSuite.php';
$suite = SCA_TestSuite::suite();
/**********************************************************
* Run it
/**********************************************************/
$result = $aTestRunner->doRun($suite);