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


PHP PHP_CodeCoverage类代码示例

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


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

示例1: process

 /**
  * @param PHP_CodeCoverage $coverage
  * @param string           $target
  */
 public function process(PHP_CodeCoverage $coverage, $target)
 {
     $target = $this->getDirectory($target);
     $report = $coverage->getReport();
     unset($coverage);
     if (!isset($_SERVER['REQUEST_TIME'])) {
         $_SERVER['REQUEST_TIME'] = time();
     }
     $date = date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']);
     $dashboard = new PHP_CodeCoverage_Report_HTML_Renderer_Dashboard($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $directory = new PHP_CodeCoverage_Report_HTML_Renderer_Directory($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $file = new PHP_CodeCoverage_Report_HTML_Renderer_File($this->templatePath, $this->generator, $date, $this->lowUpperBound, $this->highLowerBound);
     $directory->render($report, $target . 'index.html');
     $dashboard->render($report, $target . 'dashboard.html');
     foreach ($report as $node) {
         $id = $node->getId();
         if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) {
             if (!file_exists($target . $id)) {
                 mkdir($target . $id, 0777, true);
             }
             $directory->render($node, $target . $id . '/index.html');
             $dashboard->render($node, $target . $id . '/dashboard.html');
         } else {
             $dir = dirname($target . $id);
             if (!file_exists($dir)) {
                 mkdir($dir, 0777, true);
             }
             $file->render($node, $target . $id . '.html');
         }
     }
     $this->copyFiles($target);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:36,代码来源:HTML.php

示例2: getCoverageForFileWithIgnoredLines

 protected function getCoverageForFileWithIgnoredLines()
 {
     $coverage = new PHP_CodeCoverage($this->setUpXdebugStubForFileWithIgnoredLines(), new PHP_CodeCoverage_Filter());
     $coverage->start('FileWithIgnoredLines', TRUE);
     $coverage->stop();
     return $coverage;
 }
开发者ID:rdohms,项目名称:php-code-coverage,代码行数:7,代码来源:TestCase.php

示例3: 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]);
 }
开发者ID:brianium,项目名称:paratest,代码行数:30,代码来源:CoverageMergerTest.php

示例4: getCoverageForClassWithAnonymousFunction

 protected function getCoverageForClassWithAnonymousFunction()
 {
     $coverage = new PHP_CodeCoverage($this->setUpXdebugStubForClassWithAnonymousFunction(), new PHP_CodeCoverage_Filter());
     $coverage->start('ClassWithAnonymousFunction', true);
     $coverage->stop();
     return $coverage;
 }
开发者ID:xiaobudongzhang,项目名称:php-code-coverage,代码行数:7,代码来源:TestCase.php

示例5: addCoverage

 /**
  * @param \PHP_CodeCoverage|CodeCoverage $coverage
  */
 private function addCoverage($coverage)
 {
     if (null === $this->coverage) {
         $this->coverage = $coverage;
     } else {
         $this->coverage->merge($coverage);
     }
 }
开发者ID:brianium,项目名称:paratest,代码行数:11,代码来源:CoverageMerger.php

示例6: create

 /**
  * @param PHP_CodeCoverage $coverage
  */
 public function create(PHP_CodeCoverage $coverage)
 {
     $files = $coverage->getData();
     $commonPath = $this->reducePaths($files);
     $root = new PHP_CodeCoverage_Report_Node_Directory($commonPath, null);
     $this->addItems($root, $this->buildDirectoryStructure($files), $coverage->getTests(), $coverage->getCacheTokens());
     return $root;
 }
开发者ID:eunicon,项目名称:meetup,代码行数:11,代码来源:Factory.php

示例7: coverage

 /**
  * @return \PHP_CodeCoverage
  */
 public function coverage()
 {
     $coverage = new \PHP_CodeCoverage();
     $coverage->setData($this->data);
     $coverage->setTests($this->tests);
     $filter = $coverage->filter();
     $filter->setBlacklistedFiles($this->blackList);
     $filter->setWhitelistedFiles($this->whiteList);
     return $coverage;
 }
开发者ID:greencape,项目名称:phing-tasks,代码行数:13,代码来源:CoverageCollector.php

