]> git.openstreetmap.org Git - nominatim.git/blobdiff - test/bdd/steps/cgi-with-coverage.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / test / bdd / steps / cgi-with-coverage.php
index 47d3cc9ac6760c248cda6a0f56a33f726b302a90..15e050072935f79222030f23f13c03af7d58d46f 100644 (file)
@@ -10,8 +10,21 @@ function coverage_shutdown($oCoverage)
 }
 
 $covfilter = new SebastianBergmann\CodeCoverage\Filter();
 }
 
 $covfilter = new SebastianBergmann\CodeCoverage\Filter();
-$covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR']);
-$coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(null, $covfilter);
+if (method_exists($covfilter, 'addDirectoryToWhitelist')) {
+    // pre PHPUnit 9
+    $covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/lib-php');
+    $covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/website');
+    $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(null, $covfilter);
+} else {
+    // since PHP Uit 9
+    $covfilter->includeDirectory($_SERVER['COV_PHP_DIR'].'/lib-php');
+    $covfilter->includeDirectory($_SERVER['COV_PHP_DIR'].'/website');
+    $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(
+        (new SebastianBergmann\CodeCoverage\Driver\Selector)->forLineCoverage($covfilter),
+        $covfilter
+    );
+}
+
 $coverage->start($_SERVER['COV_TEST_NAME']);
 
 register_shutdown_function('coverage_shutdown', $coverage);
 $coverage->start($_SERVER['COV_TEST_NAME']);
 
 register_shutdown_function('coverage_shutdown', $coverage);