當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。