• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP xdebug_get_code_coverage函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_code_coverage

 /**
  * Get code coverage with Xdebug
  * @link http://www.xdebug.org/docs/code_coverage
  *
  * @return array filename as key and codes as array values
  */
 public static function get_code_coverage()
 {
     if (!function_exists('xdebug_get_code_coverage')) {
         return array('xdebug is not installed, no code coverage');
     }
     $coverage = xdebug_get_code_coverage();
     foreach ($coverage as $file => $line) {
         if (!file_exists($file)) {
             continue;
         }
         /**
         			$file_contents = file($file);
         			$code = '';
         			foreach ($line as $lineNumber => $int1)
         			{
         				if (isset($file_contents[$lineNumber-1]))
         				{
         					$code.= sprintf('%4d: ',$lineNumber);
         					$code.= $file_contents[$lineNumber-1];
         				}
         			}
         			$coverage[$file] = highlight_string($code, true);
         			/**/
         $key = preg_replace('/\\/vagrant\\//', '', $file);
         unset($coverage[$file]);
         $coverage[$key] = $file;
     }
     if (array_key_exists('cc_sort', $_GET)) {
         ksort($coverage);
     }
     return $coverage;
 }
开发者ID:sdgdsffdsfff,项目名称:tracer-1,代码行数:38,代码来源:tracer.php


示例2: debug_get_coverage

function debug_get_coverage($oldCoverage = array())
{
    $array = xdebug_get_code_coverage();
    $ret = $oldCoverage;
    if (!is_array($array)) {
        return $ret;
    }
    foreach ($array as $file => $views) {
        if (substr(basename($file), 0, -8) == SH_DEBUG_COVERAGE_CLASS) {
            $fileContents = file($file);
            foreach ($fileContents as $num => $lineContent) {
                $lineContent = trim($lineContent);
                if (isset($views[$num]) || $lineContent == '<?php') {
                    $previousLine = LINE_USED;
                    $ret[$file]['l_' . ($num + 1)] += LINE_USED;
                    // Used line
                } elseif ($lineContent == '' || $lineContent == '}') {
                    if ($previousLine) {
                        $ret[$file]['l_' . ($num + 1)] = $previousLine;
                    }
                } else {
                    $previousLine = LINE_UNUSED;
                }
            }
        }
    }
    return $ret;
}
开发者ID:briceparent,项目名称:Shopsailors,代码行数:28,代码来源:debug_functions.php


示例3: WebLauncher

 /**
  * Launches a test module for web inspection of results
  * @param string $module
  * @return boolean
  */
 function WebLauncher($module)
 {
     jf::$ErrorHandler->UnsetErrorHandler();
     $this->LoadFramework();
     self::$TestSuite = new \PHPUnit_Framework_TestSuite();
     self::$TestFiles[] = $this->ModuleFile($module);
     self::$TestSuite->addTestFile(self::$TestFiles[0]);
     $result = new \PHPUnit_Framework_TestResult();
     $listener = new TestListener();
     $result->addListener($listener);
     $Profiler = new Profiler();
     if (function_exists("xdebug_start_code_coverage")) {
         xdebug_start_code_coverage();
     }
     self::$TestSuite->run($result);
     if (function_exists("xdebug_start_code_coverage")) {
         $Coverage = xdebug_get_code_coverage();
     } else {
         $Coverage = null;
     }
     $Profiler->Stop();
     $listener->Finish();
     $this->OutputResult($result, $Profiler, $Coverage);
     return true;
 }
开发者ID:michalkoczwara,项目名称:WebGoatPHP,代码行数:30,代码来源:test.php


示例4: stop

 /**
  * Stop collection of code coverage information.
  *
  * @return array
  */
 public function stop()
 {
     // @codeCoverageIgnoreStart
     $codeCoverage = xdebug_get_code_coverage();
     xdebug_stop_code_coverage();
     return $codeCoverage;
     // @codeCoverageIgnoreEnd
 }
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:13,代码来源:Xdebug.php


示例5: onShutdown

 static function onShutdown()
 {
     if (self::$tests_report_path) {
         file_put_contents(self::$tests_report_path, json_encode(array('file_name' => self::$tested_file_name, 'assertions' => self::$assertions_count, 'errors' => self::$errors_count, 'error_message' => self::$error_message, 'time' => microtime(true) - self::$start_time)) . PHP_EOL, FILE_APPEND);
     }
     if (self::$coverage_file_path) {
         file_put_contents(self::$coverage_file_path, json_encode(xdebug_get_code_coverage()) . PHP_EOL, FILE_APPEND);
     }
 }