示例8: parseReport

 public function parseReport(\PHP_CodeCoverage $report)
 {
     $classes = array();
     foreach ($report->getData() as $filename => $coverage) {
         try {
             $classes[] = $this->parseClass($filename, $coverage);
         } catch (ParserException $e) {
             echo "Skipping class " . $filename . ", failed to parse\n";
         }
     }
     return $classes;
 }
开发者ID:julianseeger,项目名称:php-real-coverage,代码行数:12,代码来源:ParsingCoverageReader.php

示例9: process

 public function process(PHP_CodeCoverage $coverage, $target)
 {
     if (substr($target, -1, 1) != DIRECTORY_SEPARATOR) {
         $target .= DIRECTORY_SEPARATOR;
     }
     $this->target = $target;
     $this->initTargetDirectory($target);
     $report = $coverage->getReport();
     $this->project = new PHP_CodeCoverage_Report_XML_Project($coverage->getReport()->getName());
     $this->processTests($coverage->getTests());
     $this->processDirectory($report, $this->project);
     $index = $this->project->asDom();
     $index->formatOutput = true;
     $index->preserveWhiteSpace = false;
     $index->save($target . '/index.xml');
 }
开发者ID:illuminate3,项目名称:PMPortal,代码行数:16,代码来源:XML.php

示例10: 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

示例11: 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

示例12: suite

 public static function suite()
 {
     $srcDir = dirname(dirname(dirname(__DIR__))) . '/src/Pyrus/AtomicFileTransaction/Transaction';
     // Setup coverage filters
     $filter = PHP_CodeCoverage::getInstance()->filter();
     $filter->addDirectoryToWhitelist($srcDir);
     // Build and return test suite
     return new PHPUnit_Extensions_PhptTestSuite(__DIR__);
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:9,代码来源:AllTests.php

示例13: get_reports

 public function get_reports()
 {
     $this->reports = get_transient('json_testhelper_coverage');
     if (empty($this->reports)) {
         return new WP_Error('json_testhelper_no_report', __('No report data available', 'json_testhelper'), array('status' => 400));
     }
     if (!class_exists('PHP_CodeCoverage')) {
         return new WP_Error('json_testhelper_missing_codecoverage', __('The CodeCoverage classes are missing', 'json_testhelper'), array('status' => 500));
     }
     $master = new PHP_CodeCoverage();
     foreach ($this->reports as $report) {
         $master->merge($report);
     }
     // Clean up
     delete_transient('json_testhelper_coverage');
     $data = array('reports' => count($this->reports), 'data' => serialize($master));
     return $data;
 }
开发者ID:NicholasTaylorUK,项目名称:WP-API,代码行数:18,代码来源:helper.php

示例14: renderCodeCoverage

 /**
  * Renders and outputs the code coverage report.
  *
  * @return void
  */
 protected function renderCodeCoverage()
 {
     $this->coverage->stop();
     $codeCoverageDirectory = PATH_site . 'typo3temp/codecoverage/';
     if (!is_readable($codeCoverageDirectory) && !is_dir($codeCoverageDirectory)) {
         t3lib_div::mkdir($codeCoverageDirectory);
     }
     $coverageReport = new PHP_CodeCoverage_Report_HTML();
     $coverageReport->process($this->coverage, $codeCoverageDirectory);
     $this->outputService->output('<p><a target="_blank" href="../typo3temp/codecoverage/index.html">' . 'Click here to access the Code Coverage report</a></p>' . '<p>Memory peak usage: ' . t3lib_div::formatSize(memory_get_peak_usage()) . 'B<p/>');
 }
开发者ID:chrmue01,项目名称:typo3-starter-kit,代码行数:16,代码来源:Module.php

示例15: testSimpleMerge

 public function testSimpleMerge()
 {
     $firstFile = PARATEST_ROOT . '/src/ParaTest/Logging/LogInterpreter.php';
     $secondFile = PARATEST_ROOT . '/src/ParaTest/Logging/MetaProvider.php';
     $coverage1 = new \PHP_CodeCoverage();
     $coverage1->append(array($firstFile => array(35 => 1), $secondFile => array(34 => 1)), 'Test1');
     $coverage2 = new \PHP_CodeCoverage();
     $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]);
 }
开发者ID:bruno-arsene,项目名称:paratest,代码行数:21,代码来源:CoverageMergerTest.php


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