Moodle Hat is a Vagrant configuration which provisions a Moodle instance with Behat Acceptance testing and PHPUnit testing configured. It uses a headless Selenium server for Javascript testing.
Configuring Behat and Selenium isn't one of my favorite things. This project provides a relatively quick and painless way to create that environment for testing. PHPUnit testing is included as well for completeness.
These instructions assume a basic familiarity with Vagrant.
You will need a Github personal access token to download the composer dependencies for Behat and PHPUnit. Replace the placeholder value in $oauth
in the Moodle initiation file with a valid token.
After vagrant up
finishes, open two ssh sessions to the vagrant box. In the first, run selenium
. This relies on a bash alias to launch the headless Selenium server. In the second window, do this:
cd /var/www/moodle/htdocs
(default location of Moodle)behat
(runs all Behat tests)
behat
is a shell script which creates reports within /var/www/behat/
and calls the local vendor binary. You may append standard arguments such as behat --tags @core_blog
, which would execute core_blog tests only. The reports may be accessed via the command line or at http://behat.moodle.dev.
PHPUnit tests may be invoked normally from the command line on the vagrant host.
The instance itself may be accessed at http://local.moodle.dev.
Moodle Hat requires recent versions of both Vagrant and VirtualBox to be installed. You also need the vagrant-hostsupdater plugin.
The initial provisioning task can take a long time because it clones the Moodle git repository from github.
Moodle Hat was originally developed at Lafayette College and is available under the GPL2 license.
The headless Selenium portion of this project borrows heavily from David Adams' blog post Behat And Selenium In Vagrant.