开发者ID:dracoblue,项目名称:naith,代码行数:9,代码来源:NaithCliRunner.class.php


示例6: paintGroupEnd

 /**
  * Paints the end of a group test. Will paint the page
  * footer if the stack of tests has unwound.
  * @param string $test_name   Name of test that is ending.
  * @param integer $progress   Number of test cases ending.
  */
 function paintGroupEnd($test_name)
 {
     if (extension_loaded('xdebug')) {
         $this->code_coverage = xdebug_get_code_coverage();
         xdebug_stop_code_coverage();
         ksort($this->code_coverage);
     }
     HtmlReporter::paintGroupEnd($test_name);
 }
开发者ID:clickdimension,项目名称:tinybutstrong,代码行数:15,代码来源:HtmlCodeCoverageReporter.php


示例7: save_coverage_data

function save_coverage_data($test_id)
{
    $data = xdebug_get_code_coverage();
    xdebug_stop_code_coverage();
    if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
        mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'], 0777, true);
    }
    $file = $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] . '/' . $test_id . '.' . md5(uniqid(rand(), true));
    echo "Saving coverage data to {$file}...\n";
    file_put_contents($file, serialize($data));
}
开发者ID:shabesoglu,项目名称:pcbsd,代码行数:11,代码来源:echoserver.php


示例8: kataCodeCoverage

 /**
  * shutdown function to generate coverage 
  */
 function kataCodeCoverage()
 {
     $data = xdebug_get_code_coverage(XDEBUG_CC_DEAD_CODE | XDEBUG_CC_UNUSED);
     ksort($data);
     foreach ($data as $name => &$lines) {
         if (substr($name, 0, strlen(ROOT)) != ROOT) {
             continue;
         }
         $temp = explode(DS, $name);
         if (in_array('lib', $temp)) {
             continue;
         }
         $shortFile = array_pop($temp);
         $shortDir = array_pop($temp);
         $shortName = $shortDir . DS . $shortFile;
         if ($shortDir == 'config' || $shortName == 'webroot' . DS . 'index.php') {
             continue;
         }
         echo '<br /><h2>' . $shortName . '</h2>';
         if ($shortDir == 'lang') {
             echo 'skipping... ' . $shortDir . ' <br />';
             continue;
         }
         $file = file($name);
         $tdCell = '<td style="border:1px solid red;padding:2px;">';
         echo '<table style="min-width:100%;border:1px solid red;color:black;background-color:#e8e8e8;border-collapse:collapse;">';
         foreach ($file as $lineno => $line) {
             $count = 0;
             if (isset($lines[$lineno + 1])) {
                 $count = $lines[$lineno + 1];
             }
             if ($count > 2) {
                 $count = 3;
             }
             echo '<tr>' . $tdCell . $lineno . '</td>' . $tdCell . '<tt';
             switch ($count) {
                 case 0:
                     echo ' style="color:#c0c0c0;"';
                     break;
                 case 1:
                     echo '';
                     break;
                 case 2:
                 case 3:
                     echo ' style="color:#ffe0e0;"';
                     break;
             }
             echo '>' . h($line) . '</tt></td></tr>';
         }
         echo '</table>';
     }
     unset($lines);
     echo '</table>';
 }
开发者ID:emente,项目名称:kataii---kata-framework-2.x,代码行数:57,代码来源:coverage.php


示例9: stopCodeCoverage

 public function stopCodeCoverage()
 {
     //echo "stopCodeCoverage called...\n";
     if (extension_loaded('xdebug')) {
         $data = xdebug_get_code_coverage();
         xdebug_stop_code_coverage();
         //echo "xdebug_stop_code_coverage called...\n";
         global $CDASH_COVERAGE_DIR;
         $file = $CDASH_COVERAGE_DIR . DIRECTORY_SEPARATOR . md5($_SERVER['SCRIPT_FILENAME']);
         file_put_contents($file . '.' . md5(uniqid(rand(), true)) . '.' . get_class(), serialize($data));
     }
 }
开发者ID:kitware,项目名称:cdash,代码行数:12,代码来源:kw_web_tester.php


