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

tool_uploadcsv/cli_test fails if other plugin creates checkbox profile field with default 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.1.5, 4.2.2
    • 4.0.8, 4.1.3, 4.2
    • Unit tests

      The unit tests in \tool_uploaduser\cli_test fail if a plugin has created a custom checkbox profile field with default 0. (This is slightly similar to MDL-77611 but a completely different issue.)

      This appears to be caused by \profile_field_base::edit_field_set_default() which incorrectly checks if default data is available by using empty(), which misses defaults of 0 and the empty string.

      To reproduce, unzip the attached file local_fortest.zip into the local directory of Moodle, initialise phpunit and run tool_uploaduser_testsuite. (I hope timhunt doesn't mind me nicking his code from MDL-77611 )

      The tests will fail with errors like this:

      moodle_exception : error/CLI script finished with error code 1
      $a contents:
      /var/www/html/admin/tool/uploaduser/classes/cli_helper.php:199
      /var/www/html/admin/tool/uploaduser/classes/cli_helper.php:186
      /var/www/html/admin/tool/uploaduser/classes/cli_helper.php:386
      /var/www/html/admin/tool/uploaduser/classes/cli_helper.php:266
      /var/www/html/admin/tool/uploaduser/tests/cli_test.php:65
      /var/www/html/lib/phpunit/classes/advanced_testcase.php:80

            maherne Michael Aherne
            maherne Michael Aherne
            Simey Lameze Simey Lameze
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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