<?php

declare(strict_types=1);

namespace Doctrine\Tests;

use PHPUnit\Framework\TestCase;

/**
 * Base testcase class for all Doctrine testcases.
 */
abstract class DoctrineTestCase extends TestCase
{
}

<?php

declare(strict_types=1);

namespace Doctrine\Tests;

use PHPUnit\Framework\TestCase;
use PHPUnit\Runner\Version;

/**
 * Base testcase class for all Doctrine testcases.
 */
abstract class DoctrineTestCase extends TestCase
{
    public static function assertDoesNotMatchRegularExpression(
        string $pattern,
        string $string,
        string $message = ''
    ): void {
        // Forward-compatibility wrapper for phpunit 9 : can be removed once phpunit 8 / php 7.2 support is dropped.
        if (self::isPhpunit9()) {
            parent::assertDoesNotMatchRegularExpression($pattern, $string, $message);
        } else {
            self::assertNotRegExp($pattern, $string, $message);
        }
    }

    public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void
    {
        // Forward-compatibility wrapper for phpunit 9 : can be removed once phpunit 8 / php 7.2 support is dropped.
        if (self::isPhpunit9()) {
            parent::assertMatchesRegularExpression($pattern, $string, $message);
        } else {
            self::assertRegExp($pattern, $string, $message);
        }
    }

    public static function assertFileDoesNotExist(string $filename, string $message = ''): void
    {
        // Forward-compatibility wrapper for phpunit 9 : can be removed once phpunit 8 / php 7.2 support is dropped.
        if (self::isPhpunit9()) {
            parent::assertFileDoesNotExist($filename, $message);
        } else {
            self::assertFileNotExists($filename, $message);
        }
    }

    /**
     * Check if we're running in phpunit >= 9.0
     */
    private static function isPhpunit9(): bool
    {
        return (int) Version::series() >= 9;
    }
}

Add a forward-compatibility wrapper for phpunit8 assertions
Add a forward-compatibility wrapper for phpunit8 assertions

While doctrine still supports php7.2 the test cases need to run
under phpunit8 as well. However some assertion methods produce
deprecation warnings in the test output with phpunit >= 9.

This commit adds a thin forward compatiblity wrapper for the
new assertion method names so that they can be used with both
supported phpunit versions.
