当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Util_Configuration::getInstance方法代码示例

本文整理汇总了PHP中PHPUnit_Util_Configuration::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Configuration::getInstance方法的具体用法?PHP PHPUnit_Util_Configuration::getInstance怎么用?PHP PHPUnit_Util_Configuration::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPUnit_Util_Configuration的用法示例。


在下文中一共展示了PHPUnit_Util_Configuration::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:rsky,项目名称:makegood,代码行数:32,代码来源:PHPUnitGroupFilterTestSuite.php

示例2: 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));
     }
 }
开发者ID:guide42,项目名称:cli-unit,代码行数:12,代码来源:PhpUnitStrategy.php

示例3: create

 /**
  * @return \PHPUnit_Util_Configuration
  */
 public function create()
 {
     if (is_null($this->phpunitConfigurationFile)) {
         return null;
     } else {
         return \PHPUnit_Util_Configuration::getInstance($this->phpunitConfigurationFile);
     }
 }
开发者ID:ngyuki,项目名称:stagehand-testrunner,代码行数:11,代码来源:PHPUnitConfigurationFactory.php

示例4: 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;
 }
开发者ID:liuggio,项目名称:fastest,代码行数:11,代码来源:CreateTestsQueueFromPhpUnitXML.php

示例5: 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);
 }
开发者ID:jo-m,项目名称:ecamp3,代码行数:12,代码来源:run.php

示例6: __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);
         }
     }
 }
开发者ID:r-kovalenko,项目名称:Rediska,代码行数:20,代码来源:bootstrap.php

示例7: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('worker')) {
         return $this->runWorker($input);
     }
     $configFile = $this->getConfigFile($input);
     $config = \PHPUnit_Util_Configuration::getInstance($configFile);
     $this->bootstrap($input, $config);
     $formatter = $input->getOption('formatter');
     $tests = $this->getTestSuite($config, $input->getArgument('filenames'), $input->getOption('replay'));
     $distributor = new TestDistributor($tests, $input->getOption('interpreter-options'), $this->getWorkerOptions($input));
     $distributor->addListener($this->getFormatter($formatter, $output));
     $distributor->addListener($exitStatus = new ExitStatusListener());
     if ($input->getOption('stop-on-error')) {
         $distributor->addListener(new StopOnErrorListener($distributor));
     }
     $this->handleWriters($input->getOption('write'), $distributor);
     $distributor->run($input->getOption('workers'));
     return $exitStatus->getExitStatus();
 }
开发者ID:vektah,项目名称:phpunit-parallel,代码行数:20,代码来源:PhpunitParallel.php

示例8: testExceptionIsThrownForNotExistingConfigurationFile

 /**
  * @expectedException PHPUnit_Framework_Exception
  */
 public function testExceptionIsThrownForNotExistingConfigurationFile()
 {
     PHPUnit_Util_Configuration::getInstance('not_existing_file.xml');
 }
开发者ID:naderman,项目名称:phpunit,代码行数:7,代码来源:ConfigurationTest.php

示例9: handleArguments


