本文整理汇总了PHP中PHPUnit_TextUI_Command::main方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_TextUI_Command::main方法的具体用法?PHP PHPUnit_TextUI_Command::main怎么用?PHP PHPUnit_TextUI_Command::main使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_TextUI_Command
的用法示例。
在下文中一共展示了PHPUnit_TextUI_Command::main方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs PHPUnit.
*
* @return void
*/
public function run()
{
require_once 'PHPUnit/Autoload.php';
/** @var string */
define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
PHPUnit_TextUI_Command::main();
}
示例2: runAction
/**
* Should run tests in browser
* @param null $filterClass
*/
public function runAction($filterClass = null)
{
// Make sure PHPUnit is autoloaded
require_once 'PHPUnit/Autoload.php';
set_time_limit(3600);
$version = \PHPUnit_Runner_Version::id();
$kernel_dir = $this->container->getParameter('kernel.root_dir');
chdir($kernel_dir);
// This will force the printer class to be autoloaded by Symfony, before PHPUnit tries to (and does not) find it
$printerClass = 'Goutte\\DoodleBundle\\Tools\\PHPUnit\\HtmlResultPrinter';
if (!class_exists($printerClass)) {
$printerClass = false;
}
$argv = array();
$argv[] = 'phpunit';
if ($filterClass) {
$argv[] = '--filter';
$argv[] = $filterClass;
}
if (version_compare($version, "3.6.0") >= 0) {
if ($printerClass) {
$argv[] = '--printer';
$argv[] = $printerClass;
}
$_SERVER['argv'] = $argv;
\PHPUnit_TextUI_Command::main(true);
} else {
ob_end_clean();
echo '<pre>';
$_SERVER['argv'] = $argv;
\PHPUnit_TextUI_Command::main(false);
echo '</pre>';
exit;
}
}
示例3: run
/**
* Runs PHPUnit.
*
* @return void
*/
public function run()
{
// Store current TYPO3 configuration and set the default one
// This is needed as the configuration might include closures which cannot be backed up
$globalBackup = $this->removeClosures($GLOBALS['TYPO3_CONF_VARS']);
// Run unit tests
/** @var string */
define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
PHPUnit_TextUI_Command::main();
// Restore configuration
$GLOBALS['TYPO3_CONF_VARS'] = array_merge($GLOBALS['TYPO3_CONF_VARS'], $globalBackup);
}
示例4: foreach
$ok = false;
if (class_exists('PHPUnit_TextUI_Command')) {
echo "PHPUnit already present\n";
$ok = true;
} else {
foreach (array(stream_resolve_include_path('phpunit.phar'), stream_resolve_include_path('phpunit-old.phar'), 'PHPUnit/Runner/Version.php', 'PHPUnit/Autoload.php') as $includePath) {
if ($includePath === false) {
// stream_resolve_include_path can return false
continue;
}
\MediaWiki\suppressWarnings();
include_once $includePath;
\MediaWiki\restoreWarnings();
if (class_exists('PHPUnit_TextUI_Command')) {
$ok = true;
echo "Using PHPUnit from {$includePath}\n";
break;
}
}
}
if (!$ok) {
echo "Couldn't find a usable PHPUnit.\n";
exit(1);
}
$puVersion = PHPUnit_Runner_Version::id();
if ($puVersion !== '@package_version@' && version_compare($puVersion, '3.7.0', '<')) {
echo "PHPUnit 3.7.0 or later required; you have {$puVersion}.\n";
exit(1);
}
PHPUnit_TextUI_Command::main();
示例5: catch
<?php
require_once __DIR__ . '/vendor/autoload.php';
use SPE\Core\TestController;
use SPE\CKlein\Reports\ConsolidatedReport;
try {
PHPUnit_TextUI_Command::main(false);
} catch (Exception $e) {
}
if (TestController::isTestSuccessful()) {
echo "generate consolidation report";
$consolidatedReport = new ConsolidatedReport($argv);
$consolidatedReport->generate();
} else {
echo "in shutdown";
TestController::shutdown();
}
示例6: runTest
/**
* Run Both Unit-test and Code-coverage analysist
*
* @param string Path to Test (Juriya idiomatic style directory structure is required)
* @return stream
*/
public static function runTest($target = '')
{
$paths = explode(PATH_SEPARATOR, get_include_path());
$pwd = $_SERVER['PWD'];
if (!$target) {
self::out('--test command missed target folder');
} else {
// Find configuration definition
$configuration = '';
$configurationExists = FALSE;
if (file_exists($pwd . DIRECTORY_SEPARATOR . 'phpunit.xml')) {
$configuration = $pwd . DIRECTORY_SEPARATOR . 'phpunit.xml';
$configurationExists = TRUE;
} elseif (($path = $pwd . DIRECTORY_SEPARATOR . $target) && is_dir($path)) {
if (($testSrc = $path . DIRECTORY_SEPARATOR . 'Tests') && is_dir($testSrc)) {
$configuration = $testSrc . DIRECTORY_SEPARATOR . 'phpunit.xml';
}
} else {
foreach ($paths as $path) {
if (($testSrc = $path . DIRECTORY_SEPARATOR . $target . DIRECTORY_SEPARATOR . 'Tests') && is_dir($testSrc)) {
$configuration = $testSrc . DIRECTORY_SEPARATOR . 'phpunit.xml';
break 1;
}
}
}
// Garbage collection
$coveragePhp = '/tmp/coverage.php';
file_exists($coveragePhp) and File::delete($coveragePhp);
// Try to read the configuration
try {
$configurationInstance = \PHPUnit_Util_Configuration::getInstance($configuration);
} catch (\Exception $e) {
print $e->getMessage() . "\n";
exit(\PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
$configurationArray = $configurationInstance->getPHPUnitConfiguration();
// Validate test suites before start processing furthermore
$testDirectory = new \DirectoryIterator(str_replace('phpunit.xml', '', $configuration));
$validTestSuite = FALSE;
while ($testDirectory->valid()) {
if ($testDirectory->isFile() && strpos($testDirectory->getFilename(), 'Test.php') !== FALSE) {
$validTestSuite = TRUE;
}
$testDirectory->next();
}
if (!$validTestSuite) {
$errorText = 'ERROR: ' . I18n::translate('command_testsuite_not_found');
if ($configurationArray['colors'] === TRUE) {
$errorText = Utility::getColoredString($errorText, 'black', 'red');
}
self::out($errorText);
exit(\PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
// Reset server arguments
$_SERVER['argv'] = array('--configuration', $configuration, '--coverage-php', $coveragePhp);
// Preparing reports
$strippedText = 'Generating code coverage report in PHP format ... done';
$reportTestTitle = 'PHPUnit Report : ';
self::out($configurationArray['colors'] ? Utility::getColoredString($reportTestTitle, 'yellow') : $reportTestTitle);
$reportCcTitle = 'CodeCoverage Report : ';
$reportCcTitle = $configurationArray['colors'] ? Utility::getColoredString($reportCcTitle, 'yellow') : $reportCcTitle;
// Get phpunit report
ob_start();
$exitCode = \PHPUnit_TextUI_Command::main(FALSE);
$out = ob_get_clean();
$report = substr($out, strpos($out, "\n\n") + 1);
$unitTestReport = str_replace($strippedText, $reportCcTitle, $report);
$codeCoverage = @unserialize(File::read($coveragePhp));
$codeCoverageData = $codeCoverage->getData();
$codeCoverageRoot = $codeCoverage->getReport();
$codeCoverageNodes = $codeCoverageRoot->getChildNodes();
// Generate code coverage report
$classCoverage = array();
$overallCoverage = array('totalClasses' => 0, 'totalCoveredClasses' => 0, 'totalMethods' => 0, 'totalCoveredMethods' => 0, 'totalLines' => 0, 'totalCoveredLines' => 0);
// Closure for calculate the level
$calculate = function ($percentages) {
$level = 'gray';
if ($percentages >= 75) {
$level = 'green';
} elseif ($percentages < 75 && $percentages >= 50) {
$level = 'yellow';
} elseif ($percentages < 50 && $percentages >= 25) {
$level = 'magenta';
} else {
$level = 'red';
}
return $level;
};
$collectFromNode = function ($node) {
$classes = array_merge($node->getClasses(), $node->getTraits());
$coverage = $node->getCoverageData();
$lines = array();
$ignoredLines = $node->getIgnoredLines();
foreach ($classes as $className => $class) {
//.........这里部分代码省略.........
示例7: fire
/**
* Execute the command
*
* @return void
*/
public function fire()
{
$_SERVER['argv'] = array_slice($_SERVER['argv'], 2);
\PHPUnit_TextUI_Command::main(false);
}
示例8: main
public static function main($exit = TRUE)
{
return parent::main($exit);
}
示例9: run
/**
* Runs PHPUnit.
*
* @return void
*/
public function run()
{
/** @var string */
define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
PHPUnit_TextUI_Command::main();
}