示例10: save_coverage

 function save_coverage()
 {
     $coverage_filename = sys_get_temp_dir() . "/adminer_coverage.ser";
     $coverage = unserialize(file_get_contents($coverage_filename));
     foreach (xdebug_get_code_coverage() as $filename => $lines) {
         foreach ($lines as $l => $val) {
             if (!$coverage[$filename][$l] || $val > 0) {
                 $coverage[$filename][$l] = $val;
             }
         }
         file_put_contents($coverage_filename, serialize($coverage));
     }
 }
开发者ID:ly95,项目名称:adminer,代码行数:13,代码来源:coverage.inc.php


示例11: stop

 /**
  * Stops code coverage.
  *
  * @return array The collected coverage
  */
 public function stop()
 {
     $data = xdebug_get_code_coverage();
     xdebug_stop_code_coverage($this->_config['cleanup']);
     $result = [];
     foreach ($data as $file => $coverage) {
         foreach ($coverage as $line => $value) {
             if ($line && $value !== -2) {
                 $result[$file][$line - 1] = $value === -1 ? 0 : $value;
             }
         }
     }
     return $result;
 }
开发者ID:crysalead,项目名称:kahlan,代码行数:19,代码来源:Xdebug.php


示例12: stopCoverage

 public function stopCoverage()
 {
     $cov = xdebug_get_code_coverage();
     $this->filter($cov);
     $data = new CoverageDataHandler($this->log);
     chdir($this->root);
     $data->write($cov);
     unset($data);
     // release sqlite connection
     xdebug_stop_code_coverage();
     // make sure we wind up on same current working directory, otherwise
     // coverage handler writer doesn't know what directory to chop off
     chdir($this->root);
 }
开发者ID:guicara,项目名称:simpletest,代码行数:14,代码来源:coverage.php


示例13: stop

 /**
  * Stop collection of code coverage information and store it in Sqlite3.
  *
  * @return array
  */
 public function stop()
 {
     $cov = xdebug_get_code_coverage();
     xdebug_stop_code_coverage();
     if (!isset($this->root)) {
         $this->root = getcwd();
     }
     $dataHandler = new DataHandler(self::SQLITE_DB);
     chdir($this->root);
     $dataHandler->write($cov);
     $cleanData = $this->cleanup($dataHandler->read());
     unset($dataHandler);
     // release sqlite connection
     return $cleanData;
 }
开发者ID:legovaer,项目名称:phpcov-runner,代码行数:20,代码来源:XdebugSQLite3.php


示例14: save

 public function save()
 {
     $data = xdebug_get_code_coverage();
     $files = $this->src->getData();
     foreach ($data as $fileName => $lines) {
         if (!$this->isFileInDir($fileName)) {
             continue;
         }
         $file = $files->find($fileName);
         foreach ($lines as $lineNo => $isUsed) {
             $file->addUsedLine($lineNo - 1);
         }
     }
     $this->src->saveData($files);
 }
开发者ID:olegkolt,项目名称:phphd,代码行数:15,代码来源:Collect.php


示例15: apply

 /**
  * Takes an instance of an object (usually a Collection object) containing test
  * instances. Attaches code coverage filtering to test cases.
  *
  * @see lithium\test\filter\Coverage::collect()
  * @param object $report Instance of Report which is calling apply.
  * @param array $tests The test to apply this filter on
  * @param array $options Options for how code coverage should be applied. These options are
  *              also passed to `Coverage::collect()` to determine how to aggregate results. See
  *              the documentation for `collect()` for further options.  Options affecting this
  *              method are:
  *              -'method': The name of method to attach to, defaults to 'run'.
  * @return object|void Returns the instance of `$tests` with code coverage analysis
  *                     triggers applied.
  */
 public static function apply($report, $tests, array $options = array())
 {
     $defaults = array('method' => 'run');
     $options += $defaults;
     $m = $options['method'];
     $filter = function ($self, $params, $chain) use($report, $options) {
         xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
         $chain->next($self, $params, $chain);
         $results = xdebug_get_code_coverage();
         xdebug_stop_code_coverage();
         $report->collect(__CLASS__, array($self->subject() => $results));
     };
     $tests->invoke('applyFilter', array($m, $filter));
     return $tests;
 }
开发者ID:EHER,项目名称:chegamos,代码行数:30,代码来源:Coverage.php


示例16: shutdown

