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

PHP unit Integration tests for create_file with file_storage are not possible

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.5 regressions, 4.5, 4.5.1, 4.5.2, 4.5.3, 4.5.4
    • Files API
    • None
    • MOODLE_405_STABLE

      It has been impossible to write php unit integration tests with code that calls file_stoarge.php 
      create_file directly or indirectly since this commit:
      72b43c3541e3ce2ff7e88d59490396a5b4bbcb79

      I maintain a plugin (tool_ally). We have php unit tests to ensure a custom hook is called when creating files for different module types. This now fails because the create_file function aborts early if phpunit is running.

      ```
      if (defined('PHPUNIT_TEST') && PHPUNIT_TEST)

      {     return; }

      ```

      There are two possible fixes I would like to propose:

      1) Allow for create_file to be called in a way that the phpunit skip code condition is bypassed

       

      2) Modify file_storage to being a moodle class where it works with dependency injection so that an alternative file_storage class can be used.

       

      I'm happy to make this change and file a PR but would like to know which is the preferred fix.

            Unassigned Unassigned
            brudinie guy thomas
            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.