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


PHP PHP_CodeCoverage::filter方法代码示例

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


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

示例1: beforeExample

 public function beforeExample(ExampleEvent $event)
 {
     if (!$this->enabled) {
         return;
     }
     $example = $event->getExample();
     $resource = $example->getSpecification()->getResource();
     $this->coverage->filter()->setWhitelistedFiles([]);
     $this->coverage->filter()->addFileToWhitelist($resource->getSrcFilename());
     $this->coverage->start($resource->getSrcClassname());
 }
开发者ID:addvilz,项目名称:phpspec-cover,代码行数:11,代码来源:Listener.php

示例2: __construct

 /**
  * Creates test runner instance.
  *
  * @param string        $rootPath      The absolute path to the root folder of the test suite.
  * @param ResultPrinter $resultPrinter Result printer.
  * @throws \Exception
  */
 public function __construct($rootPath, ResultPrinter $resultPrinter)
 {
     if (!is_dir($rootPath)) {
         throw new \Exception("{$rootPath} is not a directory");
     }
     $this->rootPath = $rootPath;
     $this->resultPrinter = $resultPrinter;
     try {
         $this->coverage = new \PHP_CodeCoverage();
         $this->coverage->filter()->addDirectoryToWhitelist($rootPath);
     } catch (\PHP_CodeCoverage_Exception $e) {
         // can't collect coverage
     }
 }
开发者ID:benesch,项目名称:php-annotations,代码行数:21,代码来源:xTestRunner.php

示例3: __construct

 /**
  * @param CodeCoverageMonitor  $codeCoverageMonitor,
  * @param CodeCoverageReporter $codeCoverageReporter,
  * @param string[]             $config
  */
 public function __construct(CodeCoverageMonitor $codeCoverageMonitor, CodeCoverageReporter $codeCoverageReporter, $config)
 {
     $this->codeCoverageMonitor = $codeCoverageMonitor;
     $this->codeCoverageReporter = $codeCoverageReporter;
     $this->reportFolder = $config['report_folder'];
     $codeCoverageMonitor->filter()->addDirectoryToWhitelist($config['context_folder']);
 }
开发者ID:sam-burns,项目名称:behat-context-file-usage,代码行数:12,代码来源:PhpUnitCodeCoverageTool.php

示例4: testAppendThrowsExceptionIfUsedCodeWasNotExecuted

 /**
  * @covers PHP_CodeCoverage::performUnexecutedCoveredCodeCheck
  * @expectedException PHP_CodeCoverage_CoveredCodeNotExecutedException
  */
 public function testAppendThrowsExceptionIfUsedCodeWasNotExecuted()
 {
     $this->coverage->filter()->addDirectoryToWhitelist(TEST_FILES_PATH);
     $this->coverage->setCheckForUnexecutedCoveredCode(true);
     $data = [TEST_FILES_PATH . 'BankAccount.php' => [29 => -1, 31 => -1]];
     $linesToBeCovered = [TEST_FILES_PATH . 'BankAccount.php' => [29, 31]];
     $linesToBeUsed = [TEST_FILES_PATH . 'BankAccount.php' => [22, 24]];
     $this->coverage->append($data, 'File1.php', true, $linesToBeCovered, $linesToBeUsed);
 }
开发者ID:ezrra,项目名称:PHP,代码行数:13,代码来源:CodeCoverageTest.php

