本文整理汇总了PHP中PHPUnit_Util_Filter::addDirectoryToFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Filter::addDirectoryToFilter方法的具体用法?PHP PHPUnit_Util_Filter::addDirectoryToFilter怎么用?PHP PHPUnit_Util_Filter::addDirectoryToFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Util_Filter
的用法示例。
在下文中一共展示了PHPUnit_Util_Filter::addDirectoryToFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configure_enviroment
/**
* Configures the enviroment for testing
*
* Does the following:
*
* * Loads the phpunit framework (for the web ui)
* * Restores exception phpunit error handlers (for cli)
* * registeres an autoloader to load test files
*/
public static function configure_enviroment($do_whitelist = TRUE, $do_blacklist = TRUE)
{
if (!class_exists('PHPUnit_Util_Filter', FALSE)) {
// Make sure the PHPUnit classes are available
require_once 'PHPUnit/Framework.php';
}
if (Kohana::$is_cli) {
restore_exception_handler();
restore_error_handler();
}
spl_autoload_register(array('Kohana_Tests', 'autoload'));
Kohana_Tests::$cache = ($cache = Kohana::cache('phpunit_whitelist_cache')) === NULL ? array() : $cache;
$config = Kohana::config('phpunit');
if ($do_whitelist and $config->use_whitelist) {
self::whitelist();
}
if ($do_blacklist and count($config['blacklist'])) {
foreach ($config->blacklist as $item) {
if (is_dir($item)) {
PHPUnit_Util_Filter::addDirectoryToFilter($item);
} else {
PHPUnit_Util_Filter::addFileToFilter($item);
}
}
}
}
示例2: process
/**
* Classe capable de prendre en charge les suites de test à lancer depuis le point d'entrée
* test.php
* Actuellement capable de lancer uniquement les tests relatifs au framework. Par la suite
* il est souhaitable qu'il puisse prendre en charge le lancement des tests fonctionnels.
*
* @param array $pParams Tableau de paramètres
*
* @todo être capable de lancer les tests fonctionnels avec ce controller.
*/
public function process($pParams)
{
if (@(include_once 'PHPUnit/Framework.php')) {
require_once COPIX_PATH . 'tests/CopixTest.class.php';
require_once COPIX_PATH . 'tests/CopixDBTest.class.php';
require_once COPIX_PATH . 'tests/CopixTestRunner.class.php';
require_once COPIX_PATH . 'tests/CopixTestPrinter.class.php';
require_once COPIX_PATH . 'tests/CopixTestXMLPrinter.class.php';
// Ignore les fichiers de framework de test
PHPUnit_Util_Filter::addDirectoryToFilter(dirname(__FILE__));
PHPUnit_Util_Filter::addDirectoryToFilter(dirname(__FILE__) . '/framework');
$this->_configFile = isset($pParams['conf']) ? $pParams['conf'] : '../project/config/copix.conf.php';
if (!isset($_REQUEST['tests'])) {
$this->testWelcome();
} else {
if (!isset($pParams['xml']) || $pParams['xml'] == false) {
$options['reportDirectory'] = COPIX_TEMP_PATH;
}
$options['xml'] = isset($pParams['xml']) && $pParams['xml'];
CopixTestRunner::run($this->_getSuite(), $options);
}
} else {
$this->showRequiredPHPUnit();
}
}
示例3: beforeRunTests
/**
* Overwrites beforeRunTests. Initiates coverage-report generation if
* $coverage has been set to true (@see setCoverageStatus).
*/
protected function beforeRunTests()
{
if ($this->getCoverageStatus()) {
// blacklist selected folders from coverage report
foreach (TestRunner::$coverage_filter_dirs as $dir) {
PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir);
}
$this->getFrameworkTestResults()->collectCodeCoverageInformation(true);
}
}
示例4: blacklistDirectories
public function blacklistDirectories()
{
$directories = new DirectoryIterator(PROJECT_ROOT . DS . 'modules');
foreach ($directories as $directory) {
if (!$directory->isDot() && $directory->isDir()) {
$path = $directory->getPathname() . DS . '_tests';
if (is_dir($path)) {
PHPUnit_Util_Filter::addDirectoryToFilter($path, '.php');
}
}
}
}
示例5: suite
public static function suite()
{
PHPUnit_Util_Filter::addDirectoryToFilter(dirname(__FILE__));
$suite = new PHPUnit_Framework_TestSuite();
$suite->setName('SimpleDOM');
foreach (glob(dirname(__FILE__) . '/*.php') as $filepath) {
$name = basename($filepath, '.php');
if ($name != 'AllTests') {
$suite->addTestFile($filepath);
}
}
return $suite;
}
示例6: suite
public static function suite()
{
if (!class_exists('Kohana')) {
throw new Exception('Please include the kohana bootstrap file.');
}
spl_autoload_unregister(array('Kohana', 'auto_load'));
spl_autoload_register(array('Tests', 'auto_load'));
$files = Kohana::list_files('tests');
// Files to include in code coverage
self::whitelist();
$suite = new PHPUnit_Framework_TestSuite();
$folders = Kohana::config('phpunit.filter_folders');
foreach ($folders as $folder) {
PHPUnit_Util_Filter::addDirectoryToFilter($folder);
}
self::addTests($suite, $files);
return $suite;
}
示例7: beforeRunTests
/**
* Overwrites beforeRunTests. Initiates coverage-report generation if
* $coverage has been set to true (@see setCoverageStatus).
*/
protected function beforeRunTests()
{
if ($this->getCoverageStatus()) {
// blacklist selected folders from coverage report
$modules = $this->moduleDirectories();
foreach (TestRunner::config()->coverage_filter_dirs as $dir) {
if ($dir[0] == '*') {
$dir = substr($dir, 1);
foreach ($modules as $module) {
PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir);
}
} else {
PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir);
}
}
$this->getFrameworkTestResults()->collectCodeCoverageInformation(true);
}
}
示例8: prepare_harness
protected function prepare_harness()
{
if ($this->ver_phpunit < 3.5) {
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/ResultPrinter.php';
require_once 'PHPUnit/TextUI/Command.php';
PHPUnit_Util_Filter::addDirectoryToFilter($this->root, '.php', 'PHPUNIT', '');
} elseif ($this->ver_phpunit < 3.6) {
require_once 'PHPUnit/Autoload.php';
require_once 'PHP/CodeCoverage.php';
PHP_CodeCoverage::getInstance()->filter()->addDirectoryToBlacklist($this->root, '.php', '', 'PHPUNIT');
} else {
// PHPUnit 3.6+
/**
* Change to support PHPUnit 4+
* These libraries are loaded in via phpunit.phar or don't exist in PHPUnit 4+
*/
//require_once( 'PHPUnit/Autoload.php' );
//require_once( 'PHP/CodeCoverage.php' );
$this->add_directory_to_blacklist($this->root, '.php');
}
}
示例9: init
/**
* Initialize Task.
* This method includes any necessary PHPUnit2 libraries and triggers
* appropriate error if they cannot be found. This is not done in header
* because we may want this class to be loaded w/o triggering an error.
*/
public function init()
{
if (version_compare(PHP_VERSION, '5.0.3') < 0) {
throw new BuildException("PHPUnitTask requires PHP version >= 5.0.3", $this->getLocation());
}
/**
* Determine PHPUnit version number
*/
@(include_once 'PHPUnit/Runner/Version.php');
$version = PHPUnit_Runner_Version::id();
if (version_compare($version, '3.2.0') < 0) {
throw new BuildException("PHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation());
}
/**
* Other dependencies that should only be loaded when class is actually used.
*/
require_once 'phing/tasks/ext/phpunit/PHPUnitTestRunner.php';
require_once 'phing/tasks/ext/phpunit/BatchTest.php';
require_once 'phing/tasks/ext/phpunit/FormatterElement.php';
/**
* point PHPUnit_MAIN_METHOD define to non-existing method
*/
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined');
}
/**
* Add some defaults to the PHPUnit filter
*/
$pwd = dirname(__FILE__);
$path = realpath($pwd . '/../../../');
if (version_compare($version, '3.5.0') >= 0) {
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist($path);
} else {
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Util/Filter.php';
PHPUnit_Util_Filter::addDirectoryToFilter($path);
}
}
示例10: error_reporting
/*
* Set error reporting to the level to which Zend Framework code must comply.
*/
error_reporting(E_ALL | E_STRICT);
/*
* Determine the root, library, and tests directories of the framework
* distribution.
*/
$zfRoot = dirname(__FILE__) . '/..';
$zfCoreLibrary = "{$zfRoot}/library";
$zfCoreTests = "{$zfRoot}/tests";
/*
* Omit from code coverage reports the contents of the tests directory
*/
foreach (array('php', 'phtml', 'csv') as $suffix) {
PHPUnit_Util_Filter::addDirectoryToFilter($zfCoreTests, ".{$suffix}");
}
/*
* Prepend the Zend Framework library/ and tests/ directories to the
* include_path. This allows the tests to run out of the box and helps prevent
* loading other copies of the framework code and tests that would supersede
* this copy.
*/
$path = array($zfCoreLibrary, $zfCoreTests, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $path));
/*
* Load the user-defined test configuration file, if it exists; otherwise, load
* the default configuration.
*/
if (is_readable($zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
示例11: error_reporting
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/Framework/IncompleteTestError.php';
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'PHPUnit/Framework/TestSuite.php';
require_once 'PHPUnit/Runner/Version.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'PHPUnit/Util/Filter.php';
// Set error reporting level
error_reporting(E_ALL | E_STRICT);
// Determine the root, library, and tests directories
$root_path = dirname(__FILE__) . '/..';
$library_path = "{$root_path}/library";
$tests_path = "{$root_path}/tests";
// Omit from code coverage reports the contents of the tests directory
foreach (array('php', 'phtml', 'csv') as $suffix) {
PHPUnit_Util_Filter::addDirectoryToFilter($tests_path, ".{$suffix}");
}
// Set the include path to include Aspamia files first
$path = array($library_path, $tests_path, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $path));
/**
* Load the user-defined test configuration file, if it exists; otherwise, load
* the default configuration.
*/
if (is_readable($tests_path . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
require_once $tests_path . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
} else {
require_once $tests_path . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist';
}
// Add the library files to the code coverage reports
if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true && version_compare(PHPUnit_Runner_Version::id(), '3.1.6', '>=')) {
示例12: set_include_path
<?php
set_include_path(implode(PATH_SEPARATOR, array(dirname(__FILE__), get_include_path())));
/**
* The ethos_Test package require the Zend_Loader package from Zend Framework.
* @link http://framework.zend.com/
*/
require_once 'Zend/Loader/Autoloader.php';
/**
* Zend_Loader_Autoloader registers underscore-delimited psuedo-namespaces to
* automatically load classes into memory as they're needed. For unit testing,
* we expect that test fixtures will be subclassed in the "Test" namespace,
* while base classes exist in the "ethos" namespace.
*
* @see Zend_Loader_Autoloader::registerNamespace()
*/
Zend_Loader_Autoloader::getInstance()->registerNamespace('Test')->registerNamespace('ethos');
// END Zend_Loader_Autoloader
require_once 'PHPUnit/Framework.php';
PHPUnit_Util_Filter::addDirectoryToFilter('Zend', '.php');
PHPUnit_Util_Filter::addDirectoryToFilter('Test', 'Test.php');
示例13: main
require_once 'security/all_tests.php';
require_once 'template/all_tests.php';
require_once 'text_processing/all_tests.php';
require_once 'dbal/all_tests.php';
require_once 'regex/all_tests.php';
require_once 'network/all_tests.php';
require_once 'random/all_tests.php';
// exclude the test directory from code coverage reports
if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0') >= 0)
{
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('./');
}
else
{
PHPUnit_Util_Filter::addDirectoryToFilter('./');
}
class phpbb_all_tests
{
public static function main()
{
PHPUnit_TextUI_TestRunner::run(self::suite());
}
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite('phpBB');
$suite->addTest(phpbb_utf_all_tests::suite());
$suite->addTest(phpbb_request_all_tests::suite());
示例14: runTests
/**
* @param array $classList
* @param boolean $coverage
*/
function runTests($classList, $coverage = false)
{
$startTime = microtime(true);
// XDEBUG seem to cause problems with test execution :-(
if (function_exists('xdebug_disable')) {
xdebug_disable();
}
ini_set('max_execution_time', 0);
$this->setUp();
// Optionally skip certain tests
$skipTests = array();
if ($this->request->getVar('SkipTests')) {
$skipTests = explode(',', $this->request->getVar('SkipTests'));
}
$classList = array_diff($classList, $skipTests);
// run tests before outputting anything to the client
$suite = new PHPUnit_Framework_TestSuite();
natcasesort($classList);
foreach ($classList as $className) {
// Ensure that the autoloader pulls in the test class, as PHPUnit won't know how to do this.
class_exists($className);
$suite->addTest(new SapphireTestSuite($className));
}
// Remove the error handler so that PHPUnit can add its own
restore_error_handler();
/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
if (Director::is_cli()) {
$reporter = new CliTestReporter();
} else {
$reporter = new SapphireTestReporter();
}
self::$default_reporter->writeHeader("Sapphire Test Runner");
if (count($classList) > 1) {
self::$default_reporter->writeInfo("All Tests", "Running test cases: ", implode(", ", $classList));
} else {
self::$default_reporter->writeInfo($classList[0], "");
}
$results = new PHPUnit_Framework_TestResult();
$results->addListener($reporter);
if ($coverage === true) {
foreach (self::$coverage_filter_dirs as $dir) {
PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir);
}
$results->collectCodeCoverageInformation(true);
$suite->run($results);
if (!file_exists(ASSETS_PATH . '/coverage-report')) {
mkdir(ASSETS_PATH . '/coverage-report');
}
PHPUnit_Util_Report::render($results, ASSETS_PATH . '/coverage-report/');
$coverageApp = ASSETS_PATH . '/coverage-report/' . preg_replace('/[^A-Za-z0-9]/', '_', preg_replace('/(\\/$)|(^\\/)/', '', Director::baseFolder())) . '.html';
$coverageTemplates = ASSETS_PATH . '/coverage-report/' . preg_replace('/[^A-Za-z0-9]/', '_', preg_replace('/(\\/$)|(^\\/)/', '', realpath(TEMP_FOLDER))) . '.html';
echo "<p>Coverage reports available here:<ul>\n\t\t\t\t<li><a href=\"{$coverageApp}\">Coverage report of the application</a></li>\n\t\t\t\t<li><a href=\"{$coverageTemplates}\">Coverage report of the templates</a></li>\n\t\t\t</ul>";
} else {
$suite->run($results);
}
if (!Director::is_cli()) {
echo '<div class="trace">';
}
$reporter->writeResults();
$endTime = microtime(true);
if (Director::is_cli()) {
echo "\n\nTotal time: " . round($endTime - $startTime, 3) . " seconds\n";
} else {
echo "<p>Total time: " . round($endTime - $startTime, 3) . " seconds</p>\n";
}
if (!Director::is_cli()) {
echo '</div>';
}
// Put the error handlers back
Debug::loadErrorHandlers();
if (!Director::is_cli()) {
self::$default_reporter->writeFooter();
}
$this->tearDown();
// Todo: we should figure out how to pass this data back through Director more cleanly
if (Director::is_cli() && $results->failureCount() + $results->errorCount() > 0) {
exit(2);
}
}
示例15: setWhiteAndBlacklists
/**
* Set white / black lists
*/
public function setWhiteAndBlacklists()
{
if ($this->isPhpunitVersionGreaterOrEquals("3.6.0")) {
$filter = new PHP_CodeCoverage_Filter();
$filter->addDirectoryToBlacklist(PATH_TO_TEST_DIR);
$filter->addDirectoryToBlacklist(PATH_TO_TINE_LIBRARY);
$filter->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Setup');
$filter->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Zend');
} else {
if ($this->isPhpunitVersionGreaterOrEquals("3.5.0")) {
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_TEST_DIR);
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_TINE_LIBRARY);
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Setup');
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(PATH_TO_REAL_DIR . '/Zend');
} else {
PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_TEST_DIR);
PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_TINE_LIBRARY);
PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_REAL_DIR . '/Setup');
PHPUnit_Util_Filter::addDirectoryToFilter(PATH_TO_REAL_DIR . '/Zend');
}
}
}