Fix: phpunit - Add adapter to "not existing directory" assertion (#28534)

# Fix: phpunit - Add adapter to "not existing directory" assertion

This is a helper function added to the common test class which is useful
to maintain cross phpunit version compatibility without triggering a
deprecation error for internal phpunit test functions.

Used in a testcase for dol_dir_move in a pending PR
This commit is contained in:
MDW
2024-03-01 12:50:51 +01:00
committed by GitHub
parent 449d31a424
commit 57f4fc14d8

View File

@@ -339,4 +339,24 @@ abstract class CommonClassTest extends TestCase
'workstation' => 'Workstation',
'zapier' => 'Zapier',
);
/**
* Assert that a directory does not exist without triggering deprecation
*
* @param string $directory The directory to test
* @param string $message The message to show if the directory exists
*
* @return void
*/
protected function assertDirectoryNotExistsCompat($directory, $message = '')
{
$phpunitVersion = \PHPUnit\Runner\Version::id();
// Check if PHPUnit version is less than 9.0.0
if (version_compare($phpunitVersion, '9.0.0', '<')) {
$this->assertDirectoryNotExists($directory, $message);
} else {
$this->assertDirectoryDoesNotExist($directory, $message);
}
}
}