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

cli/util.php doesn't work in some configurations, preventing unit tests from running

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.7.5
    • Fix Version/s: None
    • Component/s: Unit tests
    • Labels:
      None
    • Affected Branches:
      MOODLE_37_STABLE

      Description

      I'm using MacOS and the MAMP install of Moodle. If I try to set up Moodle to run unit tests, using `cli/util.php`, it fails. There are two reasons for this:

       

      1. This line must be added to `config.php`: `'dbsocket' => '/Applications/MAMP/tmp/mysql/mysql.sock'`.
      2. I have multiple php installs (at minimum, one from MAMP and one from brew). Since `cli/init.php` runs the `php` executable, it inevitably chooses the wrong one and fails.

      Solution:

      The first problem can be solved by adding a note to the documentation on how to find the `mysql.sock` and how to edit the config file.

      The second can be solved (I believe), by using the `PHP_BINARY` constant defined by PHP 5.4+, instead of executing `php` and letting the system decide which version to run. See https://stackoverflow.com/questions/2372624/get-current-php-executable-from-within-script for details, potential problems with this approach on Windows, and a possible solution to that problem.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            credly1 Credly
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: