3 declare(strict_types
=1);
8 * Helper class extending \PHPUnit\Framework\TestCase.
9 * Used to make Shaarli UT run on multiple versions of PHPUnit.
11 class TestCase
extends \PHPUnit\Framework\TestCase
14 * expectExceptionMessageRegExp has been removed and replaced by expectExceptionMessageMatches in PHPUnit 9.
16 public function expectExceptionMessageRegExp(string $regularExpression): void
18 if (method_exists($this, 'expectExceptionMessageMatches')) {
19 $this->expectExceptionMessageMatches($regularExpression);
21 parent
::expectExceptionMessageRegExp($regularExpression);
26 * assertContains is now used for iterable, strings should use assertStringContainsString
28 public function assertContainsPolyfill($expected, $actual, string $message = ''): void
30 if (is_string($actual) && method_exists($this, 'assertStringContainsString')) {
31 static::assertStringContainsString($expected, $actual, $message);
33 static::assertContains($expected, $actual, $message);
38 * assertNotContains is now used for iterable, strings should use assertStringNotContainsString
40 public function assertNotContainsPolyfill($expected, $actual, string $message = ''): void
42 if (is_string($actual) && method_exists($this, 'assertStringNotContainsString')) {
43 static::assertStringNotContainsString($expected, $actual, $message);
45 static::assertNotContains($expected, $actual, $message);
50 * assertFileNotExists has been renamed in assertFileDoesNotExist
52 public static function assertFileNotExists(string $filename, string $message = ''): void
54 if (method_exists(TestCase
::class, 'assertFileDoesNotExist')) {
55 static::assertFileDoesNotExist($filename, $message);
57 parent
::assertFileNotExists($filename, $message);
62 * assertRegExp has been renamed in assertMatchesRegularExpression
64 public static function assertRegExp(string $pattern, string $string, string $message = ''): void
66 if (method_exists(TestCase
::class, 'assertMatchesRegularExpression')) {
67 static::assertMatchesRegularExpression($pattern, $string, $message);
69 parent
::assertRegExp($pattern, $string, $message);
73 public function isInTestsContext(): bool