MDL-83468 phpunit: Add back isInIsolation to testcase

This helper has been deprecated in PHPUnit, but we still need it in
Moodle.
This commit is contained in:
Andrew Nicols
2025-01-20 16:47:55 +01:00
committed by Sara Arjona
parent bc75ef8bbc
commit d6aabc8b2e
+15
View File
@@ -25,6 +25,7 @@
*/
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
use PHPUnit\Framework\TestCase;
/**
* Base class for PHPUnit test cases customised for Moodle
@@ -643,4 +644,18 @@ abstract class base_testcase extends PHPUnit\Framework\TestCase {
}
};
}
/**
* Determine whether the test is running in isolation.
*
* Note: This was previously a public method of the TestCase, but as removed in PHPUnit 10.
* There is no direct replacement, but we can use reflection to access the protected property.
* @return bool
*/
public function isInIsolation(): bool {
$rc = new \ReflectionClass(TestCase::class);
$rcp = $rc->getProperty('inIsolation');
return $rcp->getValue($this);
}
}