Skip to content

Moosh makes Moodle behat init fail #288

@mwithheld

Description

@mwithheld
  • moosh version: latest
  • moodle version: 3.8
    • database: any
  • php version:any
  • operating system:linux

Steps to reproduce

Actual behaviour

  • Install a clean Moodle
  • Install Moosh from moodle.org/plugins
curl https://moodle.org/plugins/download.php/20823/moosh_moodle.zip --output moosh.zip; unzip -o -q moosh.zip; rm -f moosh.zip;
cd moosh; php ../composer.phar install; ln -f -s $PWD/moosh.php /usr/local/bin/moosh; cd ..;
  • Run the command-line Behat init: admin/tool/behat/cli/init.php

  • It fails with these errors:

PHP Warning:  require_once(/var/www/html/moosh/tests/mooshtest/tests/behat/../../../../lib/behat/behat_base.php): failed to open stream: No such file or directory in /var/www/html/moosh/tests/mooshtest/tests/behat/behat_moosh.php on line 24
PHP Fatal error:  require_once(): Failed opening required '/var/www/html/moosh/tests/mooshtest/tests/behat/../../../../lib/behat/behat_base.php' (include_path='/var/www/html/lib/pear:.:/usr/local/lib/php') in /var/www/html/moosh/tests/mooshtest/tests/behat/behat_moosh.php on line 24

Warning: require_once(/var/www/html/moosh/tests/mooshtest/tests/behat/../../../../lib/behat/behat_base.php): failed to open stream: No such file or directory in /var/www/html/moosh/tests/mooshtest/tests/behat/behat_moosh.php on line 24

Fatal error: require_once(): Failed opening required '/var/www/html/moosh/tests/mooshtest/tests/behat/../../../../lib/behat/behat_base.php' (include_path='/var/www/html/lib/pear:.:/usr/local/lib/php') in /var/www/html/moosh/tests/mooshtest/tests/behat/behat_moosh.php on line 24
  • There is no lib/behat directory under the moosh/ dir this path resolves to. I think it's meant to be looking for lib/behat relative to the Moodle root one level higher.

  • I don't see how 4 levels up from /moosh/tests/mooshtest/tests/behat/ ever resolves to the Moodle root, which will always be 1 level higher. If it usually works b/c you're including behat_moosh.php from another directory, try use dirname(DIR) to get there.

  • If you need to, you could try a little harder to guess where the Moodle root is, e.g. pseudocode:

- Look for config.php at '__DIR__ . '/../../../../'
- If it is not there, look one more level up
- require_once from this path.

Expected behaviour

Moodle's Behat tests should not fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions