mirror of
https://github.com/moodle/moodle.git
synced 2025-03-04 08:06:30 +01:00
MDL-72930 navigation: Changes to the secondary view unit tests.
The display of the arrays has been changed and so updates were necessary for the unit tests as well due to changing output.
This commit is contained in:
parent
060e5dedee
commit
f85662d744
@ -514,9 +514,7 @@ class secondary_test extends \advanced_testcase {
|
||||
$secondary = new secondary($PAGE);
|
||||
$secondary->add_node($this->generate_node_tree_construct($structure, 'primarynode'));
|
||||
$selectednode = $secondary->find($selected, null);
|
||||
$method = new ReflectionMethod('core\navigation\views\secondary', 'get_menu_array');
|
||||
$method->setAccessible(true);
|
||||
$response = $method->invoke($secondary, $selectednode);
|
||||
$response = \core\navigation\views\secondary::create_menu_element([$selectednode]);
|
||||
|
||||
$this->assertSame($expected, $response);
|
||||
}
|
||||
@ -544,7 +542,7 @@ class secondary_test extends \advanced_testcase {
|
||||
"Fetch information from a node with children" => [
|
||||
'child2',
|
||||
[
|
||||
'https://www.example.com/moodle/test.php' => 'child2',
|
||||
'https://www.example.com/moodle/test.php' => 'child2.3',
|
||||
'https://www.example.com/moodle/view/course.php?child=2' => 'child2.1',
|
||||
'https://www.example.com/moodle/view/admin.php?child=2' => 'child2.2'
|
||||
],
|
||||
@ -557,22 +555,18 @@ class secondary_test extends \advanced_testcase {
|
||||
'parentnode1',
|
||||
[
|
||||
[
|
||||
'parentnode1' => [
|
||||
'https://www.example.com/moodle/my' => 'child1'
|
||||
],
|
||||
'child2' => [
|
||||
'https://www.example.com/moodle/test.php' => 'child2',
|
||||
'https://www.example.com/moodle/view/course.php?child=2' => 'child2.1',
|
||||
'https://www.example.com/moodle/view/admin.php?child=2' => 'child2.2',
|
||||
]
|
||||
],
|
||||
[
|
||||
],
|
||||
'child3' => [
|
||||
'https://www.example.com/moodle/view/course.php?child=3' => 'child3.1',
|
||||
'https://www.example.com/moodle/view/admin.php?child=3' => 'child3.2'
|
||||
]
|
||||
],
|
||||
[
|
||||
'parentnode1' => [
|
||||
'https://www.example.com/moodle/my' => 'child1'
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
@ -657,78 +651,6 @@ class secondary_test extends \advanced_testcase {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for get_additional_child_nodes
|
||||
*
|
||||
* @param string $selectedkey
|
||||
* @param array $expected
|
||||
* @dataProvider test_get_additional_child_nodes_provider
|
||||
*/
|
||||
public function test_get_additional_child_nodes(string $selectedkey, array $expected) {
|
||||
global $PAGE;
|
||||
$structure = [
|
||||
'parentnode1' => [
|
||||
'child1' => '/my',
|
||||
'child2' => [
|
||||
'action' => '/test.php',
|
||||
'children' => [
|
||||
'child2.1' => '/view/course.php?child=2',
|
||||
'child2.2' => '/view/admin.php?child=2',
|
||||
]
|
||||
],
|
||||
'child3' => [
|
||||
'child3.1' => '/view/course.php?child=3',
|
||||
'child3.2' => '/view/admin.php?child=3',
|
||||
]
|
||||
],
|
||||
'parentnode2' => "/view/module.php"
|
||||
];
|
||||
|
||||
$secondary = new secondary($PAGE);
|
||||
$nodes = $this->generate_node_tree_construct($structure, 'primarynode');
|
||||
$selectednode = $nodes->find($selectedkey, null);
|
||||
$method = new ReflectionMethod('core\navigation\views\secondary', 'get_additional_child_nodes');
|
||||
$method->setAccessible(true);
|
||||
$response = $method->invoke($secondary, $selectednode);
|
||||
|
||||
$this->assertSame($expected, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provider for test_get_additional_child_nodes
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function test_get_additional_child_nodes_provider(): array {
|
||||
return [
|
||||
"Get nodes with deep nested children" => [
|
||||
"parentnode1",
|
||||
[
|
||||
'https://www.example.com/moodle/my' => 'child1',
|
||||
'https://www.example.com/moodle/test.php' => 'child2',
|
||||
'https://www.example.com/moodle/view/course.php?child=2' => 'child2.1',
|
||||
'https://www.example.com/moodle/view/admin.php?child=2' => 'child2.2',
|
||||
'https://www.example.com/moodle/view/course.php?child=3' => 'child3.1',
|
||||
'https://www.example.com/moodle/view/admin.php?child=3' => 'child3.2',
|
||||
]
|
||||
],
|
||||
"Get children from parent without action " => [
|
||||
"child3",
|
||||
[
|
||||
'https://www.example.com/moodle/view/course.php?child=3' => 'child3.1',
|
||||
'https://www.example.com/moodle/view/admin.php?child=3' => 'child3.2'
|
||||
]
|
||||
],
|
||||
"Get children from parent with action " => [
|
||||
"child2",
|
||||
[
|
||||
'https://www.example.com/moodle/view/course.php?child=2' => 'child2.1',
|
||||
'https://www.example.com/moodle/view/admin.php?child=2' => 'child2.2'
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the get_overflow_menu_data function
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user