Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-74056

Improve and clarify unit testing of boostnavbar

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.0
    • Navigation
    • MOODLE_400_STABLE

      Spotted in MDL-73645, the test 'theme/boost/tests/boostnavbar_test.php' currently tests the internals of the class and no public methods, which isn't considered best practice.

      In addition to the above, it makes assertions about the protected method 'remove_items_that_exist_in_navigation' which are at odds with how the class behaves at a public level. A scenario verifies that nodes duplicated in the primary navigation are removed when calling remove_items_that_exist_in_navigation() with an instance of core\navigation\views\primary. However, boostnavbar never calls the protected method with an instance of primary (it always passes secondary) and so the real usage of the class won't remove nodes present in the primary nav.

      The navigation code appears to rely on some uses of magic getters and global $PAGE, but I think we should still be able to improve on what we've got here simply by testing the behavior of the objects, rather than testing specific internals. boostnavbar->get_items() seems like a good candidate to start with.

            Unassigned Unassigned
            jaked Jake Dallimore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.