Capabilities not there when initialising PHPUnit

Capabilities not there when initialising PHPUnit

by Matthias Grähn -
Number of replies: 1

Hi there,

I am quite new to moodle and setting up some tests for a plugin (local).

I have the installation script and some capabilities defined within access.php. Within the install.php there are some references to capabilities definew within access.php. As I understand this page it should exactly be done this way
https://docs.moodle.org/dev/Local_plugins

Now when initialising php unit with php admin/tool/phpunit/cli/init.php an errow is thrown because that capabilities are not present (in test database).

Question is, what do I do to make it work? (Except from inserting the capabilities also manually within install.php file.)

Thanks and regards

matthias

Average of ratings: -
In reply to Matthias Grähn

Re: Capabilities not there when initialising PHPUnit

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi Matthias,

You can compare Initializing PHPUnit tests with initializing a Moodle site the very first time. When you install a program, there is only one user: the admin who installs the program, and (most) capabilities are not yet defined nor configured. So you cannot use your capabilities in your install.php file, because they will only be available after this script and access.php have been run.

R