//.........这里部分代码省略.........
             $this->arguments['test'] = $this->options[1][0];
         }
         if (isset($this->options[1][1])) {
             $this->arguments['testFile'] = realpath($this->options[1][1]);
         } else {
             $this->arguments['testFile'] = '';
         }
         if (isset($this->arguments['test']) && is_file($this->arguments['test']) && substr($this->arguments['test'], -5, 5) != '.phpt') {
             $this->arguments['testFile'] = realpath($this->arguments['test']);
             $this->arguments['test'] = substr($this->arguments['test'], 0, strrpos($this->arguments['test'], '.'));
         }
     }
     if (!isset($this->arguments['testSuffixes'])) {
         $this->arguments['testSuffixes'] = array('Test.php', '.phpt');
     }
     if (isset($includePath)) {
         ini_set('include_path', $includePath . PATH_SEPARATOR . ini_get('include_path'));
     }
     if ($this->arguments['loader'] !== null) {
         $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
     }
     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);
         } elseif (file_exists($configurationFile . '.dist')) {
             $this->arguments['configuration'] = realpath($configurationFile . '.dist');
         }
     } elseif (!isset($this->arguments['configuration']) && $this->arguments['useDefaultConfiguration']) {
         if (file_exists('phpunit.xml')) {
             $this->arguments['configuration'] = realpath('phpunit.xml');
         } elseif (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();
         $configuration->handlePHPConfiguration();
         /**
          * Issue #1216
          */
         if (isset($this->arguments['bootstrap'])) {
             $this->handleBootstrap($this->arguments['bootstrap']);
         } elseif (isset($phpunit['bootstrap'])) {
             $this->handleBootstrap($phpunit['bootstrap']);
         }
         /**
          * Issue #657
          */
         if (isset($phpunit['stderr']) && !isset($this->arguments['stderr'])) {
             $this->arguments['stderr'] = $phpunit['stderr'];
         }
         if (isset($phpunit['printerClass'])) {
             if (isset($phpunit['printerFile'])) {
                 $file = $phpunit['printerFile'];
             } else {
                 $file = '';
             }
             $this->arguments['printer'] = $this->handlePrinter($phpunit['printerClass'], $file);
         }
         if (isset($phpunit['testSuiteLoaderClass'])) {
             if (isset($phpunit['testSuiteLoaderFile'])) {
                 $file = $phpunit['testSuiteLoaderFile'];
             } else {
                 $file = '';
             }
             $this->arguments['loader'] = $this->handleLoader($phpunit['testSuiteLoaderClass'], $file);
         }
         $browsers = $configuration->getSeleniumBrowserConfiguration();
         if (!empty($browsers) && class_exists('PHPUnit_Extensions_SeleniumTestCase')) {
             PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers;
         }
         if (!isset($this->arguments['test'])) {
             $testSuite = $configuration->getTestSuiteConfiguration(isset($this->arguments['testsuite']) ? $this->arguments['testsuite'] : null);
             if ($testSuite !== null) {
                 $this->arguments['test'] = $testSuite;
             }
         }
     } elseif (isset($this->arguments['bootstrap'])) {
         $this->handleBootstrap($this->arguments['bootstrap']);
     }
     if (isset($this->arguments['printer']) && is_string($this->arguments['printer'])) {
         $this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
     }
     if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') {
         $test = new PHPUnit_Extensions_PhptTestCase($this->arguments['test']);
         $this->arguments['test'] = new PHPUnit_Framework_TestSuite();
         $this->arguments['test']->addTest($test);
     }
     if (!isset($this->arguments['test']) || isset($this->arguments['testDatabaseLogRevision']) && !isset($this->arguments['testDatabaseDSN'])) {
         $this->showHelp();
         exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
     }
 }
开发者ID:HarveyCheng,项目名称:myblog,代码行数:101,代码来源:Command.php

示例10: testGetTestSuiteNamesReturnsTheNamesIfDefined

 /**
  * @covers PHPUnit_Util_Configuration::getTestSuiteNames
  */
 public function testGetTestSuiteNamesReturnsTheNamesIfDefined()
 {
     $configuration = PHPUnit_Util_Configuration::getInstance(dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'configuration.suites.xml');
     $names = $configuration->getTestSuiteNames();
     $this->assertEquals(['Suite One', 'Suite Two'], $names);
 }
开发者ID:sebastianbergmann,项目名称:phpunit,代码行数:9,代码来源:ConfigurationTest.php

