-
Notifications
You must be signed in to change notification settings - Fork 1
Behat for windows
These instructions were created for Windows 7, but it's highly likely that everything applies to Windows 8. To get started, you'll need to get a pre-packaged version of Moodle 2.5+ with XAMPP. This contains a zip file with everything you need to get Moodle 2.5 running. After you extract the file you can run the Start Moodle.exe
file and that will load everything you need.
You will also need git for Windows. You will need this to clone our UCLA repo, but also to install Git Bash, a command line environment that we'll use to run the behat scripts and selenium server. When you install make sure to enable the 'Git Bash in context menu' option. This will let you 'right-click' on any folder and start Git Bash in that context. Also allow Git Bash to be added to your Windows Path.
In order to clone our repo, you'll need to set up Git Bash with your Github keys. This is pretty standard and very well documented in the Github setup page.
You will now need to get your hands a little dirty. We'll be changing the the document root of the apache server so that we can load our custom version of Moodle. in your server
folder find the following file: apache/conf/httpd.conf
. You will have to edit this file in two locations to change the document root so that we point to a folder called www
instead of moodle
.
# DocumentRoot "C:/Users/PathTo/MoodleWindowsInstaller-latest-25/server/moodle"
DocumentRoot "C:/Users/PathTo/MoodleWindowsInstaller-latest-25/server/www"
# And also change
# <Directory "C:/Users/PathTo/MoodleWindowsInstaller-latest-25/server/moodle">
<Directory "C:/Users/PathTo/MoodleWindowsInstaller-latest-25/server/www">
This assumes that you have created a folder called www
inside the server
folder. Save the changes and restart the server. If you go to localhost
, you will see a blank page instead of the pre-loaded vanilla Moodle.
Go to your server/www
folder and clone a copy of the Moodle project with git clone git@github.com:ucla/moodle.git
. You can now access this instance of Moodle with localhost\moodle
.
You will need to set up a database and config file. I've found it easier to simply import a pre-loaded database dump than to have Moodle go through the install process. Here is a fine specimen: https://test.ccle.ucla.edu/vagrant/new_moodle_instance.sql. Download that file into your server
folder.
Open a Git Bash instance in the server
folder. Type the following commands that follow the mysql>
prompt:
$ mysql/bin/mysql -u root -p
Enter password:
[ Press Enter ]
Welcome to the MySQL Monitor...
...
mysql>
mysql> CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON moodle.* TO 'moodle'@'localhost' IDENTIFIED BY 'test';
Query OK, 1 row affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 1 row affected (0.00 sec)
mysql> use moodle
Dtabase changed
mysql> source new_moodle_instance.sql
... Query OK, ...
mysql> exit
Congratulations! You've just created a new Moodle instance.
Go to your server/www
folder. Open up Git Bash in that context and type in the following:
ln -s local/ucla/config/shared_behat_moodle-config.php config.php
touch cofing_private.php
cd ..
mkdir moodledata
We've created the Moodle config.php
and config_private.php
, as well as the moodledata
dir that Moodle expects. Notice that moodledata
is created in the www
folder. Also notice that in your config_private.php
, you will need to specify a full windows path to that folder.
Edit your config private and put in the following:
<?php
// Private moodle configuration file
// sensitive db details
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'moodle';
$CFG->dbpass = 'test';
$CFG->wwwroot = 'http://localhost/moodle';
$CFG->dataroot = 'C:/pathTo/server/www/moodledata';
// Default salt to use if you are using the sample database dump at
// https://test.ccle.ucla.edu/vagrant/new_moodle_instance.sql
$CFG->passwordsaltmain = 'a_very_long_salt_string';
The SQL dump is updated for Moodle 2.5.2, so if you're running that codebase you will not have to run any site upgrades.
When we created the symlink with ln -s ...
, Windows did not really create a symlink, but instead copied the file. Our custom config.php
needs to be modified to reflect that. Edit your config.php
file and change the following:
$_dirroot_ = dirname(realpath(__FILE__)) . '/../../..';
// into
$_dirroot_ = dirname(realpath(__FILE__));
Now you should be able to load the site on localhost/moodle
.
You will need to get Composer in order to run Behat. To do this, type the following into your Git Bash console. Assuming you're in your moodle
folder:
curl -sS http://getcomposer.org/installer | php
If all works, you'll see a Composer successfully installed to C:/...
message. Now you need to initialize your Behat environment in Moodle. Add the following lines to your config_private.php
:
$CFG->behat_prefix = 'bht_';
$CFG->behat_dataroot = $CFG->dataroot . '/behat';
$CFG->behat_switchcompletely = true;
Go back to your console and initialize the Behat environment with:
php admin/tool/behat/cli/init.php
The first time around, this will download all the dependencies and build the tables that will be used for the Behat environment. You might have to wait a while...
Get the standalone Selenium server. This requires you to have Java on your system. If you've installed Git Bash, you'll be able to run the server like so (assuming you open Git Bash in the folder containing the jar file):
java -jar selenium-server-standalone-2.37.0.jar