"Behat only can modify the test database and the test dataroot!" (BEHAT_SITE_RUNNING not defined)

"Behat only can modify the test database and the test dataroot!" (BEHAT_SITE_RUNNING not defined)

by Lawrence Lagerlof -
Number of replies: 2

I am trying to run a behat test feature that comes with moodle.

- behat configuration set in config.php

require_once dirname(__FILE__) . '/moodle-browser-config/init.php';

$CFG->wwwroot = 'http://localhost/moodle404';
$CFG->dataroot = '/var/moodledata';

$CFG->behat_wwwroot = 'http://127.0.0.1/moodle404';
$CFG->behat_dataroot = '/var/moodledata_behat';
$CFG->behat_prefix = 'behat_';

- php admin/tool/behat/cli/init.php executed sucessfully.

- Selenium is running with the correct version of chromedriver

- When I try to run this single feature (below) I receive the message "Behat only can modify the test database and the test dataroot!":

vendor/bin/behat --config /var/moodledata_behat/behatrun/behat/behat.yml `pwd`/mod/forum/tests/behat/private_replies.feature

Debugging I found that BEHAT_SITE_RUNNING is not defined in behat_hooks.php, method before_suite_final_checks().

So my question is, what I need to do to enable BEHAT_SITE_RUNNING, the correct way.

Note: $CFG->wwwroot and $CFG->behat_wwwroot are both accessible, and even behat website shows me the title "Acceptance test site".

Average of ratings: -
In reply to Lawrence Lagerlof

Re: "Behat only can modify the test database and the test dataroot!" (BEHAT_SITE_RUNNING not defined)

by Lexy Walker -
Picture of Core developers Picture of Particularly helpful Moodlers
You've probably solved your problem by now, but I just found this post while trying to set up a Behat environment in Docker and stumbling across the same problem.

You tried to make your own config.php file from scratch, and forgot to include this line at the end:

require_once(__DIR__ . '/lib/setup.php');
In reply to Lawrence Lagerlof

Re: "Behat only can modify the test database and the test dataroot!" (BEHAT_SITE_RUNNING not defined)

by Pablo Zambrano -
Hi Lawrence,

I would like to know if you have managed to solve the problem you raised, because I am currently at the same point and I'm not quite sure what to do, any help is welcome.