示例11: testWithEmptyConfigurations

 /**
  * @ticket 1311
  * @covers PHPUnit_Util_Configuration::getLoggingConfiguration
  * @covers PHPUnit_Util_Configuration::getPHPConfiguration
  * @covers PHPUnit_Util_Configuration::getPHPUnitConfiguration
  * @covers PHPUnit_Util_Configuration::getTestSuiteConfiguration
  * @covers PHPUnit_Util_Configuration::getFilterConfiguration
  *
  * @uses   PHPUnit_Util_Configuration::getInstance
  */
 public function testWithEmptyConfigurations()
 {
     $emptyConfiguration = PHPUnit_Util_Configuration::getInstance(dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'configuration_empty.xml');
     $logging = $emptyConfiguration->getLoggingConfiguration();
     $this->assertEmpty($logging);
     $php = $emptyConfiguration->getPHPConfiguration();
     $this->assertEmpty($php['include_path']);
     $phpunit = $emptyConfiguration->getPHPUnitConfiguration();
     $this->assertArrayNotHasKey('bootstrap', $phpunit);
     $this->assertArrayNotHasKey('testSuiteLoaderFile', $phpunit);
     $this->assertArrayNotHasKey('printerFile', $phpunit);
     $suite = $emptyConfiguration->getTestSuiteConfiguration();
     $this->assertEmpty($suite->getGroups());
     $filter = $emptyConfiguration->getFilterConfiguration();
     $this->assertEmpty($filter['whitelist']['include']['directory']);
     $this->assertEmpty($filter['whitelist']['include']['file']);
     $this->assertEmpty($filter['whitelist']['exclude']['directory']);
     $this->assertEmpty($filter['whitelist']['exclude']['file']);
 }
开发者ID:phecho,项目名称:phpunit,代码行数:29,代码来源:ConfigurationTest.php

示例12: 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();
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:66,代码来源:ezptestrunner.php

示例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();
     if (isset($arguments['configuration'])) {
         $arguments['configuration']->handlePHPConfiguration();
         $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration();
         if (isset($phpunitConfiguration['deprecatedStrictModeSetting'])) {
             $arguments['deprecatedStrictModeSetting'] = true;
         }
         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['disallowChangesToGlobalState']) && !isset($arguments['disallowChangesToGlobalState'])) {
             $arguments['disallowChangesToGlobalState'] = $phpunitConfiguration['disallowChangesToGlobalState'];
         }
         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['reportUselessTests']) && !isset($arguments['reportUselessTests'])) {
             $arguments['reportUselessTests'] = $phpunitConfiguration['reportUselessTests'];
         }
         if (isset($phpunitConfiguration['strictCoverage']) && !isset($arguments['strictCoverage'])) {
             $arguments['strictCoverage'] = $phpunitConfiguration['strictCoverage'];
         }
         if (isset($phpunitConfiguration['disallowTestOutput']) && !isset($arguments['disallowTestOutput'])) {
             $arguments['disallowTestOutput'] = $phpunitConfiguration['disallowTestOutput'];
         }
         if (isset($phpunitConfiguration['enforceTimeLimit']) && !isset($arguments['enforceTimeLimit'])) {
             $arguments['enforceTimeLimit'] = $phpunitConfiguration['enforceTimeLimit'];
         }
         if (isset($phpunitConfiguration['disallowTodoAnnotatedTests']) && !isset($arguments['disallowTodoAnnotatedTests'])) {
             $arguments['disallowTodoAnnotatedTests'] = $phpunitConfiguration['disallowTodoAnnotatedTests'];
         }
         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'];
         }
         $groupCliArgs = array();
         if (!empty($arguments['groups'])) {
             $groupCliArgs = $arguments['groups'];
         }
         $groupConfiguration = $arguments['configuration']->getGroupConfiguration();
         if (!empty($groupConfiguration['include']) && !isset($arguments['groups'])) {
             $arguments['groups'] = $groupConfiguration['include'];
         }
         if (!empty($groupConfiguration['exclude']) && !isset($arguments['excludeGroups'])) {
             $arguments['excludeGroups'] = array_diff($groupConfiguration['exclude'], $groupCliArgs);
         }
         foreach ($arguments['configuration']->getListenerConfiguration() as $listener) {
             if (!class_exists($listener['class'], false) && $listener['file'] !== '') {
                 require_once $listener['file'];
             }
             if (class_exists($listener['class'])) {
//.........这里部分代码省略.........
开发者ID:mubassirhayat,项目名称:Laravel51-starter,代码行数:101,代码来源:TestRunner.php

示例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) {
//.........这里部分代码省略.........
开发者ID:nurcahyo,项目名称:juriya,代码行数:101,代码来源:Console.php

示例15: 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);
     }
 }
开发者ID:eanoriega20,项目名称:monedasZend,代码行数:36,代码来源:Command.php


注:本文中的PHPUnit_Util_Configuration::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。