MDL-66903 core: Introduce \core_component::reset to replace hacks
Traditionally we have done this using reflection and it would be better to do this in a 'proper' fashion in case we ever need to change how it works.
This commit is contained in:
@@ -38,8 +38,7 @@ final class component_test extends advanced_testcase {
|
||||
public function tearDown(): void {
|
||||
parent::tearDown();
|
||||
|
||||
$plugintypes = new ReflectionProperty(\core_component::class, 'plugintypes');
|
||||
$plugintypes->setValue(null, null);
|
||||
\core_component::reset();
|
||||
}
|
||||
|
||||
public function test_get_core_subsystems(): void {
|
||||
@@ -959,7 +958,7 @@ final class component_test extends advanced_testcase {
|
||||
// We have to override the dirroot and libdir, and then reset the plugintypes property.
|
||||
$CFG->dirroot = $vfileroot->url();
|
||||
$CFG->libdir = $vfileroot->url() . '/lib';
|
||||
(new ReflectionProperty('core_component', 'plugintypes'))->setValue(null, null);
|
||||
\core_component::reset();
|
||||
|
||||
// Existing classes do not break.
|
||||
$this->assertTrue(
|
||||
|
||||
Reference in New Issue
Block a user