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 . ';');
|
$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();
|
BaseTestCase::setupTimezone();
|
||||||
|
|
|
@ -45,7 +45,7 @@ class PluginOutputTest extends BaseTestCase
|
||||||
$html,
|
$html,
|
||||||
preg_quote(self::SUFFIX, '~')
|
preg_quote(self::SUFFIX, '~')
|
||||||
);
|
);
|
||||||
$this->assertRegExp($expect, $actual, 'Output must match example regexp');
|
$this->assertMatchesRegularExpression($expect, $actual, 'Output must match example regexp');
|
||||||
} else {
|
} else {
|
||||||
$expect = $prefix . $html . self::SUFFIX;
|
$expect = $prefix . $html . self::SUFFIX;
|
||||||
$this->assertEquals($expect, $actual, 'Output must match example');
|
$this->assertEquals($expect, $actual, 'Output must match example');
|
||||||
|
|
|
@ -275,7 +275,7 @@ inkey' => 'blarg'
|
||||||
);
|
);
|
||||||
|
|
||||||
$rendered = $writer->render();
|
$rendered = $writer->render();
|
||||||
$this->assertRegExp(
|
$this->assertMatchesRegularExpression(
|
||||||
'~linebreak\\\\nin line~',
|
'~linebreak\\\\nin line~',
|
||||||
$rendered,
|
$rendered,
|
||||||
'newlines in values are not escaped'
|
'newlines in values are not escaped'
|
||||||
|
|
Loading…
Reference in New Issue