]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/steps/cgi-with-coverage.php
Merge pull request #2553 from lonvia/revert-street-matching-to-full-names
[nominatim.git] / test / bdd / steps / cgi-with-coverage.php
1 <?php
2 require_once 'SebastianBergmann/CodeCoverage/autoload.php';
3
4
5 function coverage_shutdown($oCoverage)
6 {
7     $oCoverage->stop();
8     $writer = new \SebastianBergmann\CodeCoverage\Report\PHP;
9     $writer->process($oCoverage, $_SERVER['PHP_CODE_COVERAGE_FILE']);
10 }
11
12 $covfilter = new SebastianBergmann\CodeCoverage\Filter();
13 if (method_exists($covfilter, 'addDirectoryToWhitelist')) {
14     // pre PHPUnit 9
15     $covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/lib-php');
16     $covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/website');
17     $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(null, $covfilter);
18 } else {
19     // since PHP Uit 9
20     $covfilter->includeDirectory($_SERVER['COV_PHP_DIR'].'/lib-php');
21     $covfilter->includeDirectory($_SERVER['COV_PHP_DIR'].'/website');
22     $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(
23         (new SebastianBergmann\CodeCoverage\Driver\Selector)->forLineCoverage($covfilter),
24         $covfilter
25     );
26 }
27
28 $coverage->start($_SERVER['COV_TEST_NAME']);
29
30 register_shutdown_function('coverage_shutdown', $coverage);
31
32 include $_SERVER['COV_SCRIPT_FILENAME'];