How to address plugin settings for Behat tests

How to address plugin settings for Behat tests

Matthias Opitz -
回帖数:2

Hi,

I have written a course format that has an option to display certain information for modules used in a course. The option is switched off by default and may be enabled in the plugin settings.

To be able to test that this information is shown I will have to enable the option first. The option and it's value is stored in the "config_plugins" table

I wrote a generator that I tried to use to add/update the data in that table but all I get is a dml write exception.

How can I switch on a plugin setting using Behat?

Thank you in advance,

m!

回复Matthias Opitz

Re: How to address plugin settings for Behat tests

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
The standard

Given the following config values are set as admin:

step works for things in config_plugins. For example https://github.com/studentquiz/moodle-mod_studentquiz/blob/master/tests/behat/admin_settings.feature#L35
回复Tim Hunt

Re: How to address plugin settings for Behat tests

Matthias Opitz -
Sadly that did not do the trick (for me) - so I solved it in the end like so:
And I log in as "admin"
And I navigate to "Plugins > MyPlugin" in site administration
And I set the following fields to these values:
| Use labels | Yes |
And I press "Save changes"
And I log out

Sometimes it just seems to be too easy...
But thanks anyway,
m!