tests: Don't use deprecated assertion `assertRegExp()`
This commit is contained in:
parent
f27e872d90
commit
e671324ddb
|
@ -333,6 +333,23 @@ namespace Icinga\Test {
|
|||
$adapter->exec('DROP TABLE ' . $table . ';');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add assertMatchesRegularExpression() method for phpunit >= 8.0 < 9.0 for compatibility with PHP 7.2.
|
||||
*
|
||||
* @TODO Remove once PHP 7.2 support is not needed for testing anymore.
|
||||
*/
|
||||
public static function assertMatchesRegularExpression(
|
||||
string $pattern,
|
||||
string $string,
|
||||
string $message = ''
|
||||
): void {
|
||||
if (method_exists(parent::class, 'assertMatchesRegularExpression')) {
|
||||
parent::assertMatchesRegularExpression($pattern, $string, $message);
|
||||
} else {
|
||||
static::assertRegExp($pattern, $string, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BaseTestCase::setupTimezone();
|
||||
|
|
|
@ -45,7 +45,7 @@ class PluginOutputTest extends BaseTestCase
|
|||
$html,
|
||||
preg_quote(self::SUFFIX, '~')
|
||||
);
|
||||
$this->assertRegExp($expect, $actual, 'Output must match example regexp');
|
||||
$this->assertMatchesRegularExpression($expect, $actual, 'Output must match example regexp');
|
||||
} else {
|
||||
$expect = $prefix . $html . self::SUFFIX;
|
||||
$this->assertEquals($expect, $actual, 'Output must match example');
|
||||
|
|
|
@ -275,7 +275,7 @@ inkey' => 'blarg'
|
|||
);
|
||||
|
||||
$rendered = $writer->render();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'~linebreak\\\\nin line~',
|
||||
$rendered,
|
||||
'newlines in values are not escaped'
|
||||
|
|
Loading…
Reference in New Issue