Unit testing

Unit testing

by Sarah Fahlesson -
Number of replies: 1

So, like everyone else, we've created a 'few' plugins. Now we have set up a rather automated process for building and testing. But... our unit tests fail. ALL the time. And not within our plugins, but with moodle files themselves.

The problem seems to be that the unit tests aren't locating $CFG, and then not dirroot or libdir. I can fix this by going into the file itself and changing code from

require_once("{$CFG->libdir}/externallib.php");

to

require_once(__DIR__.'/../../../../../lib/externallib.php');

But every time I fix one, another in another file shows up. One or two, ok... whatever. But now I'm starting to be wonder if there might be a problem with our setup that unit testing can't locate $CFG. When we build without unit testing, no problems. Everything works as expected, $CFG is located, and nothing is off. I figure we're doing something wrong, but I can't for the life of me figure out what. Any suggestions about where to start looking would be appreciated.

Average of ratings: -