本文整理汇总了PHP中PHP_CodeCoverage_Filter类的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeCoverage_Filter类的具体用法?PHP PHP_CodeCoverage_Filter怎么用?PHP PHP_CodeCoverage_Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHP_CodeCoverage_Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSimpleMergeLegacy
/**
* Test merge for code coverage library 3 version
*
* @requires function \PHP_CodeCoverage::merge
*/
public function testSimpleMergeLegacy()
{
$firstFile = PARATEST_ROOT . '/src/ParaTest/Logging/LogInterpreter.php';
$secondFile = PARATEST_ROOT . '/src/ParaTest/Logging/MetaProvider.php';
$filter = new \PHP_CodeCoverage_Filter();
$filter->addFilesToWhitelist([$firstFile, $secondFile]);
$coverage1 = new \PHP_CodeCoverage(null, $filter);
$coverage1->append(array($firstFile => array(35 => 1), $secondFile => array(34 => 1)), 'Test1');
$coverage2 = new \PHP_CodeCoverage(null, $filter);
$coverage2->append(array($firstFile => array(35 => 1, 36 => 1)), 'Test2');
$merger = new CoverageMerger();
$this->call($merger, 'addCoverage', $coverage1);
$this->call($merger, 'addCoverage', $coverage2);
/** @var \PHP_CodeCoverage $coverage */
$coverage = $this->getObjectValue($merger, 'coverage');
$this->assertInstanceOf('\\PHP_CodeCoverage', $coverage);
$data = $coverage->getData();
$this->assertCount(2, $data[$firstFile][35]);
$this->assertEquals('Test1', $data[$firstFile][35][0]);
$this->assertEquals('Test2', $data[$firstFile][35][1]);
$this->assertCount(1, $data[$firstFile][36]);
$this->assertEquals('Test2', $data[$firstFile][36][0]);
$this->assertCount(1, $data[$secondFile][34]);
$this->assertEquals('Test1', $data[$secondFile][34][0]);
}
示例2: __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();
}
示例3: 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);
}
}
示例4: __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);
}
}
示例5: __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);
}
}
示例6: startTestSuite
/**
* Add Mockery files to PHPUnit's blacklist so they don't showup on coverage reports
*/
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
if (class_exists('\\PHP_CodeCoverage_Filter') && method_exists('\\PHP_CodeCoverage_Filter', 'getInstance')) {
\PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(__DIR__ . '/../../../Mockery/', '.php', '', 'PHPUNIT');
\PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__DIR__ . '/../../../Mockery.php', 'PHPUNIT');
}
}
示例7: createTestResult
/**
* Create the test result and splice on our code coverage reports.
*
* @return PHPUnit_Framework_TestResult
*/
protected function createTestResult()
{
$result = new PHPUnit_Framework_TestResult();
$FixtureInjector = new FixtureInjector($this->_getFixtureManager(array()));
$result->addListener($FixtureInjector);
if (!empty($this->_params['codeCoverage'])) {
if (method_exists($result, 'collectCodeCoverageInformation')) {
$result->collectCodeCoverageInformation(true);
}
if (method_exists($result, 'setCodeCoverage')) {
$Filter = new PHP_CodeCoverage_Filter();
$Filter->addFileToBlacklist('systemlib.php');
$result->setCodeCoverage(new PHP_CodeCoverage(null, $Filter));
}
}
return $result;
}
示例8: getCodeCoverageFilter
/**
* Get the code coverage filter instance we will use for tests.
* When running PHPUnit 3.5, this will return the singleton instance.
* When running PHPUnit 3.6, this will return the instance we hold internally;
* this same instance will be passed to PHPUnit in AgaviTesting::dispatch().
*
* @return PHP_CodeCoverage_Filter The code coverage filter for our tests.
*
* @author David Zülke <david.zuelke@bitextender.com>
* @since 1.0.7
* @deprecated 1.1.0 Use AgaviPhpUnitCli
*/
public static function getCodeCoverageFilter()
{
if (self::$codeCoverageFilter === null) {
// PHP_CodeCoverage doesn't expose any version info, we'll have to check if there is a static getInstance method
self::$codeCoverageFilter = method_exists('PHP_CodeCoverage_Filter', 'getInstance') ? PHP_CodeCoverage_Filter::getInstance() : new PHP_CodeCoverage_Filter();
}
return self::$codeCoverageFilter;
}
示例9: init
/**
* Initialise the wrapper class.
*/
public function init()
{
require_once 'PHP/CodeCoverage.php';
require_once 'PHP/CodeCoverage/Report/HTML.php';
require_once 'PHPUnit/Autoload.php';
require_once 'PHP/CodeCoverage/Filter.php';
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'PHPUNIT');
}
示例10: setUp
/**
* Set up the test suite.
*
* @return void
* @access protected
*/
protected function setUp()
{
// Update the code coverage blacklist -- we don't want to analyze all the
// test code or any external PEAR libraries that we include:
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('/usr/share/php');
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('/usr/local/lib');
PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(dirname(__FILE__));
// Clear out Smarty files to ensure testing begins with a clean slate:
$this->_smartyCleanup();
}
示例11: phpunit_autoload
function phpunit_autoload($class)
{
if (strpos($class, 'PHPUnit_') === 0) {
$file = str_replace('_', '/', $class) . '.php';
$file = PHPUnit_Util_Filesystem::fileExistsInIncludePath($file);
if ($file) {
require_once $file;
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist($file, 'PHPUNIT');
}
}
}
示例12: setCodeCoverageIgnores
protected function setCodeCoverageIgnores()
{
$codeCoverageFilter = PHP_CodeCoverage_Filter::getInstance();
$codeCoverageFilter->addDirectoryToBlacklist(dirname(__FILE__));
foreach($this->codeCoverageIgnoreDirectoryList as $oneDirectory)
{
$codeCoverageFilter->addDirectoryToBlacklist($oneDirectory);
}
$codeCoverageFilter->addFilesToBlackList($this->codeCoverageIgnoreFileList);
}
示例13: 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');
}
}
}
示例14: testSimpleMerge
public function testSimpleMerge()
{
$firstFile = PARATEST_ROOT . '/src/ParaTest/Logging/LogInterpreter.php';
$secondFile = PARATEST_ROOT . '/src/ParaTest/Logging/MetaProvider.php';
$filter = new \PHP_CodeCoverage_Filter();
$filter->addFilesToWhitelist([$firstFile, $secondFile]);
$coverage1 = new \PHP_CodeCoverage(null, $filter);
$coverage1->append(array($firstFile => array(35 => 1), $secondFile => array(34 => 1)), 'Test1');
$coverage2 = new \PHP_CodeCoverage(null, $filter);
$coverage2->append(array($firstFile => array(35 => 1, 36 => 1)), 'Test2');
$merger = new CoverageMerger();
$merger->addCoverage($coverage1);
$merger->addCoverage($coverage2);
$coverage = $merger->getCoverage();
$data = $coverage->getData();
$this->assertEquals(2, count($data[$firstFile][35]));
$this->assertEquals('Test1', $data[$firstFile][35][0]);
$this->assertEquals('Test2', $data[$firstFile][35][1]);
$this->assertEquals(1, count($data[$firstFile][36]));
$this->assertEquals('Test2', $data[$firstFile][36][0]);
$this->assertEquals(1, count($data[$secondFile][34]));
$this->assertEquals('Test1', $data[$secondFile][34][0]);
}
示例15: init
/**
* Initializes the Spec library
*
* @static
* @param bool $autoload Unless it's false it will register a custom autoloader
* @return bool
*/
public static function init($autoload = true)
{
static $alreadyInitialized = false;
if ($alreadyInitialized) {
return false;
}
// Register auto loader
if ($autoload) {
self::autoload();
}
// Register stream wrapper for spec files
$scheme = self::SCHEME;
if (!in_array($scheme, stream_get_wrappers())) {
// Get loaded extensions
$extensions = array_merge(get_loaded_extensions(), get_loaded_extensions(true));
// Check if the Suhosin patch is loaded
if (in_array('suhosin', $extensions)) {
$list = ini_get('suhosin.executor.include.whitelist');
$list = explode(',', $list);
$list = array_filter(array_map('trim', $list));
if (!in_array($scheme, $list)) {
throw new \RuntimeException("The Suhosin patch has been detected but the custom '{$scheme}' scheme was not found as allowed. " . "Please review your php.ini settings to include '{$scheme}' in 'suhosin.executor.include.whitelist'.");
}
}
stream_wrapper_register($scheme, __NAMESPACE__ . '\\Spec\\StreamWrapper');
}
// Black list Spec files for PHPUnit
if (class_exists('\\PHP_CodeCoverage_Filter', false)) {
$filter = \PHP_CodeCoverage_Filter::getInstance();
$filter->addFileToBlacklist(__FILE__, 'PHPUNIT');
$filter->addDirectoryToBlacklist(__DIR__ . DIRECTORY_SEPARATOR . 'Spec', '.php', '', 'PHPUNIT', FALSE);
// Also add Hamcrest matcher library from the include path
$paths = explode(PATH_SEPARATOR, get_include_path());
foreach ($paths as $path) {
if (is_file($path . DIRECTORY_SEPARATOR . 'Hamcrest/MatcherAssert.php')) {
$filter->addDirectoryToBlacklist($path . DIRECTORY_SEPARATOR . 'Hamcrest', '.php', '', 'PHPUNIT', FALSE);
break;
}
}
}
// include standard matchers and keywords
include_once __DIR__ . '/Spec/keywords.php';
include_once __DIR__ . '/Spec/matchers.php';
// Setup suite stack
self::$suites = new \SplStack();
return true;
}