function shutdown()
{
    $File = "/watt/coverage.txt";
    $fh = fopen($File, 'a') or die("Error: cant open file");
    //$oldcov = unserialize(file_get_contents($File));
    $cov = xdebug_get_code_coverage();
    $appname = $_GET['wattappname'];
    $traceid = $_GET['watttraceid'];
    $requestid = $_GET['wattrequestid'];
    $linktype = $_GET['wattlinktype'];
    foreach ($cov as $fname => $fcov) {
        foreach ($fcov as $fline => $value) {
            $line = $appname . "," . $traceid . "," . $requestid . "," . $fname . "," . $fline . ",\n";
            fputs($fh, $line) or die("error writing");
        }
    }
}
开发者ID:nanliu0408,项目名称:fittest,代码行数:17,代码来源:pre.php


示例17: collectXdebug

 /**
  * Collects information about code coverage.
  * @return array
  */
 private static function collectXdebug()
 {
     $positive = $negative = array();
     foreach (xdebug_get_code_coverage() as $file => $lines) {
         if (!file_exists($file)) {
             continue;
         }
         foreach ($lines as $num => $val) {
             if ($val > 0) {
                 $positive[$file][$num] = $val;
             } else {
                 $negative[$file][$num] = $val;
             }
         }
     }
     return array($positive, $negative);
 }
开发者ID:knedle,项目名称:twitter-nette-skeleton,代码行数:21,代码来源:Collector.php


示例18: apply

 /**
  * Takes an instance of an object (usually a Collection object) containing test
  * instances. Attaches code coverage filtering to test cases.
  *
  * @see lithium\test\filter\Coverage::collect()
  * @param object $report Instance of Report which is calling apply.
  * @param array $tests The test to apply this filter on
  * @param array $options Options for how code coverage should be applied. These options are
  *              also passed to `Coverage::collect()` to determine how to aggregate results. See
  *              the documentation for `collect()` for further options.  Options affecting this
  *              method are:
  *              -'method': The name of method to attach to, defaults to 'run'.
  * @return object Returns the instance of `$tests` with code coverage analysis
  *                     triggers applied.
  */
 public static function apply($report, $tests, array $options = array())
 {
     $defaults = array('method' => 'run');
     $options += $defaults;
     if (!function_exists('xdebug_start_code_coverage')) {
         $msg = "Xdebug not installed. Please install Xdebug before running code coverage.";
         throw new RuntimeException($msg);
     }
     $filter = function ($self, $params, $chain) use($report, $options) {
         xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
         $chain->next($self, $params, $chain);
         $results = xdebug_get_code_coverage();
         xdebug_stop_code_coverage();
         $report->collect(__CLASS__, array($self->subject() => $results));
     };
     $tests->invoke('applyFilter', array($options['method'], $filter));
     return $tests;
 }
开发者ID:newmight2015,项目名称:Blockchain-2,代码行数:33,代码来源:Coverage.php


示例19: save

 /**
  * Saves information about code coverage. Do not call directly.
  * @return void
  * @internal
  */
 public static function save()
 {
     $f = fopen(self::$file, 'a+');
     flock($f, LOCK_EX);
     fseek($f, 0);
     $coverage = @unserialize(stream_get_contents($f));
     foreach (xdebug_get_code_coverage() as $filename => $lines) {
         foreach ($lines as $num => $val) {
             if (empty($coverage[$filename][$num]) || $val > 0) {
                 $coverage[$filename][$num] = $val;
                 // -1 => untested; -2 => dead code
             }
         }
     }
     ftruncate($f, 0);
     fwrite($f, serialize($coverage));
     fclose($f);
 }
开发者ID:jakuborava,项目名称:walletapp,代码行数:23,代码来源:Collector.php


示例20: paintFooter

 function paintFooter($test_name)
 {
     if (extension_loaded('xdebug')) {
         $this->coverage = xdebug_get_code_coverage();
         xdebug_stop_code_coverage();
     }
     $colour = $this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green";
     print "<div style=\"";
     print "padding: 8px; margin-top: 1em; background-color: {$colour}; color: white;";
     print "\">";
     print $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
     print " test cases complete:\n";
     print "<strong>" . $this->getPassCount() . "</strong> passes, ";
     print "<strong>" . $this->getFailCount() . "</strong> fails and ";
     print "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
     print "</div>\n";
     $this->paintCoverage();
     print "</body>\n</html>\n";
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:19,代码来源:HtmlReporterWithCoverage.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP xdebug_get_function_stack函数代码示例发布时间:2022-05-23
下一篇:
PHP xdebug_enable函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap