本文整理汇总了PHP中PHP_CodeCoverage_Filter::addDirectoryToWhitelist方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeCoverage_Filter::addDirectoryToWhitelist方法的具体用法?PHP PHP_CodeCoverage_Filter::addDirectoryToWhitelist怎么用?PHP PHP_CodeCoverage_Filter::addDirectoryToWhitelist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHP_CodeCoverage_Filter
的用法示例。
在下文中一共展示了PHP_CodeCoverage_Filter::addDirectoryToWhitelist方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* CodeCoverage constructor
*/
public function __construct()
{
$filter = new \PHP_CodeCoverage_Filter();
$filter->addDirectoryToWhitelist(__DIR__ . '/../app');
$filter->addDirectoryToWhitelist(__DIR__ . '/../src');
$this->coverage = new \PHP_CodeCoverage(null, $filter);
$this->writer = new \PHP_CodeCoverage_Report_PHP();
}
示例2: setup
/** @BeforeSuite */
public static function setup()
{
if (!self::$coverage) {
$filter = new \PHP_CodeCoverage_Filter();
$filter->addDirectoryToBlacklist(__DIR__ . '/../../../vendor');
$filter->addDirectoryToWhitelist(__DIR__ . '/../../../Bundle');
self::$coverage = new \PHP_CodeCoverage(null, $filter);
}
}
示例3: __construct
/**
* JBZooPHPUnit_Coverage constructor.
* @SuppressWarnings(PHPMD.Superglobals)
*/
public function __construct()
{
if (Env::hasXdebug() && isset($_REQUEST['jbzoo-phpunit'])) {
$cmsType = $_REQUEST['jbzoo-phpunit-type'];
$testName = $_REQUEST['jbzoo-phpunit-test'];
$this->_covRoot = realpath(__DIR__ . '/../..');
$this->_covDir = realpath($this->_covRoot . '/src');
$this->_covHash = implode('_', [md5(serialize($_REQUEST)), mt_rand(0, 100000000)]);
$this->_covResult = realpath($this->_covRoot . '/build/coverage_cov') . '/' . $cmsType . '-' . $testName . '.cov';
$covFilter = new PHP_CodeCoverage_Filter();
$covFilter->addDirectoryToWhitelist($this->_covDir);
$this->_coverage = new PHP_CodeCoverage(null, $covFilter);
}
}
示例4: __construct
/**
* CovCatcher constructor.
* @param string $testName
* @param array $options
* @throws Exception
*/
public function __construct($testName = null, array $options = array())
{
if (!class_exists('\\JBZoo\\Data\\Data')) {
throw new Exception('jbzoo/data required for CovCatcher');
}
if (!class_exists('\\JBZoo\\Utils\\Env')) {
throw new Exception('jbzoo/utils required for CovCatcher');
}
$this->_initConfig($options);
$this->_hash = $this->_getPrefix($testName) . '_' . md5(serialize($this->_config->getArrayCopy()) . '|' . $testName);
if (Env::hasXdebug()) {
$covFilter = new \PHP_CodeCoverage_Filter();
$covFilter->addDirectoryToWhitelist($this->_config->get('src'));
$this->_coverage = new \PHP_CodeCoverage(null, $covFilter);
}
}
示例5: handleConfiguration
//.........这里部分代码省略.........
if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) {
$arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles'];
} else {
$arguments['coverageTextShowUncoveredFiles'] = false;
}
if (isset($loggingConfiguration['coverageTextShowOnlySummary'])) {
$arguments['coverageTextShowOnlySummary'] = $loggingConfiguration['coverageTextShowOnlySummary'];
} else {
$arguments['coverageTextShowOnlySummary'] = false;
}
}
if (isset($loggingConfiguration['coverage-xml']) && !isset($arguments['coverageXml'])) {
$arguments['coverageXml'] = $loggingConfiguration['coverage-xml'];
}
if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
$arguments['jsonLogfile'] = $loggingConfiguration['json'];
}
if (isset($loggingConfiguration['plain'])) {
$arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], true);
}
if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
$arguments['tapLogfile'] = $loggingConfiguration['tap'];
}
if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) {
$arguments['junitLogfile'] = $loggingConfiguration['junit'];
if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
$arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
}
}
if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
$arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
}
if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
$arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
}
if ((isset($arguments['coverageClover']) || isset($arguments['coverageCrap4J']) || isset($arguments['coverageHtml']) || isset($arguments['coveragePHP']) || isset($arguments['coverageText']) || isset($arguments['coverageXml'])) && $this->runtime->canCollectCodeCoverage()) {
$filterConfiguration = $arguments['configuration']->getFilterConfiguration();
$arguments['addUncoveredFilesFromWhitelist'] = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
$arguments['processUncoveredFilesFromWhitelist'] = $filterConfiguration['whitelist']['processUncoveredFilesFromWhitelist'];
if (empty($filterConfiguration['whitelist']['include']['directory']) && empty($filterConfiguration['whitelist']['include']['file'])) {
foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
$this->codeCoverageFilter->addDirectoryToBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
$this->codeCoverageFilter->addFileToBlacklist($file);
}
foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
$this->codeCoverageFilter->removeDirectoryFromBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
$this->codeCoverageFilter->removeFileFromBlacklist($file);
}
}
foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
$this->codeCoverageFilter->addDirectoryToWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
$this->codeCoverageFilter->addFileToWhitelist($file);
}
foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
$this->codeCoverageFilter->removeDirectoryFromWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
$this->codeCoverageFilter->removeFileFromWhitelist($file);
}
}
}
$arguments['addUncoveredFilesFromWhitelist'] = isset($arguments['addUncoveredFilesFromWhitelist']) ? $arguments['addUncoveredFilesFromWhitelist'] : true;
$arguments['processUncoveredFilesFromWhitelist'] = isset($arguments['processUncoveredFilesFromWhitelist']) ? $arguments['processUncoveredFilesFromWhitelist'] : false;
$arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : null;
$arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : null;
$arguments['disallowChangesToGlobalState'] = isset($arguments['disallowChangesToGlobalState']) ? $arguments['disallowChangesToGlobalState'] : null;
$arguments['cacheTokens'] = isset($arguments['cacheTokens']) ? $arguments['cacheTokens'] : false;
$arguments['columns'] = isset($arguments['columns']) ? $arguments['columns'] : 80;
$arguments['colors'] = isset($arguments['colors']) ? $arguments['colors'] : PHPUnit_TextUI_ResultPrinter::COLOR_DEFAULT;
$arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : true;
$arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : true;
$arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : true;
$arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
$arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
$arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : false;
$arguments['processIsolation'] = isset($arguments['processIsolation']) ? $arguments['processIsolation'] : false;
$arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : false;
$arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 90;
$arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 50;
$arguments['stopOnError'] = isset($arguments['stopOnError']) ? $arguments['stopOnError'] : false;
$arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : false;
$arguments['stopOnIncomplete'] = isset($arguments['stopOnIncomplete']) ? $arguments['stopOnIncomplete'] : false;
$arguments['stopOnRisky'] = isset($arguments['stopOnRisky']) ? $arguments['stopOnRisky'] : false;
$arguments['stopOnSkipped'] = isset($arguments['stopOnSkipped']) ? $arguments['stopOnSkipped'] : false;
$arguments['timeoutForSmallTests'] = isset($arguments['timeoutForSmallTests']) ? $arguments['timeoutForSmallTests'] : 1;
$arguments['timeoutForMediumTests'] = isset($arguments['timeoutForMediumTests']) ? $arguments['timeoutForMediumTests'] : 10;
$arguments['timeoutForLargeTests'] = isset($arguments['timeoutForLargeTests']) ? $arguments['timeoutForLargeTests'] : 60;
$arguments['reportUselessTests'] = isset($arguments['reportUselessTests']) ? $arguments['reportUselessTests'] : false;
$arguments['strictCoverage'] = isset($arguments['strictCoverage']) ? $arguments['strictCoverage'] : false;
$arguments['disallowTestOutput'] = isset($arguments['disallowTestOutput']) ? $arguments['disallowTestOutput'] : false;
$arguments['enforceTimeLimit'] = isset($arguments['enforceTimeLimit']) ? $arguments['enforceTimeLimit'] : false;
$arguments['disallowTodoAnnotatedTests'] = isset($arguments['disallowTodoAnnotatedTests']) ? $arguments['disallowTodoAnnotatedTests'] : false;
$arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : false;
}
示例6: substr
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
});
}
/**
* Code coverage option
*/
if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true) {
$codeCoverageFilter = new PHP_CodeCoverage_Filter();
$lastArg = end($_SERVER['argv']);
if (is_dir($zfCoreTests . '/' . $lastArg)) {
$codeCoverageFilter->addDirectoryToWhitelist($zfCoreLibrary . '/' . $lastArg);
} elseif (is_file($zfCoreTests . '/' . $lastArg)) {
$codeCoverageFilter->addDirectoryToWhitelist(dirname($zfCoreLibrary . '/' . $lastArg));
} else {
$codeCoverageFilter->addDirectoryToWhitelist($zfCoreLibrary);
}
/*
* Omit from code coverage reports the contents of the tests directory
*/
$codeCoverageFilter->addDirectoryToBlacklist($zfCoreTests, '');
$codeCoverageFilter->addDirectoryToBlacklist(PEAR_INSTALL_DIR, '');
$codeCoverageFilter->addDirectoryToBlacklist(PHP_LIBDIR, '');
unset($codeCoverageFilter);
}
/*
* Unset global variables that are no longer needed.
示例7: handleConfiguration
//.........这里部分代码省略.........
}
$arguments['reportDirectory'] = $loggingConfiguration['coverage-html'];
}
if (isset($loggingConfiguration['coverage-clover']) && !isset($arguments['coverageClover'])) {
$arguments['coverageClover'] = $loggingConfiguration['coverage-clover'];
}
if (isset($loggingConfiguration['coverage-php']) && !isset($arguments['coveragePHP'])) {
$arguments['coveragePHP'] = $loggingConfiguration['coverage-php'];
}
if (isset($loggingConfiguration['coverage-text']) && !isset($arguments['coverageText'])) {
$arguments['coverageText'] = $loggingConfiguration['coverage-text'];
if (isset($loggingConfiguration['coverageTextShowUncoveredFiles'])) {
$arguments['coverageTextShowUncoveredFiles'] = $loggingConfiguration['coverageTextShowUncoveredFiles'];
} else {
$arguments['coverageTextShowUncoveredFiles'] = FALSE;
}
}
if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) {
$arguments['jsonLogfile'] = $loggingConfiguration['json'];
}
if (isset($loggingConfiguration['plain'])) {
$arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE);
}
if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) {
$arguments['tapLogfile'] = $loggingConfiguration['tap'];
}
if (isset($loggingConfiguration['junit']) && !isset($arguments['junitLogfile'])) {
$arguments['junitLogfile'] = $loggingConfiguration['junit'];
if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) {
$arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped'];
}
}
if (isset($loggingConfiguration['testdox-html']) && !isset($arguments['testdoxHTMLFile'])) {
$arguments['testdoxHTMLFile'] = $loggingConfiguration['testdox-html'];
}
if (isset($loggingConfiguration['testdox-text']) && !isset($arguments['testdoxTextFile'])) {
$arguments['testdoxTextFile'] = $loggingConfiguration['testdox-text'];
}
if ((isset($arguments['coverageClover']) || isset($arguments['reportDirectory']) || isset($arguments['coveragePHP']) || isset($arguments['coverageText'])) && extension_loaded('xdebug')) {
$filterConfiguration = $arguments['configuration']->getFilterConfiguration();
$arguments['addUncoveredFilesFromWhitelist'] = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist'];
foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) {
$this->codeCoverageFilter->addDirectoryToBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['include']['file'] as $file) {
$this->codeCoverageFilter->addFileToBlacklist($file);
}
foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) {
$this->codeCoverageFilter->removeDirectoryFromBlacklist($dir['path'], $dir['suffix'], $dir['prefix'], $dir['group']);
}
foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) {
$this->codeCoverageFilter->removeFileFromBlacklist($file);
}
foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) {
$this->codeCoverageFilter->addDirectoryToWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['include']['file'] as $file) {
$this->codeCoverageFilter->addFileToWhitelist($file);
}
foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) {
$this->codeCoverageFilter->removeDirectoryFromWhitelist($dir['path'], $dir['suffix'], $dir['prefix']);
}
foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) {
$this->codeCoverageFilter->removeFileFromWhitelist($file);
}
}
}
$arguments['addUncoveredFilesFromWhitelist'] = isset($arguments['addUncoveredFilesFromWhitelist']) ? $arguments['addUncoveredFilesFromWhitelist'] : TRUE;
$arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : NULL;
$arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : NULL;
$arguments['cacheTokens'] = isset($arguments['cacheTokens']) ? $arguments['cacheTokens'] : TRUE;
$arguments['colors'] = isset($arguments['colors']) ? $arguments['colors'] : FALSE;
$arguments['convertErrorsToExceptions'] = isset($arguments['convertErrorsToExceptions']) ? $arguments['convertErrorsToExceptions'] : TRUE;
$arguments['convertNoticesToExceptions'] = isset($arguments['convertNoticesToExceptions']) ? $arguments['convertNoticesToExceptions'] : TRUE;
$arguments['convertWarningsToExceptions'] = isset($arguments['convertWarningsToExceptions']) ? $arguments['convertWarningsToExceptions'] : TRUE;
$arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array();
$arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array();
$arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE;
$arguments['processIsolation'] = isset($arguments['processIsolation']) ? $arguments['processIsolation'] : FALSE;
$arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE;
$arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'UTF-8';
$arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE;
$arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70;
$arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35;
$arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE;
$arguments['stopOnError'] = isset($arguments['stopOnError']) ? $arguments['stopOnError'] : FALSE;
$arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE;
$arguments['stopOnIncomplete'] = isset($arguments['stopOnIncomplete']) ? $arguments['stopOnIncomplete'] : FALSE;
$arguments['stopOnSkipped'] = isset($arguments['stopOnSkipped']) ? $arguments['stopOnSkipped'] : FALSE;
$arguments['timeoutForSmallTests'] = isset($arguments['timeoutForSmallTests']) ? $arguments['timeoutForSmallTests'] : 1;
$arguments['timeoutForMediumTests'] = isset($arguments['timeoutForMediumTests']) ? $arguments['timeoutForMediumTests'] : 10;
$arguments['timeoutForLargeTests'] = isset($arguments['timeoutForLargeTests']) ? $arguments['timeoutForLargeTests'] : 60;
$arguments['strict'] = isset($arguments['strict']) ? $arguments['strict'] : FALSE;
$arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE;
if ($arguments['filter'] !== FALSE && preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) {
// Escape delimiters in regular expression. Do NOT use preg_quote,
// to keep magic characters.
$arguments['filter'] = '/' . str_replace('/', '\\/', $arguments['filter']) . '/';
}
}
示例8: tearDown
/**
* Collect code coverage after the suite has been run
*
* @AfterSuite
*/
public static function tearDown(SuiteEvent $event)
{
$parameters = $event->getContextParameters();
if ($parameters['enableCodeCoverage']) {
$client = new Client($parameters['url']);
$response = $client->get('/', array('X-Enable-Coverage' => 1, 'X-Test-Session-Id' => self::$testSessionId, 'X-Collect-Coverage' => 1))->send();
$data = unserialize((string) $response->getBody());
$filter = new PHP_CodeCoverage_Filter();
foreach ($parameters['whitelist'] as $dir) {
$filter->addDirectoryToWhitelist($dir);
}
$coverage = new PHP_CodeCoverage(null, $filter);
$coverage->append($data, 'behat-suite');
$report = new PHP_CodeCoverage_Report_HTML();
$report->process($coverage, $parameters['coveragePath']);
}
}
示例9: addDirectoryToWhitelist
/**
* Add a directory to the whitelist (recursively).
*
* @param string $directory
* @param string $suffix
* @param string $prefix
* @return $this
*/
public function addDirectoryToWhitelist($directory, $suffix = '.php', $prefix = '')
{
$this->filter->addDirectoryToWhitelist($directory, $suffix, $prefix);
return $this;
}
开发者ID:peridot-php,项目名称:peridot-code-coverage-reporters,代码行数:13,代码来源:AbstractCodeCoverageReporter.php
示例10: suite_add_dir
define('THROW_ON_ERROR', $throwOnError);
$config = array();
$groups = $options['group'] ? explode(',', $options['group']) : null;
$args = array('reportDirectory' => $options['coverage-html'], 'filter' => $options['filter'], 'excludeGroups' => explode(',', $options['exclude-group']), 'groups' => $groups, 'strict' => true, 'processIsolation' => false, 'backupGlobals' => false, 'backupStaticAttributes' => false, 'convertErrorsToExceptions' => $throwOnError, 'convertNoticesToExceptions' => $throwOnError, 'convertWarningsToExceptions' => $throwOnError, 'addUncoveredFilesFromWhitelist' => true, 'processUncoveredFilesFromWhitelist' => true);
$masterSuite = new PHPUnit_Framework_TestSuite();
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $testPath . '/lib/Unit/');
$masterSuite->addTest($suite);
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $testPath . '/lib/FileSystem/');
$masterSuite->addTest($suite);
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $testPath . '/lib/StreamWrapper/');
$masterSuite->addTest($suite);
$filter = new PHP_CodeCoverage_Filter();
$filter->addDirectoryToWhitelist($basePath . '/src/', '.php');
$runner = new PHPUnit_TextUI_TestRunner(null, $filter);
$runner->doRun($masterSuite, $args);
function suite_add_dir($suite, $dir)
{
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY) as $item) {
foreach (require_tests($item) as $class) {
$suite->addTest(new PHPUnit_Framework_TestSuite($class));
}
}
}
function require_tests($file)
{
static $cache = array();
if (!preg_match("/Test\\.php\$/", $file)) {
return array();
示例11: dirname
<?php
/**
* Flitch
*
* @link http://github.com/DASPRiD/Flitch For the canonical source repository
* @copyright 2011-2012 Ben Scholzen 'DASPRiD'
* @license http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
*/
// Set error reporting pretty high
error_reporting(E_ALL | E_STRICT);
// Get base, application and tests path
define('BASE_PATH', dirname(__DIR__));
define('TESTS_PATH', __DIR__);
// Define filters for clover report
$filter = new PHP_CodeCoverage_Filter();
$filter->addDirectoryToBlacklist(TESTS_PATH);
$filter->addDirectoryToBlacklist(BASE_PATH . '/bin');
$filter->addFilesToBlacklist(array(BASE_PATH . '/src/autoload_classmap.php', BASE_PATH . '/src/autoload_function.php', BASE_PATH . '/src/autoload_register.php'));
$filter->addDirectoryToWhitelist(BASE_PATH . '/src', '.php');
unset($filter);
// Load autoloader
require_once BASE_PATH . '/src/autoload_register.php';
示例12: suite_add_dir
require $testPath . '/config.php';
date_default_timezone_set('Australia/Melbourne');
$options = array('coverage-html' => null, 'filter' => null, 'exclude-group' => null, 'group' => null);
$options = array_merge($options, getopt('', array('help', 'filter:', 'coverage-html:', 'exclude-group:', 'group:')));
$help = array_key_exists('help', $options);
if ($help) {
echo $usage;
exit;
}
$config = array();
$groups = $options['group'] ? explode(',', $options['group']) : null;
$args = array('reportDirectory' => $options['coverage-html'], 'coverageHtml' => $options['coverage-html'], 'filter' => $options['filter'], 'excludeGroups' => explode(',', $options['exclude-group']), 'groups' => $groups, 'strict' => true, 'processIsolation' => false, 'backupGlobals' => false, 'backupStaticAttributes' => false, 'convertErrorsToExceptions' => true, 'convertNoticesToExceptions' => true, 'convertWarningsToExceptions' => true, 'addUncoveredFilesFromWhitelist' => true, 'processUncoveredFilesFromWhitelist' => true);
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $basePath . '/test/');
$filter = new PHP_CodeCoverage_Filter();
$filter->addDirectoryToWhitelist($libPath, '.php');
$runner = new PHPUnit_TextUI_TestRunner(null, $filter);
$runner->doRun($suite, $args);
function suite_add_dir($suite, $dir)
{
$iter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($iter as $item) {
foreach (require_tests($item) as $class) {
$suite->addTest(new PHPUnit_Framework_TestSuite($class));
}
}
}
function require_tests($file)
{
static $cache = array();
if (!preg_match("/Test\\.php\$/", $file)) {