示例5: process

    /**
     * @param  PHP_CodeCoverage $coverage
     * @param  string           $target
     * @return string
     */
    public function process(PHP_CodeCoverage $coverage, $target = null)
    {
        $filter = $coverage->filter();
        $output = sprintf('<?php
$coverage = new PHP_CodeCoverage;
$coverage->setData(%s);
$coverage->setTests(%s);

$filter = $coverage->filter();
$filter->setWhitelistedFiles(%s);

return $coverage;', var_export($coverage->getData(true), 1), var_export($coverage->getTests(), 1), var_export($filter->getWhitelistedFiles(), 1));
        if ($target !== null) {
            return file_put_contents($target, $output);
        } else {
            return $output;
        }
    }
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-zf25,代码行数:23,代码来源:PHP.php

示例6: __begin_coverage

function __begin_coverage()
{
    global $__coverage;
    if (isset($__coverage)) {
        return;
    }
    if (!getenv("TEST_COVERAGE")) {
        return;
    }
    require_once "PHP/CodeCoverage.php";
    require_once "PHP/CodeCoverage/Driver.php";
    require_once "PHP/CodeCoverage/Driver/Xdebug.php";
    require_once "PHP/CodeCoverage/Filter.php";
    require_once "PHP/CodeCoverage/Util.php";
    require_once "File/Iterator/Facade.php";
    require_once "File/Iterator/Factory.php";
    require_once "File/Iterator.php";
    $__coverage = new PHP_CodeCoverage();
    $__coverage->start('test');
    $__coverage->filter()->addDirectoryToWhitelist(realpath(dirname(__FILE__) . "/../Modyllic"));
    register_shutdown_function('__end_coverage');
}
开发者ID:nmx,项目名称:Modyllic,代码行数:22,代码来源:test_environment.php

示例7: run

 /**
  * Runs a TestCase.
  *
  * @param  PHPUnit_Framework_Test $test
  */
 public function run(PHPUnit_Framework_Test $test)
 {
     PHPUnit_Framework_Assert::resetCount();
     $error = FALSE;
     $failure = FALSE;
     $incomplete = FALSE;
     $skipped = FALSE;
     $this->startTest($test);
     $errorHandlerSet = FALSE;
     if ($this->convertErrorsToExceptions) {
         $oldErrorHandler = set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
         if ($oldErrorHandler === NULL) {
             $errorHandlerSet = TRUE;
         } else {
             restore_error_handler();
         }
     }
     if (self::$xdebugLoaded === NULL) {
         self::$xdebugLoaded = extension_loaded('xdebug');
         self::$useXdebug = self::$xdebugLoaded;
     }
     $useXdebug = self::$useXdebug && $this->codeCoverage !== NULL && !$test instanceof PHPUnit_Extensions_SeleniumTestCase && !$test instanceof PHPUnit_Framework_Warning;
     if ($useXdebug) {
         // We need to blacklist test source files when no whitelist is used.
         if (!$this->codeCoverage->filter()->hasWhitelist()) {
             $classes = PHPUnit_Util_Class::getHierarchy(get_class($test), TRUE);
             foreach ($classes as $class) {
                 $this->codeCoverage->filter()->addFileToBlacklist($class->getFileName());
             }
         }
         $this->codeCoverage->start($test);
     }
     PHP_Timer::start();
     try {
         if (!$test instanceof PHPUnit_Framework_Warning && $this->strictMode && extension_loaded('pcntl') && class_exists('PHP_Invoker')) {
             switch ($test->getSize()) {
                 case PHPUnit_Util_Test::SMALL:
                     $_timeout = $this->timeoutForSmallTests;
                     break;
                 case PHPUnit_Util_Test::MEDIUM:
                     $_timeout = $this->timeoutForMediumTests;
                     break;
                 case PHPUnit_Util_Test::LARGE:
                     $_timeout = $this->timeoutForLargeTests;
                     break;
             }
             $invoker = new PHP_Invoker();
             $invoker->invoke(array($test, 'runBare'), array(), $_timeout);
         } else {
             $test->runBare();
         }
     } catch (PHPUnit_Framework_AssertionFailedError $e) {
         $failure = TRUE;
         if ($e instanceof PHPUnit_Framework_IncompleteTestError) {
             $incomplete = TRUE;
         } else {
             if ($e instanceof PHPUnit_Framework_SkippedTestError) {
                 $skipped = TRUE;
             }
         }
     } catch (Exception $e) {
         $error = TRUE;
     }
     $time = PHP_Timer::stop();
     $test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
     if ($this->strictMode && $test->getNumAssertions() == 0) {
         $incomplete = TRUE;
     }
     if ($useXdebug) {
         try {
             $this->codeCoverage->stop(!$incomplete && !$skipped);
         } catch (PHP_CodeCoverage_Exception $cce) {
             $error = TRUE;
             if (!isset($e)) {
                 $e = $cce;
             }
         }
     }
     if ($errorHandlerSet === TRUE) {
         restore_error_handler();
     }
     if ($error === TRUE) {
         $this->addError($test, $e, $time);
     } else {
         if ($failure === TRUE) {
             $this->addFailure($test, $e, $time);
         } else {
             if ($this->strictMode && $test->getNumAssertions() == 0) {
                 $this->addFailure($test, new PHPUnit_Framework_IncompleteTestError('This test did not perform any assertions'), $time);
             } else {
                 if ($this->strictMode && $test->hasOutput()) {
                     $this->addFailure($test, new PHPUnit_Framework_OutputError(sprintf('This test printed output: %s', $test->getActualOutput())), $time);
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:qube81,项目名称:old-phpunit,代码行数:101,代码来源:TestResult.php

示例8: function

     $coverage = new PHP_CodeCoverage();
     $emitter->on('runner.start', function () use($coverage) {
         $coverage->filter()->addDirectoryToWhitelist(__DIR__ . '/src');
         $coverage->filter()->removeFileFromWhitelist(__DIR__ . '/src/Dsl.php');
         $coverage->start('peridot');
     });
     $emitter->on('runner.end', function () use($coverage) {
         $coverage->stop();
         $writer = new PHP_CodeCoverage_Report_HTML();
         $writer->process($coverage, __DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'report');
     });
 }
 if ($codeCoverage == 'clover' && $shouldCover) {
     $coverage = new PHP_CodeCoverage();
     $emitter->on('runner.start', function () use($coverage) {
         $coverage->filter()->addDirectoryToWhitelist(__DIR__ . '/src');
         $coverage->filter()->removeFileFromWhitelist(__DIR__ . '/src/Dsl.php');
         $coverage->start('peridot');
     });
     $emitter->on('runner.end', function () use($coverage) {
         $coverage->stop();
         $writer = new PHP_CodeCoverage_Report_Clover();
         $writer->process($coverage, __DIR__ . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'clover.xml');
     });
 }
 $emitter->on('peridot.start', function (Environment $env) use(&$coverage) {
     $definition = $env->getDefinition();
     $definition->option("banner", null, InputOption::VALUE_REQUIRED, "Custom banner text");
     $definition->getArgument('path')->setDefault('specs');
 });
 /**
开发者ID:peridot-php,项目名称:peridot,代码行数:31,代码来源:peridot.php

示例9: main

 /**
  * Main method.
  */
 public static function main()
 {
     $input = new ezcConsoleInput();
     $input->registerOption(new ezcConsoleOption('', 'clover', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'html', ezcConsoleInput::TYPE_STRING));
     $input->registerOption(new ezcConsoleOption('', 'blacklist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'whitelist', ezcConsoleInput::TYPE_STRING, array(), TRUE));
     $input->registerOption(new ezcConsoleOption('', 'merge', ezcConsoleInput::TYPE_NONE, FALSE));
     $input->registerOption(new ezcConsoleOption('h', 'help', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     $input->registerOption(new ezcConsoleOption('v', 'version', ezcConsoleInput::TYPE_NONE, NULL, FALSE, '', '', array(), array(), FALSE, FALSE, TRUE));
     try {
         $input->process();
     } catch (ezcConsoleOptionException $e) {
         print $e->getMessage() . "\n";
         exit(1);
     }
     if ($input->getOption('help')->value) {
         self::showHelp();
         exit(0);
     } else {
         if ($input->getOption('version')->value) {
             self::printVersionString();
             exit(0);
         }
     }
     $arguments = $input->getArguments();
     $clover = $input->getOption('clover')->value;
     $html = $input->getOption('html')->value;
     $blacklist = $input->getOption('blacklist')->value;
     $whitelist = $input->getOption('whitelist')->value;
     $merge = $input->getOption('merge')->value;
     if (count($arguments) == 1) {
         self::printVersionString();
         $coverage = new PHP_CodeCoverage();
         $filter = $coverage->filter();
         if (empty($whitelist)) {
             $c = new ReflectionClass('ezcBase');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             $c = new ReflectionClass('ezcConsoleInput');
             $filter->addDirectoryToBlacklist(dirname($c->getFileName()));
             foreach ($blacklist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToBlacklist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToBlacklist($item);
                     }
                 }
             }
         } else {
             foreach ($whitelist as $item) {
                 if (is_dir($item)) {
                     $filter->addDirectoryToWhitelist($item);
                 } else {
                     if (is_file($item)) {
                         $filter->addFileToWhitelist($item);
                     }
                 }
             }
         }
         if (!$merge) {
             $coverage->start('phpcov');
             require $arguments[0];
             $coverage->stop();
         } else {
             $facade = new File_Iterator_Facade();
             $result = $facade->getFilesAsArray($arguments[0], '.cov');
             foreach ($files as $file) {
                 $coverage->merge(unserialize(file_get_contents($file)));
             }
         }
         if ($clover) {
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($coverage, $clover);
         }
         if ($html) {
             $writer = new PHP_CodeCoverage_Report_HTML();
             $writer->process($coverage, $html);
         }
     } else {
         self::showHelp();
         exit(1);
     }
 }
开发者ID:proofek,项目名称:php-code-coverage,代码行数:87,代码来源:Command.php

示例10: merge

 /**
  * Merges the data from another instance of PHP_CodeCoverage.
  *
  * @param PHP_CodeCoverage $that
  */
 public function merge(PHP_CodeCoverage $that)
 {
     $this->filter->setBlacklistedFiles(array_merge($this->filter->getBlacklistedFiles(), $that->filter()->getBlacklistedFiles()));
     $this->filter->setWhitelistedFiles(array_merge($this->filter->getWhitelistedFiles(), $that->filter()->getWhitelistedFiles()));
     foreach ($that->data as $file => $lines) {
         if (!isset($this->data[$file])) {
             if (!$this->filter->isFiltered($file)) {
                 $this->data[$file] = $lines;
             }
             continue;
         }
         foreach ($lines as $line => $data) {
             if ($data !== NULL) {
                 if (!isset($this->data[$file][$line])) {
                     $this->data[$file][$line] = $data;
                 } else {
                     $this->data[$file][$line] = array_unique(array_merge($this->data[$file][$line], $data));
                 }
             }
         }
     }
     $this->tests = array_merge($this->tests, $that->getTests());
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:28,代码来源:CodeCoverage.php

示例11: __construct

 public function __construct(\PHP_CodeCoverage $phpCoverage)
 {
     $this->phpCodeCoverage = $phpCoverage ? $phpCoverage : new \PHP_CodeCoverage();
     $this->filter = $this->phpCodeCoverage->filter();
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:5,代码来源:Filter.php

示例12: merge

 /**
  * Merges the data from another instance of PHP_CodeCoverage.
  *
  * @param PHP_CodeCoverage $that
  */
 public function merge(PHP_CodeCoverage $that)
 {
     foreach ($that->getData() as $file => $lines) {
         if (!isset($this->data[$file])) {
             if (!$that->filter()->isFiltered($file)) {
                 $this->data[$file] = $lines;
             }
             continue;
         }
         foreach ($lines as $line => $data) {
             if ($data !== null) {
                 if (!isset($this->data[$file][$line])) {
                     $this->data[$file][$line] = $data;
                 } else {
                     $this->data[$file][$line] = array_unique(array_merge($this->data[$file][$line], $data));
                 }
             }
         }
     }
     $this->tests = array_merge($this->tests, $that->getTests());
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:26,代码来源:CodeCoverage.php

示例13:

                $files = array_merge($files, Tests::getFromCategory($argument));
            }
        }
    }
}
if (count($files) === 0) {
    $files = Tests::getAll();
}
switch ($command) {
    case 'list':
        Testrunner::search($files);
        break;
    case 'check':
        if (in_array('coverage', $options)) {
            $coverage = new PHP_CodeCoverage();
            $coverage->filter()->addDirectoryToWhitelist('src');
            $coverage->start('Testrunner');
        }
        $result = Testrunner::compare($files);
        if (in_array('coverage', $options)) {
            $coverage->stop();
            $writer = new PHP_CodeCoverage_Report_Clover();
            $writer->process($coverage, 'runner.xml');
            echo "\nCoverage saved as runner.xml\n\n";
        }
        if (!$result) {
            echo "[0;31mTestrunner failed, please fix or rebase before building or deploying![0m\n\n";
            if (in_array('show', $options)) {
                echo file_get_contents('runner.log') . "\n\n";
                echo "Done!\n\n";
            }
开发者ID:vicular,项目名称:Parser,代码行数:31,代码来源:runner.php

示例14: function

 if ($codeCoverage == 'html' && $shouldCover) {
     $coverage = new PHP_CodeCoverage();
     $emitter->on('runner.start', function () use($coverage) {
         $coverage->filter()->addFileToBlacklist(__DIR__ . '/src/Dsl.php');
         $coverage->start('peridot');
     });
     $emitter->on('runner.end', function () use($coverage) {
         $coverage->stop();
         $writer = new PHP_CodeCoverage_Report_HTML();
         $writer->process($coverage, __DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'report');
     });
 }
 if ($codeCoverage == 'clover' && $shouldCover) {
     $coverage = new PHP_CodeCoverage();
     $emitter->on('runner.start', function () use($coverage) {
         $coverage->filter()->addFileToBlacklist(__DIR__ . '/src/Dsl.php');
         $coverage->start('peridot');
     });
     $emitter->on('runner.end', function () use($coverage) {
         $coverage->stop();
         $writer = new PHP_CodeCoverage_Report_Clover();
         $writer->process($coverage, __DIR__ . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR . 'clover.xml');
     });
 }
 $emitter->on('peridot.start', function (Environment $env) use(&$coverage) {
     $definition = $env->getDefinition();
     $definition->option("banner", null, InputOption::VALUE_REQUIRED, "Custom banner text");
     $definition->getArgument('path')->setDefault('specs');
 });
 /**
  * Demonstrate registering a custom reporter via peridot config
开发者ID:austinsmorris,项目名称:peridot,代码行数:31,代码来源:peridot.php

示例15: file

 * with this program;  If not, see <http://www.gnu.org/licenses/>.
 */
require_once __DIR__ . '/../../vendor/autoload.php';
$php_code_coverage = null;
$php_code_coverage_db = null;
if (getenv('PHP_CODE_COVERAGE')) {
    $php_code_coverage_db = file(getenv('PHP_CODE_COVERAGE'), FILE_IGNORE_NEW_LINES);
    $php_code_coverage_db_tmp = [];
    foreach ($php_code_coverage_db as $entry) {
        $entry = explode('=', $entry, 2);
        $php_code_coverage_db_tmp[$entry[0]] = unserialize($entry[1]);
    }
    $php_code_coverage_db = $php_code_coverage_db_tmp;
    unset($php_code_coverage_db_tmp);
    $php_code_coverage = new PHP_CodeCoverage();
    $php_code_coverage_filter = $php_code_coverage->filter();
    $php_code_coverage_filter->addFileToBlacklist(__FILE__);
    foreach ($php_code_coverage_db as $entry) {
        $php_code_coverage_filter->addFileToWhitelist($entry['fullname']);
    }
    $php_code_coverage->start(basename(getenv('PHP_CODE_COVERAGE')));
    register_shutdown_function(function ($php_code_coverage, $php_code_coverage_db) {
        $php_code_coverage->stop();
        foreach ($php_code_coverage->getData(true) as $file => $coverage) {
            foreach ($coverage as $line => $id) {
                if (!isset($php_code_coverage_db[strtolower($file)]['coverage'][$line]) || !is_array($php_code_coverage_db[strtolower($file)]['coverage'][$line])) {
                    $php_code_coverage_db[strtolower($file)]['coverage'][$line] = [];
                }
                $id = !is_array($id) ? [$id] : $id;
                $php_code_coverage_db[strtolower($file)]['coverage'][$line] = array_unique(array_merge($id, $php_code_coverage_db[strtolower($file)]['coverage'][$line]));
            }
开发者ID:adrianbroher,项目名称:thwboard,代码行数:31,代码来源:coverage.php


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