public static function whitelist() { $folders = Kohana::config('phpunit.whitelist_folders'); foreach ($folders as $folder) { $files = Kohana::list_files($folder, TRUE); foreach ($files as $file) { if (is_file($file)) { if ($file == __FILE__) { continue; } else { PHPUnit_Util_Filter::addFileToWhitelist($file); } } } } }
public static function suite() { PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY . 'plugins/builtin'); PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY . 'Dwoo'); PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY . 'Dwoo.php'); PHPUnit_Util_Filter::removeDirectoryFromWhitelist(DWOO_DIRECTORY . 'Dwoo/Adapters'); $suite = new self('Dwoo - Unit Tests Report'); foreach (new DirectoryIterator(dirname(__FILE__)) as $file) { if (!$file->isDot() && !$file->isDir() && (string) $file !== 'DwooTests.php' && substr((string) $file, -4) === '.php') { require_once $file->getPathname(); $class = basename($file, '.php'); // to have an optional test suite, it should implement a public static function isRunnable // that returns true only if all the conditions are met to run it successfully, for example // it can check that an external library is present if (!method_exists($file, 'isRunnable') || call_user_func(array($file, 'isRunnable'))) { $suite->addTestSuite($class); } } } return $suite; }
/** * @param array $arguments * @since Method available since Release 3.2.1 */ protected function handleConfiguration(array &$arguments) { if (isset($arguments['configuration'])) { $arguments['configuration'] = new PHPUnit_Util_Configuration($arguments['configuration']); $arguments['pmd'] = $arguments['configuration']->getPMDConfiguration(); } else { $arguments['pmd'] = array(); } $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE; $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE; $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : ''; $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE; $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE; if (isset($arguments['configuration'])) { $arguments['configuration']->handlePHPConfiguration(); $filterConfiguration = $arguments['configuration']->getFilterConfiguration(); PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']; foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) { PHPUnit_Util_Filter::addDirectoryToFilter($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['blacklist']['include']['file'] as $file) { PHPUnit_Util_Filter::addFileToFilter($file); } foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) { PHPUnit_Util_Filter::removeDirectoryFromFilter($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) { PHPUnit_Util_Filter::removeFileFromFilter($file); } foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) { PHPUnit_Util_Filter::addDirectoryToWhitelist($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['whitelist']['include']['file'] as $file) { PHPUnit_Util_Filter::addFileToWhitelist($file); } foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) { PHPUnit_Util_Filter::removeDirectoryFromWhitelist($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) { PHPUnit_Util_Filter::removeFileFromWhitelist($file); } $phpunitConfiguration = $arguments['configuration']->getPHPUnitConfiguration(); if (isset($phpunitConfiguration['ansi']) && !isset($arguments['ansi'])) { $arguments['ansi'] = $phpunitConfiguration['ansi']; } 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['stopOnFailure']) && !isset($arguments['stopOnFailure'])) { $arguments['stopOnFailure'] = $phpunitConfiguration['stopOnFailure']; } $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']; } $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['coverage-xml']) && !isset($arguments['coverageClover'])) { $arguments['coverageClover'] = $loggingConfiguration['coverage-xml']; } if (isset($loggingConfiguration['coverage-source']) && !isset($arguments['coverageSource'])) { $arguments['coverageSource'] = $loggingConfiguration['coverage-source']; } if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) { $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz']; } if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) { $arguments['jsonLogfile'] = $loggingConfiguration['json']; } if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) { $arguments['metricsXML'] = $loggingConfiguration['metrics-xml']; } if (isset($loggingConfiguration['plain'])) { $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE); } if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) { if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) { $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines']; } if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) { $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches']; } $arguments['pmdXML'] = $loggingConfiguration['pmd-xml']; } if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) { $arguments['tapLogfile'] = $loggingConfiguration['tap']; } if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) { $arguments['xmlLogfile'] = $loggingConfiguration['test-xml']; if (isset($loggingConfiguration['logIncompleteSkipped']) && !isset($arguments['logIncompleteSkipped'])) { $arguments['logIncompleteSkipped'] = $loggingConfiguration['logIncompleteSkipped']; } } if (isset($loggingConfiguration['story-html']) && !isset($arguments['storyHTMLFile'])) { $arguments['storyHTMLFile'] = $loggingConfiguration['story-html']; } if (isset($loggingConfiguration['story-text']) && !isset($arguments['storyTextFile'])) { $arguments['storsTextFile'] = $loggingConfiguration['story-text']; } 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']; } $browsers = $arguments['configuration']->getSeleniumBrowserConfiguration(); if (!empty($browsers)) { require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; PHPUnit_Extensions_SeleniumTestCase::$browsers = $browsers; } } $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5; $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70; $arguments['ansi'] = isset($arguments['ansi']) ? $arguments['ansi'] : 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['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1'; $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['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE; }
protected function handleCustomTestSuite() { $directory = getcwd(); $packages = $this->options[1]; if (isset($this->arguments['coverageClover']) || isset($this->arguments['reportDirectory'])) { $fillWhitelist = true; } else { $fillWhitelist = false; } $this->arguments['test'] = new PHPUnit_Framework_TestSuite(); $this->arguments['test']->setName('eZ Components'); if (empty($packages)) { $packages = $this->getPackages($directory); } foreach ($packages as $package) { $added = false; $slashCount = substr_count($package, DIRECTORY_SEPARATOR); if ($this->release == 'trunk' && $slashCount !== 0 || $this->release == 'stable' && $slashCount > 1) { if (file_exists($package)) { PHPUnit_Util_Class::collectStart(); require_once $package; $class = PHPUnit_Util_Class::collectEnd(); if (!empty($class)) { $this->arguments['test']->addTest(call_user_func(array(array_pop($class), 'suite'))); $added = true; $package = substr($package, 0, strpos($package, DIRECTORY_SEPARATOR)); } else { die("\n Cannot load: {$package}. \n"); } } } else { $suite = $this->getTestSuite($directory, $package); if (!is_null($suite)) { $this->arguments['test']->addTest($suite); $added = true; } } if ($fillWhitelist && $added) { foreach (glob($directory . '/' . $package . '/src/*_autoload.php') as $autoloadFile) { foreach (include $autoloadFile as $className => $fileName) { if (strpos($fileName, 'xmlwritersubstitute.php') === false) { PHPUnit_Util_Filter::addFileToWhitelist($directory . '/' . str_replace($package, $package . '/src', $fileName)); } } } } } if (isset($this->arguments['colors']) && $this->arguments['colors'] === true) { $colors = true; } else { $colors = false; } if (isset($this->arguments['debug']) && $this->arguments['debug'] === true) { $debug = true; } else { $debug = false; } if (isset($this->arguments['verbose']) && $this->arguments['verbose'] === true) { $verbose = true; } else { $verbose = false; } $this->arguments['printer'] = new ezcTestPrinter(NULL, $verbose, $colors, $debug); }
* @category cfh * @package cfhCompile * @subpackage UnitTests * @copyright Copyright (c) 2007 - 2008 William Bailey <*****@*****.**>. * @license http://www.gnu.org/licenses/lgpl.html Lesser GPL * @version $Id$ */ error_reporting(E_ALL | E_STRICT); chdir(dirname(__FILE__)); require_once 'PHPUnit/Util/Filter.php'; require_once 'PHPUnit/Framework/TestSuite.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; require_once 'PHPUnit/Extensions/Database/TestCase.php'; if (file_exists('cfhCompile.compiled.php')) { require_once 'cfhCompile.compiled.php'; PHPUnit_Util_Filter::addFileToWhitelist('cfhCompile.compiled.php'); } else { require_once '../library/cfhCompile/Loader.php'; cfhCompile_Loader::registerAutoload(); PHPUnit_Util_Filter::addDirectoryToWhitelist(realpath('../library/')); PHPUnit_Util_Filter::addFileToFilter(__FILE__); } /** * Main Unit Test Class. * * @category cfh * @package cfhCompile * @subpackage UnitTests * @copyright Copyright (c) 2007 - 2008 William Bailey <*****@*****.**>. */ class AllTests
/** * @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['pmd'] = $arguments['configuration']->getPMDConfiguration(); } else { $arguments['pmd'] = array(); } $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['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE; $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : ''; $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE; $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE; if (isset($arguments['configuration'])) { $arguments['configuration']->handlePHPConfiguration(); $filterConfiguration = $arguments['configuration']->getFilterConfiguration(); PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']; foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) { PHPUnit_Util_Filter::addDirectoryToFilter($dir['path'], $dir['suffix'], $dir['group'], $dir['prefix']); } foreach ($filterConfiguration['blacklist']['include']['file'] as $file) { PHPUnit_Util_Filter::addFileToFilter($file); } foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) { PHPUnit_Util_Filter::removeDirectoryFromFilter($dir['path'], $dir['suffix'], $dir['group'], $dir['prefix']); } foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) { PHPUnit_Util_Filter::removeFileFromFilter($file); } foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) { PHPUnit_Util_Filter::addDirectoryToWhitelist($dir['path'], $dir['suffix'], $dir['prefix']); } foreach ($filterConfiguration['whitelist']['include']['file'] as $file) { PHPUnit_Util_Filter::addFileToWhitelist($file); } foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) { PHPUnit_Util_Filter::removeDirectoryFromWhitelist($dir['path'], $dir['suffix'], $dir['prefix']); } foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) { PHPUnit_Util_Filter::removeFileFromWhitelist($file); } $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']; } $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['coverage-xml']) && !isset($arguments['coverageClover'])) { $arguments['coverageClover'] = $loggingConfiguration['coverage-xml']; } if (isset($loggingConfiguration['coverage-source']) && !isset($arguments['coverageSource'])) { $arguments['coverageSource'] = $loggingConfiguration['coverage-source']; } if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) { $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz']; } if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) { $arguments['jsonLogfile'] = $loggingConfiguration['json']; } if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) { $arguments['metricsXML'] = $loggingConfiguration['metrics-xml']; } if (isset($loggingConfiguration['plain'])) { $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE); } if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) { if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) { $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines']; } if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) { $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches']; } $arguments['pmdXML'] = $loggingConfiguration['pmd-xml']; } 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['story-html']) && !isset($arguments['storyHTMLFile'])) { $arguments['storyHTMLFile'] = $loggingConfiguration['story-html']; } if (isset($loggingConfiguration['story-text']) && !isset($arguments['storyTextFile'])) { $arguments['storsTextFile'] = $loggingConfiguration['story-text']; } 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']; } } $arguments['backupGlobals'] = isset($arguments['backupGlobals']) ? $arguments['backupGlobals'] : NULL; $arguments['backupStaticAttributes'] = isset($arguments['backupStaticAttributes']) ? $arguments['backupStaticAttributes'] : NULL; $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5; $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70; $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['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1'; $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['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE; if ($arguments['filter'] !== FALSE && preg_match('/^[a-zA-Z0-9_]/', $arguments['filter'])) { $arguments['filter'] = '/' . $arguments['filter'] . '/'; } }
private function handleCoverageFilter($file) { if ($this->consider_covers_files == false) { return; } $data = file_get_contents($file); foreach (explode("\n", $data) as $line) { $file = str_replace(array('BASE', 'APP', 'LIB', 'FWK', '*'), array(AK_BASE_DIR, AK_APP_DIR, AK_LIB_DIR, AK_FRAMEWORK_DIR, ''), $line); if (is_file($file)) { $this->consider_covers_files == 'white' ? PHPUnit_Util_Filter::addFileToWhitelist($file) : PHPUnit_Util_Filter::addFileToFilter($file); } elseif (is_dir($file)) { $this->consider_covers_files == 'white' ? PHPUnit_Util_Filter::addDirectoryToWhitelist($file) : PHPUnit_Util_Filter::addDirectoryToFilter($file); } } }
/** * @param array $arguments * @access protected * @since Method available since Release 3.2.1 */ protected function handleConfiguration(array &$arguments) { if (isset($arguments['configuration'])) { $arguments['configuration'] = new PHPUnit_Util_Configuration($arguments['configuration']); $arguments['pmd'] = $arguments['configuration']->getPMDConfiguration(); } else { $arguments['pmd'] = array(); } $arguments['filter'] = isset($arguments['filter']) ? $arguments['filter'] : FALSE; $arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array(); $arguments['repeat'] = isset($arguments['repeat']) ? $arguments['repeat'] : FALSE; $arguments['stopOnFailure'] = isset($arguments['stopOnFailure']) ? $arguments['stopOnFailure'] : FALSE; $arguments['testDatabasePrefix'] = isset($arguments['testDatabasePrefix']) ? $arguments['testDatabasePrefix'] : ''; $arguments['verbose'] = isset($arguments['verbose']) ? $arguments['verbose'] : FALSE; $arguments['wait'] = isset($arguments['wait']) ? $arguments['wait'] : FALSE; if (isset($arguments['configuration'])) { $filterConfiguration = $arguments['configuration']->getFilterConfiguration(); PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = $filterConfiguration['whitelist']['addUncoveredFilesFromWhitelist']; foreach ($filterConfiguration['blacklist']['include']['directory'] as $dir) { PHPUnit_Util_Filter::addDirectoryToFilter($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['blacklist']['include']['file'] as $file) { PHPUnit_Util_Filter::addFileToFilter($file); } foreach ($filterConfiguration['blacklist']['exclude']['directory'] as $dir) { PHPUnit_Util_Filter::removeDirectoryFromFilter($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['blacklist']['exclude']['file'] as $file) { PHPUnit_Util_Filter::removeFileFromFilter($file); } foreach ($filterConfiguration['whitelist']['include']['directory'] as $dir) { PHPUnit_Util_Filter::addDirectoryToWhitelist($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['whitelist']['include']['file'] as $file) { PHPUnit_Util_Filter::addFileToWhitelist($file); } foreach ($filterConfiguration['whitelist']['exclude']['directory'] as $dir) { PHPUnit_Util_Filter::removeDirectoryFromWhitelist($dir['path'], $dir['suffix']); } foreach ($filterConfiguration['whitelist']['exclude']['file'] as $file) { PHPUnit_Util_Filter::removeFileFromWhitelist($file); } $phpConfiguration = $arguments['configuration']->getPHPConfiguration(); foreach ($phpConfiguration['ini'] as $name => $value) { ini_set($name, $value); } foreach ($phpConfiguration['var'] as $name => $value) { $GLOBALS[$name] = $value; } $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']; } $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-xml']) && !isset($arguments['coverageXML'])) { $arguments['coverageXML'] = $loggingConfiguration['coverage-xml']; } if (isset($loggingConfiguration['graphviz']) && !isset($arguments['graphvizLogfile'])) { $arguments['graphvizLogfile'] = $loggingConfiguration['graphviz']; } if (isset($loggingConfiguration['json']) && !isset($arguments['jsonLogfile'])) { $arguments['jsonLogfile'] = $loggingConfiguration['json']; } if (isset($loggingConfiguration['metrics-xml']) && !isset($arguments['metricsXML'])) { $arguments['metricsXML'] = $loggingConfiguration['metrics-xml']; } if (isset($loggingConfiguration['plain'])) { $arguments['listeners'][] = new PHPUnit_TextUI_ResultPrinter($loggingConfiguration['plain'], TRUE); } if (isset($loggingConfiguration['pmd-xml']) && !isset($arguments['pmdXML'])) { if (isset($loggingConfiguration['cpdMinLines']) && !isset($arguments['cpdMinLines'])) { $arguments['cpdMinLines'] = $loggingConfiguration['cpdMinLines']; } if (isset($loggingConfiguration['cpdMinMatches']) && !isset($arguments['cpdMinMatches'])) { $arguments['cpdMinMatches'] = $loggingConfiguration['cpdMinMatches']; } $arguments['pmdXML'] = $loggingConfiguration['pmd-xml']; } if (isset($loggingConfiguration['tap']) && !isset($arguments['tapLogfile'])) { $arguments['tapLogfile'] = $loggingConfiguration['tap']; } if (isset($loggingConfiguration['test-xml']) && !isset($arguments['xmlLogfile'])) { $arguments['xmlLogfile'] = $loggingConfiguration['test-xml']; 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']; } } $arguments['cpdMinLines'] = isset($arguments['cpdMinLines']) ? $arguments['cpdMinLines'] : 5; $arguments['cpdMinMatches'] = isset($arguments['cpdMinMatches']) ? $arguments['cpdMinMatches'] : 70; $arguments['groups'] = isset($arguments['groups']) ? $arguments['groups'] : array(); $arguments['excludeGroups'] = isset($arguments['excludeGroups']) ? $arguments['excludeGroups'] : array(); $arguments['logIncompleteSkipped'] = isset($arguments['logIncompleteSkipped']) ? $arguments['logIncompleteSkipped'] : FALSE; $arguments['reportCharset'] = isset($arguments['reportCharset']) ? $arguments['reportCharset'] : 'ISO-8859-1'; $arguments['reportYUI'] = isset($arguments['reportYUI']) ? $arguments['reportYUI'] : TRUE; $arguments['reportHighlight'] = isset($arguments['reportHighlight']) ? $arguments['reportHighlight'] : FALSE; $arguments['reportLowUpperBound'] = isset($arguments['reportLowUpperBound']) ? $arguments['reportLowUpperBound'] : 35; $arguments['reportHighLowerBound'] = isset($arguments['reportHighLowerBound']) ? $arguments['reportHighLowerBound'] : 70; if (isset($arguments['reportDirectory'])) { $arguments['reportDirectory'] = $this->getDirectory($arguments['reportDirectory']); } }
define('oxADMIN_PASSWD', 'admin'); } if (getenv('CODECOVERAGE')) { // PHPUnit_Util_Filter configuration PHPUnit_Util_Filter::$addUncoveredFilesFromWhitelist = true; PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/chromephp/chromephp_admin_list.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/chromephp/chromephp_admin_file.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/chromephp/chromephp_admin.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/chromephp/chromephp_admin_perform.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/chromephp/chromephp_admin_main.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/helper/helper_admin_list.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/helper/helper_admin_modules.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/Admin/helper/helper_admin_iframe.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/testperformance.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/modulemanagerlist.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/filemanager.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/chromephpmanager.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/authorization.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/chromephp.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/modulemanager.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/mysqlmanager.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/modulemanageranalize.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/include/chromephpfile.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/include/chromephpmysqlreading.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/include/chromephpmysql.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/include/chromephpheader.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/core/include/chromephpblocked.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/extensions/chromephp_oxutilsview.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/extensions/chromephp_oxshopcontrol.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . 'modules/debugax/view/helper_modules.php'); }
/** * Recursively whitelists an array of files * * @param array $files Array of files to whitelist */ static protected function set_whitelist($files) { foreach($files as $file) { if(is_array($file)) { self::set_whitelist($file); } else { if( ! isset(Kohana_Tests::$cache[$file])) { $relative_path = substr($file, strrpos($file, 'classes/') + 8, -strlen(EXT)); $cascading_file = Kohana::find_file('classes', $relative_path); // The theory is that if this file is the highest one in the cascading filesystem // then it's safe to whitelist Kohana_Tests::$cache[$file] = ($cascading_file === $file); } if(Kohana_Tests::$cache[$file]) { PHPUnit_Util_Filter::addFileToWhitelist($file); } } } }
<?php // Add "PHPUnit_Util_Filter::addFileToWhitelist( PATH_TO_FILE )" to add files to coverage // you can use the 'oxPATH' constant as the path to the shops root // PHPUnit_Util_Filter::addFileToWhitelist( oxPATH . '/modules/vendor/mymodule/core/myarticle.php' ); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/api.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/base.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/exception.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/notification.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/request_base.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/request_payment.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/request_refund.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/request_resend.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/api/request_update.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/controllers/bz_barzahlen_callback.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/controllers/bz_barzahlen_payment.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/controllers/bz_barzahlen_thankyou.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/controllers/bz_barzahlen_transactions.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/models/bz_barzahlen_order.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/models/bz_barzahlen_payment_gateway.php'); PHPUnit_Util_Filter::addFileToWhitelist(oxPATH . '/modules/bz_barzahlen/models/bz_barzahlen_update_handler.php');
protected static function includeCoverage() { PHPUnit_Util_Filter::addFileToWhitelist(VAF_PATH . '/html/vafAjax.include.php'); }
protected function _whitelist() { $folders = array('helpers', 'controllers', 'libraries'); foreach ($folders as $folder) { $files = self::list_files($folder, TRUE); foreach ($files as $file) { if (is_file($file)) { if ($file == __FILE__) { continue; } else { PHPUnit_Util_Filter::addFileToWhitelist($file); } } } } }
* File containing the runtests CLI script * * @copyright Copyright (C) 1999-2010 eZ Systems AS. All rights reserved. * @license http://ez.no/licenses/gnu_gpl GNU GPLv2 * @package tests */ set_time_limit(0); require_once 'autoload.php'; require_once 'PHPUnit/Framework.php'; require_once 'PHPUnit/TextUI/TestRunner.php'; require_once 'tests/toolkit/ezptestrunner.php'; // Exclude the test system from code coverage reports PHPUnit_Util_Filter::addDirectoryToFilter(getcwd() . '/tests'); // Whitelist all eZ Publish kernel files $baseDir = getcwd(); $autoloadArray = (include 'autoload/ezp_kernel.php'); foreach ($autoloadArray as $class => $file) { // Exclude files from the tests directory if (strpos($file, 'tests') !== 0) { PHPUnit_Util_Filter::addFileToWhitelist("{$baseDir}/{$file}"); } } $cli = eZCLI::instance(); $script = eZScript::instance(array('description' => "eZ Publish Test Runner\n\n" . "sets up an eZ Publish testing environment" . "\n", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true)); $script->startup(); // $options = $script->getOptions(); $script->initialize(); // Avoids Fatal error: eZ Publish did not finish its request if die() is used. eZExecution::setCleanExit(); ezpTestRunner::main(); $script->shutdown();
/** * Recursively whitelists an array of files * * @param array $files Array of files to whitelist * @param Unittest_TestSuite $suite Suite to load the whitelist into */ protected static function set_whitelist($files, Unittest_TestSuite $suite = NULL) { foreach ($files as $file) { if (is_array($file)) { self::set_whitelist($file, $suite); } else { if (!isset(Unittest_tests::$cache[$file])) { $relative_path = substr($file, strrpos($file, 'classes' . DIRECTORY_SEPARATOR) + 8, -strlen(EXT)); $cascading_file = Kohana::find_file('classes', $relative_path); // The theory is that if this file is the highest one in the cascading filesystem // then it's safe to whitelist Unittest_tests::$cache[$file] = $cascading_file === $file; } if (Unittest_tests::$cache[$file]) { if (isset($suite)) { $suite->addFileToWhitelist($file); } else { PHPUnit_Util_Filter::addFileToWhitelist($file); } } } } }
/** * Recursively whitelists an array of files * * @param array $files Array of files to whitelist */ protected static function set_whitelist($files) { if (self::$phpunit_v35) { $filter = PHP_CodeCoverage_Filter::getInstance(); } foreach ($files as $file) { if (is_array($file)) { self::set_whitelist($file); } else { if (!isset(Kohana_Tests::$cache[$file])) { $relative_path = substr($file, strrpos($file, 'classes' . DIRECTORY_SEPARATOR) + 8, -strlen(EXT)); $cascading_file = Kohana::find_file('classes', $relative_path); // The theory is that if this file is the highest one in the cascading filesystem // then it's safe to whitelist Kohana_Tests::$cache[$file] = $cascading_file === $file; } if (Kohana_Tests::$cache[$file]) { if (isset($filter)) { $filter->addFileToWhitelist($file); } else { PHPUnit_Util_Filter::addFileToWhitelist($file); } } } } }
function main() { /** * Whitelist files when using PHPUnit > 3.5 */ @(include_once 'PHPUnit/Runner/Version.php'); if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0) { $newFilter = true; } else { $newFilter = false; @(include_once 'PHPUnit/Util/Filter.php'); } $files = $this->getFilenames(); $this->log("Setting up coverage database for " . count($files) . " files"); $props = new Properties(); foreach ($files as $file) { $fullname = $file['fullname']; $filename = $file['key']; $props->setProperty($filename, serialize(array('fullname' => $fullname, 'coverage' => array()))); if ($newFilter) { PHP_CodeCoverage_Filter::getInstance()->addFileToWhiteList($file['fullname']); } else { PHPUnit_Util_Filter::addFileToWhitelist($file['fullname']); } } $dbfile = new PhingFile($this->database); $props->store($dbfile); $this->project->setProperty('coverage.database', $dbfile->getAbsolutePath()); }