It has the following additional requirements:
* [behave test framework](https://behave.readthedocs.io) >= 1.2.6
-* [phpunit](https://phpunit.de) >= 7.3
+* [phpunit](https://phpunit.de) (9.5 is known to work)
* [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
* [Pylint](https://pylint.org/) (2.6.0 is used for the CI)
* [pytest](https://pytest.org)
}
$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);
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)
getenv('UNIT_TEST_DSN') :
'pgsql:dbname=nominatim_unit_tests';
- $this->assertRegExp(
- '/unit_test/',
- $unit_test_dsn,
- 'Test database will get destroyed, thus should have a name like unit_test to be safe'
- );
-
## Create the database.
{
$aDSNParsed = \Nominatim\DB::parseDSN($unit_test_dsn);
public function testSqlObjectDump()
{
$oErr = new DatabaseError('Sql error', 123, null, array('one' => 'two'));
- $this->assertRegExp('/two/', $oErr->getSqlDebugDump());
+ $this->assertStringContainsString('two', $oErr->getSqlDebugDump());
}
}
require_once(CONST_LibDir.'/TokenList.php');
-class TokenTest extends \PHPUnit\Framework\TestCase
+class TokenListTest extends \PHPUnit\Framework\TestCase
{
protected function setUp(): void
{