本文整理汇总了PHP中PHPUnit_Util_Configuration类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Configuration类的具体用法?PHP PHPUnit_Util_Configuration怎么用?PHP PHPUnit_Util_Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Util_Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bootstrap
private function bootstrap(InputInterface $input, \PHPUnit_Util_Configuration $config)
{
$bootstrap = $input->getOption('bootstrap');
if (!$bootstrap && isset($config->getPHPUnitConfiguration()['bootstrap'])) {
$bootstrap = $config->getPHPUnitConfiguration()['bootstrap'];
}
if ($bootstrap) {
putenv('PHPUNIT_PARALLEL=master');
dont_leak_env_and_include($bootstrap);
}
}
示例2: shouldExclude
/**
* @param ReflectionClass $theClass
* @param Stagehand_TestRunner_Config $config
* @return boolean
*/
protected function shouldExclude(ReflectionClass $class, ReflectionMethod $method)
{
if (is_null($this->config->phpunitConfigFile)) {
return false;
}
$groups = PHPUnit_Util_Test::getGroups($class->getName(), $method->getName());
$shouldExclude = false;
$groupConfiguration = PHPUnit_Util_Configuration::getInstance($this->config->phpunitConfigFile)->getGroupConfiguration();
if (array_key_exists('include', $groupConfiguration) && count($groupConfiguration['include'])) {
$shouldExclude = true;
foreach ($groups as $group) {
if (in_array($group, $groupConfiguration['include'])) {
$shouldExclude = false;
break;
}
}
}
if (array_key_exists('exclude', $groupConfiguration) && count($groupConfiguration['exclude'])) {
foreach ($groups as $group) {
if (in_array($group, $groupConfiguration['exclude'])) {
$shouldExclude = true;
break;
}
}
}
return $shouldExclude;
}
示例3: findTests
/**
* {@inheritDoc}
* @see \Guide42\CliUnit\Strategy\StrategyInterface::findTests()
*/
public function findTests($directory)
{
$config = \PHPUnit_Util_Configuration::getInstance($this->findConfigFile($directory));
foreach ($config->getTestSuiteConfiguration() as $suite) {
$command = 'ls';
(yield new TestCase($suite->getName(), $command));
}
}
示例4: create
/**
* @return \PHPUnit_Util_Configuration
*/
public function create()
{
if (is_null($this->phpunitConfigurationFile)) {
return null;
} else {
return \PHPUnit_Util_Configuration::getInstance($this->phpunitConfigurationFile);
}
}
示例5: __construct
public function __construct($theClass = '', $name = '')
{
$this->setName(get_class($this));
$zendPath = getCwd();
chdir(realpath(dirname(__FILE__)));
require_once 'PHPUnit/Util/Configuration.php';
// test phpUnit version
if (version_compare(PHPUnit_Runner_Version::id(), '3.4', '>=')) {
$configuration = PHPUnit_Util_Configuration::getInstance('phpunit.xml');
} else {
$configuration = new PHPUnit_Util_Configuration('phpunit.xml');
}
$testSuite = $configuration->getTestSuiteConfiguration(false);
chdir($zendPath);
foreach ($testSuite->tests() as $test) {
if (!$test instanceof PHPUnit_Framework_Warning) {
$this->addTestSuite($test);
}
}
}
示例6: execute
public static function execute($xmlFile)
{
$configuration = \PHPUnit_Util_Configuration::getInstance($xmlFile);
$testSuites = new TestsQueue();
/** @var \PHPUnit_Framework_TestSuite $bla */
foreach ($configuration->getTestSuiteConfiguration()->getIterator() as $testSuite) {
$class = new \ReflectionClass($testSuite->getName());
$testSuites->add($class->getFileName());
}
return $testSuites;
}
示例7: main
public static function main($configFile)
{
$arguments = array('listGroups' => FALSE, 'loader' => NULL, 'useDefaultConfiguration' => TRUE, 'configuration' => $configFile);
$configuration = PHPUnit_Util_Configuration::getInstance($configFile);
$configuration->handlePHPConfiguration();
$phpunit = $configuration->getPHPUnitConfiguration();
if (isset($phpunit['bootstrap'])) {
PHPUnit_Util_Fileloader::load($phpunit['bootstrap']);
}
$testSuite = $configuration->getTestSuiteConfiguration();
return self::runTest($testSuite, $arguments);
}
示例8: assertConfigurationEquals
/**
* Asserts that the values in $actualConfiguration equal $expectedConfiguration.
*
* @param PHPUnit_Util_Configuration $expectedConfiguration
* @param PHPUnit_Util_Configuration $actualConfiguration
*/
protected function assertConfigurationEquals(PHPUnit_Util_Configuration $expectedConfiguration, PHPUnit_Util_Configuration $actualConfiguration)
{
$this->assertEquals($expectedConfiguration->getFilterConfiguration(), $actualConfiguration->getFilterConfiguration());
$this->assertEquals($expectedConfiguration->getGroupConfiguration(), $actualConfiguration->getGroupConfiguration());
$this->assertEquals($expectedConfiguration->getListenerConfiguration(), $actualConfiguration->getListenerConfiguration());
$this->assertEquals($expectedConfiguration->getLoggingConfiguration(), $actualConfiguration->getLoggingConfiguration());
$this->assertEquals($expectedConfiguration->getPHPConfiguration(), $actualConfiguration->getPHPConfiguration());
$this->assertEquals($expectedConfiguration->getPHPUnitConfiguration(), $actualConfiguration->getPHPUnitConfiguration());
$this->assertEquals($expectedConfiguration->getTestSuiteConfiguration(), $actualConfiguration->getTestSuiteConfiguration());
}
示例9: get_settings_hackery
public static function get_settings_hackery(PHPUnit_TextUI_Command $toread)
{
$arguments = $toread->arguments;
$config = PHPUnit_Util_Configuration::getInstance($arguments['configuration'])->getPHPUnitConfiguration();
$verbose = isset($config['verbose']) ? $config['verbose'] : false;
$verbose = isset($arguments['verbose']) ? $arguments['verbose'] : $verbose;
$colors = isset($config['colors']) ? $config['colors'] : Hint_ResultPrinter::COLOR_DEFAULT;
$colors = isset($arguments['colors']) ? $arguments['colors'] : $colors;
$debug = isset($config['debug']) ? $config['debug'] : false;
$debug = isset($arguments['debug']) ? $arguments['debug'] : $debug;
return array($verbose, $colors, $debug);
}
示例10: handleConfiguration
/**
* @param array $arguments
* @since Method available since Release 3.2.1
*/
protected function handleConfiguration(array &$arguments)
{
if (isset($arguments['configuration']) && !$arguments['configuration'] instanceof PHPUnit_Util_Configuration) {
$arguments['configuration'] = PHPUnit_Util_Configuration::getInstance($arguments['configuration']);
}
$arguments['debug'] = isset($arguments['debug']) ? $arguments['debug'] : FALSE;
$arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE;
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
if (isset($arguments['configuration'])) {
$arguments['configuration']->handlePHPConfiguration();
$phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) {
$arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
}
if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) {
$arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
}
if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
$arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
}
if (isset($phpunitConfiguration['cacheTokens']) && !isset($arguments['cacheTokens'])) {
$arguments['cacheTokens'] = $phpunitConfiguration['cacheTokens'];
}
if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
$arguments['colors'] = $phpunitConfiguration['colors'];
}
if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
$arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
}
if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
$arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
}
if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
$arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
}
if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) {
$arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
}
if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
$arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
}
if (isset($phpunitConfiguration['timeoutForSmallTests']) && !isset($arguments['timeoutForSmallTests'])) {
$arguments['timeoutForSmallTests'] = $phpunitConfiguration['timeoutForSmallTests'];
}
if (isset($phpunitConfiguration['timeoutForMediumTests']) && !isset($arguments['timeoutForMediumTests'])) {
$arguments['timeoutForMediumTests'] = $phpunitConfiguration['timeoutForMediumTests'];
}
if (isset($phpunitConfiguration['timeoutForLargeTests']) && !isset($arguments['timeoutForLargeTests'])) {
$arguments['timeoutForLargeTests'] = $phpunitConfiguration['timeoutForLargeTests'];
}
if (isset($phpunitConfiguration['strict']) && !isset($arguments['strict'])) {
$arguments['strict'] = $phpunitConfiguration['strict'];
}
if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) {
$arguments['verbose'] = $phpunitConfiguration['verbose'];
}
if (isset($phpunitConfiguration['forceCoversAnnotation']) && !isset($arguments['forceCoversAnnotation'])) {
$arguments['forceCoversAnnotation'] = $phpunitConfiguration['forceCoversAnnotation'];
}
if (isset($phpunitConfiguration['mapTestClassNameToCoveredClassName']) && !isset($arguments['mapTestClassNameToCoveredClassName'])) {
$arguments['mapTestClassNameToCoveredClassName'] = $phpunitConfiguration['mapTestClassNameToCoveredClassName'];
}
$groupConfiguration = $arguments['configuration']->getGroupConfiguration();
if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
$arguments['groups'] = $groupConfiguration['include'];
}
if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
$arguments['excludeGroups'] = $groupConfiguration['exclude'];
}
foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
if (!class_exists($listener['class'], FALSE) && $listener['file'] !== '') {
require_once $listener['file'];
}
if (class_exists($listener['class'], FALSE)) {
if (count($listener['arguments']) == 0) {
$listener = new $listener['class']();
} else {
$listenerClass = new ReflectionClass($listener['class']);
$listener = $listenerClass->newInstanceArgs($listener['arguments']);
}
if ($listener instanceof PHPUnit_Framework_TestListener) {
$arguments['listeners'][] = $listener;
}
}
}
$loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['reportDirectory'])) {
if (isset($loggingConfiguration['charset']) && !isset($arguments['reportCharset'])) {
$arguments['reportCharset'] = $loggingConfiguration['charset'];
}
if (isset($loggingConfiguration['yui']) && !isset($arguments['reportYUI'])) {
$arguments['reportYUI'] = $loggingConfiguration['yui'];
}
if (isset($loggingConfiguration['highlight']) && !isset($arguments['reportHighlight'])) {
$arguments['reportHighlight'] = $loggingConfiguration['highlight'];
}
//.........这里部分代码省略.........
示例11: handleArguments
//.........这里部分代码省略.........
}
if (isset($this->arguments['configuration']) &&
is_dir($this->arguments['configuration'])) {
$configurationFile = $this->arguments['configuration'] .
'/phpunit.xml';
if (file_exists($configurationFile)) {
$this->arguments['configuration'] = realpath(
$configurationFile
);
}
else if (file_exists($configurationFile . '.dist')) {
$this->arguments['configuration'] = realpath(
$configurationFile . '.dist'
);
}
}
else if (!isset($this->arguments['configuration']) &&
$this->arguments['useDefaultConfiguration']) {
if (file_exists('phpunit.xml')) {
$this->arguments['configuration'] = realpath('phpunit.xml');
} else if (file_exists('phpunit.xml.dist')) {
$this->arguments['configuration'] = realpath(
'phpunit.xml.dist'
);
}
}
if (isset($this->arguments['configuration'])) {
try {
$configuration = PHPUnit_Util_Configuration::getInstance(
$this->arguments['configuration']
);
}
catch (Exception $e) {
print $e->getMessage() . "\n";
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
$phpunit = $configuration->getPHPUnitConfiguration();
if (isset($phpunit['syntaxCheck'])) {
$this->arguments['syntaxCheck'] = $phpunit['syntaxCheck'];
}
if (isset($phpunit['testSuiteLoaderClass'])) {
if (isset($phpunit['testSuiteLoaderFile'])) {
$file = $phpunit['testSuiteLoaderFile'];
} else {
$file = '';
}
$this->arguments['loader'] = $this->handleLoader(
$phpunit['testSuiteLoaderClass'], $file
);
}
$configuration->handlePHPConfiguration();
if (!isset($this->arguments['bootstrap'])) {
$phpunitConfiguration = $configuration->getPHPUnitConfiguration();
示例12: handleConfiguration
/**
* @param string $filename
* @param PHP_CodeCoverage $coverage
*/
protected function handleConfiguration($filename, \PHP_CodeCoverage $coverage)
{
$filter = $coverage->filter();
$configuration = \PHPUnit_Util_Configuration::getInstance($filename);
$filterConfiguration = $configuration->getFilterConfiguration();
$coverage->setAddUncoveredFilesFromWhitelist($filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']);
$coverage->setProcessUncoveredFilesFromWhitelist($filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist']);
foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
$filter->addDirectoryToBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
$filter->addFileToBlacklist($file);
}
foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
$filter->removeDirectoryFromBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
$filter->removeFileFromBlacklist($file);
}
foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
$filter->addDirectoryToWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
$filter->addFileToWhitelist($file);
}
foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
$filter->removeDirectoryFromWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
$filter->removeFileFromWhitelist($file);
}
}
示例13: handleConfiguration
/**
* @param array $arguments
* @since Method available since Release 3.2.1
*/
protected function handleConfiguration(array &$arguments)
{
if (isset($arguments['configuration']) && !$arguments['configuration'] instanceof PHPUnit_Util_Configuration) {
$arguments['configuration'] = PHPUnit_Util_Configuration::getInstance($arguments['configuration']);
}
$arguments['debug'] = isset($arguments['debug']) ? $arguments['debug'] : FALSE;
$arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE;
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
$arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE;
if (isset($arguments['configuration'])) {
$arguments['configuration']->handlePHPConfiguration();
$phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
if (isset($phpunitConfiguration['backupGlobals']) && !isset($arguments['backupGlobals'])) {
$arguments['backupGlobals'] = $phpunitConfiguration['backupGlobals'];
}
if (isset($phpunitConfiguration['backupStaticAttributes']) && !isset($arguments['backupStaticAttributes'])) {
$arguments['backupStaticAttributes'] = $phpunitConfiguration['backupStaticAttributes'];
}
if (isset($phpunitConfiguration['bootstrap']) && !isset($arguments['bootstrap'])) {
$arguments['bootstrap'] = $phpunitConfiguration['bootstrap'];
}
if (isset($phpunitConfiguration['colors']) && !isset($arguments['colors'])) {
$arguments['colors'] = $phpunitConfiguration['colors'];
}
if (isset($phpunitConfiguration['convertErrorsToExceptions']) && !isset($arguments['convertErrorsToExceptions'])) {
$arguments['convertErrorsToExceptions'] = $phpunitConfiguration['convertErrorsToExceptions'];
}
if (isset($phpunitConfiguration['convertNoticesToExceptions']) && !isset($arguments['convertNoticesToExceptions'])) {
$arguments['convertNoticesToExceptions'] = $phpunitConfiguration['convertNoticesToExceptions'];
}
if (isset($phpunitConfiguration['convertWarningsToExceptions']) && !isset($arguments['convertWarningsToExceptions'])) {
$arguments['convertWarningsToExceptions'] = $phpunitConfiguration['convertWarningsToExceptions'];
}
if (isset($phpunitConfiguration['processIsolation']) && !isset($arguments['processIsolation'])) {
$arguments['processIsolation'] = $phpunitConfiguration['processIsolation'];
}
if (isset($phpunitConfiguration['stopOnFailure']) && !isset($arguments['stopOnFailure'])) {
$arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure'];
}
if (isset($phpunitConfiguration['verbose']) && !isset($arguments['verbose'])) {
$arguments['verbose'] = $phpunitConfiguration['verbose'];
}
$groupConfiguration = $arguments['configuration']->getGroupConfiguration();
if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
$arguments['groups'] = $groupConfiguration['include'];
}
if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
$arguments['excludeGroups'] = $groupConfiguration['exclude'];
}
foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
if (!class_exists($listener['class'], FALSE) && $listener['file'] !== '') {
$file = PHPUnit_Util_Filesystem::fileExistsInIncludePath($listener['file']);
if ($file !== FALSE) {
require $file;
}
}
if (class_exists($listener['class'], FALSE)) {
if (count($listener['arguments']) == 0) {
$listener = new $listener['class']();
} else {
$listenerClass = new ReflectionClass($listener['class']);
$listener = $listenerClass->newInstanceArgs($listener['arguments']);
}
if ($listener instanceof PHPUnit_Framework_TestListener) {
$arguments['listeners'][] = $listener;
}
}
}
$loggingConfiguration = $arguments['configuration']->getLoggingConfiguration();
if (isset($loggingConfiguration['coverage-html']) && !isset($arguments['reportDirectory'])) {
if (isset($loggingConfiguration['charset']) && !isset($arguments['reportCharset'])) {
$arguments['reportCharset'] = $loggingConfiguration['charset'];
}
if (isset($loggingConfiguration['yui']) && !isset($arguments['reportYUI'])) {
$arguments['reportYUI'] = $loggingConfiguration['yui'];
}
if (isset($loggingConfiguration['highlight']) && !isset($arguments['reportHighlight'])) {
$arguments['reportHighlight'] = $loggingConfiguration['highlight'];
}
if (isset($loggingConfiguration['lowUpperBound']) && !isset($arguments['reportLowUpperBound'])) {
$arguments['reportLowUpperBound'] = $loggingConfiguration['lowUpperBound'];
}
if (isset($loggingConfiguration['highLowerBound']) && !isset($arguments['reportHighLowerBound'])) {
$arguments['reportHighLowerBound'] = $loggingConfiguration['highLowerBound'];
}
$arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
}
if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
$arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
}
if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
$arguments['jsonLogfile'] = $loggingConfiguration['json'];
}
if (isset($loggingConfiguration['plain'])) {
$arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
}
//.........这里部分代码省略.........
示例14: 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) {
//.........这里部分代码省略.........
示例15: getModel
/**
* (non-PHPdoc)
*
* @see \SK\ITCBundle\Controller\FilesystemController::getModel()
*/
protected function getModel()
{
$model = parent::getModel();
$model = $model['model'];
$bundlesPhpunit = array();
foreach ($model['bundles'] as $id => $bundle) {
$bundlePhpUnitFile = sprintf("%s/%s", $bundle->getPath(), "phpunit.xml");
$bundlePhpUnitInfo = new \SplFileInfo($bundlePhpUnitFile);
$bundlesPhpunit[$bundle->getName()] = $bundlePhpUnitInfo;
}
$model['bundlesPhpunit'] = $bundlesPhpunit;
$phpunit = sprintf("%s/%s", $model['path'], "phpunit.xml");
$bundle = $model['bundle'];
if (NULL != $bundle) {
$phpunit = sprintf("%s/%s", $bundle->getPath(), "phpunit.xml");
}
if (is_file($phpunit)) {
$configuration = \PHPUnit_Util_Configuration::getInstance($phpunit);
$configuration->handlePHPConfiguration();
$groups = $configuration->getTestSuiteConfiguration()->getGroupDetails();
$model['configuration'] = $configuration;
$model['groups'] = $groups;
$model['group'] = $this->getRequest()->get('group', NULL);
$model['suite'] = $this->getRequest()->get('suite', NULL);
$model['test'] = $this->getRequest()->get('test', NULL);
$model['case'] = $this->getRequest()->get('case', NULL);
$model['phpunit'] = $phpunit;
// $geshi = new \GeSHi(file_get_contents($phpunit), 'xml');
// $geshi->parse_code();
}
return array('model' => $model);
}