mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-13 19:25:22 +01:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user