Change $CFG value in test

Change $CFG value in test

by Gilles-Philippe Leblanc -
Number of replies: 2

Hi,

I i'm trying to write an unit test un phpunit. I am able to set my config value one time but unable to change it live in my unittest. Do someone know how to do it ?

Thanks you,

Gilles-Philippe

Average of ratings: -
In reply to Gilles-Philippe Leblanc

Re: Change $CFG value in test

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Several unit tests in core code do this, so search and find one to see how it is done. (Probably you use set_config.)

In reply to Tim Hunt

Re: Change $CFG value in test

by Gilles-Philippe Leblanc -

Finally, the problem was not related with set_config(). It indeed work as espected.

I'm writing a unit test for the get_plugins_import() method mod/grade/lib.php because it does not reset even by calling the test method: resetAfterTest().

I think I have found a solution. Thank you for your help and sorry for the inconvenience!