MDL-86637 core: Use ReflectionProperty to access static navigation data
In PHP 7.4.0, ReflectionClass and static properties don't play nicely together. Using ReflectionProperty side steps the issue.
This commit is contained in:
@@ -150,9 +150,10 @@ STRING;
|
||||
*/
|
||||
public function test_set_navigation_url(): void {
|
||||
\navigation_node::override_active_url(new \moodle_url('/foo/bar/baz'));
|
||||
$this->assertNotNull(
|
||||
(new \ReflectionClass(\navigation_node::class))->getStaticPropertyValue('fullmeurl', null)
|
||||
);
|
||||
$property = new \ReflectionProperty(\navigation_node::class, 'fullmeurl');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$this->assertNotNull($property->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,9 +162,10 @@ STRING;
|
||||
* @depends test_set_navigation_url
|
||||
*/
|
||||
public function test_navigation_url_reset(): void {
|
||||
$this->assertNull(
|
||||
(new \ReflectionClass(\navigation_node::class))->getStaticPropertyValue('fullmeurl', null)
|
||||
);
|
||||
$property = new \ReflectionProperty(\navigation_node::class, 'fullmeurl');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$this->assertNull($property->getValue());
|
||||
}
|
||||
|
||||
// Uncomment following tests to see logging of unexpected changes in global state and database.
|
||||
|
||||
Reference in New Issue
Block a user