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

Unit test test_get_file_icons adjustment for custom icons compatibility

XMLWordPrintable

    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MOODLE_403_STABLE
    • MDL-80526-MOODLE_403_STABLE
    • MDL-80526-master
    • Show
      Amend the count on https://github.com/moodle/moodle/blob/main/admin/tool/filetypes/tests/tool_filetypes_test.php#L91
    • Hide

      Testing scenario 1. With added custom icon (expected succes)

      1. Add a custom icon to /pix/f/. For example make a copy of unknown.svg in the `/pix/f` folder and rename to mycustomicon.svg.
      2. Initialise the unit tests. Execute:

        php admin/tool/phpunit/cli/init.php

      3. Execute the testsuite for tool_filetypes. Run:

        vendor/bin/phpunit --testsuite tool_filetypes_testsuite

      4. Observe no failing unit test.
         

      Testing scenario 2. With missing required icon (expected failure)

      1. Rename a required icon, for example, rename /pix/f/unknown.svg. to /pix/f/test.svg
      2. Execute the testsuite for tool_filetypes again. Run:

        vendor/bin/phpunit --testsuite tool_filetypes_testsuite

      3. Observe failing unit test.
      4. Rename the svg file back to what it was /pix/f/unknown.svg and run the unit test again.
      5. Ensure it passes.
      Show
      Testing scenario 1. With added custom icon (expected succes) Add a custom icon to /pix/f/ . For example make a copy of unknown.svg in the `/pix/f` folder and rename to mycustomicon.svg. Initialise the unit tests. Execute: php admin/tool/phpunit/cli/init.php Execute the testsuite for tool_filetypes. Run: vendor/bin/phpunit --testsuite tool_filetypes_testsuite Observe no failing unit test.   Testing scenario 2. With missing required icon (expected failure) Rename a required icon, for example, rename /pix/f/unknown.svg . to /pix/f/test.svg Execute the testsuite for tool_filetypes again. Run: vendor/bin/phpunit --testsuite tool_filetypes_testsuite Observe failing unit test. Rename the svg file back to what it was /pix/f/unknown.svg and run the unit test again. Ensure it passes.

      This addresses a unit test failure related to custom icons in Moodle. The current "test_get_file_icons" unit test, on tool_filetypes, causes issues on sites with custom icons due to a mismatch in expected counts. Developers can add custom icons to the path `/pix/f/`, for example, `/pix/f/mycustomicon.svg`.

      The proposed change adjusts the validation approach. The test now checks for the required icons, without needing to specify a count. Allowing developers to add custom icons to the folder without needing to alter any unit test.

      Steps to reproduce

      1. Add a custom icon to `/pix/f/`. For example make a copy of unknown.svg in the `/pix/f` folder and rename to mycustomicon.svg.
      2. Initialise the unit tests. Execute `php admin/tool/phpunit/cli/init.php`
      3. Execute the testsuite for tool_filetypes. `Run vendor/bin/phpunit --testsuite tool_filetypes_testsuite`
      4. Observe the failing unit test.

       

            scottverbeek Scott Verbeek
            scottverbeek Scott Verbeek
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Simey Lameze Simey Lameze
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 56 minutes
                1h 56m

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