]> git.openstreetmap.org Git - nominatim.git/commitdiff
enable PHPUnit 9 for coverage
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 7 Dec 2021 11:07:17 +0000 (12:07 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 7 Dec 2021 11:07:17 +0000 (12:07 +0100)
A couple of functions have been renamed.

test/bdd/steps/cgi-with-coverage.php
test/bdd/steps/steps_api_queries.py

index 6f0d79bb2202bde84de2a1b9e9db79c98a5006c2..15e050072935f79222030f23f13c03af7d58d46f 100644 (file)
@@ -10,9 +10,21 @@ function coverage_shutdown($oCoverage)
 }
 
 $covfilter = new SebastianBergmann\CodeCoverage\Filter();
-$covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/lib-php');
-$covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR'].'/website');
-$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);
index fc0a2156b5cd5e8dbc96de1e574879265c7d23ef..994695870a644c85cbc4a3d30bf4eddff2efd58e 100644 (file)
@@ -82,6 +82,7 @@ def send_api_query(endpoint, params, fmt, context):
 
     cmd = ['/usr/bin/env', 'php-cgi', '-f']
     if context.nominatim.code_coverage_path:
+        env['XDEBUG_MODE'] = 'coverage'
         env['COV_SCRIPT_FILENAME'] = env['SCRIPT_FILENAME']
         env['COV_PHP_DIR'] = context.nominatim.src_dir
         env['COV_TEST_NAME'] = '%s:%s' % (context.scenario.filename, context.scenario.line)