Actions

Testing Area/Behat Testing/Setup: Difference between revisions

From Mahara Wiki

< Testing Area‎ | Behat Testing
No edit summary
No edit summary
Line 4: Line 4:




Install Apache, PHP5, Database, Git:
  sudo apt-get install php5 php5-cli php5-pgsql php5-xmlrpc php5-intl php5-curl php5-gd php5-xdebug php5-dbg postgresql apache2 git curl


Restart Apache
  sudo service apache2 restart
Make a mahara directory in the same place as Moodle
  sudo mkdir /var/www/html/mahara
Then change into the Mahara directory
cd /var/www/html/mahara
Then change the permission
sudo chown username:username /var/www/html/mahara
Get Mahara clone.
  git clone https://gitorious.org/mahara/ngson2000s-mahara.git .
Checkout correct version
  git checkout --track origin/behat
Become Postgres user:
  sudo su postgres
Open psql.After some preamble you should see the prompt postgres=#.
  psql
You should now see postgres=# ready and awaiting your command.
Create a user and don't use the PW that you use for your workstation:
  CREATE USER maharauser WITH PASSWORD 'yourpassword';
 
As you previously did, you should see postgres=#
You are now going to create a database:
  CREATE DATABASE mahara WITH OWNER maharauser;
Exit to leave psql by pressing Ctrl-D
Exit back to your own user:
  exit
Make a data directory:
  sudo mkdir /var/www/maharadata
Make directory writeable by mahara:
  sudo chmod 777 /var/www/maharadata
In the code below make sure you change <your email address> to your actual work email address, without the <> signs.
<pre>
<?php
$cfg = new stdClass();
$branch = 'master';
// database connection details
// valid values for dbtype are 'postgres8' and 'mysql5'
$cfg->dbtype  = 'postgres';
$cfg->dbhost  = 'localhost';
$cfg->dbuser  = 'maharauser';
$cfg->dbname  = "mahara";
$cfg->dbpass  = 'password';
$cfg->dataroot = "/var/www/maharadata";
$cfg->sendemail = true;
$cfg->sendallemailto = '<your email address>';
$cfg->productionmode = false;
$cfg->perftofoot = true;
</pre>
An example config.php should appear:
* Copy all of the code above
* open text editor from start menu
* paste code
* save file in the directory: /var/www/html/mahara/htdocs/ and call it config.php
* save
===Behat installation with Mahara===
Add these config settings to the bottom of your config.php file.
<pre>
// Behat config
$cfg->dbprefix = ''; // Behat complains without this
$cfg->wwwroot = 'http://127.0.0.1/mahara/htdocs'
$cfg->behat_dbprefix = 'behat_'; // must not empty
$cfg->behat_dataroot = '/var/www/maharadata/behat';
$cfg->behat_wwwroot = 'http://localhost:8000';
</pre>
Make a data directory:
  sudo mkdir /var/www/maharadata/behat
Make directory writeable by mahara:
  sudo chmod 777 /var/www/maharadata/behat
Initialise Behat
 
  cd /var/www/html/mahara
  php test/behat/scripts/init.php
disable test site
  php test/behat/scripts/util.php --disable
Go to url to install
http://127.0.0.1/mahara/htdocs/admin/index.php
Click "Install Mahara" on the webpage
Click "Continue" on the webpage
You need to change the password and the email. Set the email to your work email address.
Re-enable the test site so we can run the tests
  php test/behat/scripts/util.php --enable
Run the selenium server in another terminal
  java -jar /path/to/your/selenium/server/selenium-server-standalone-2.NN.N.jar
Run the standalone PHP webserver
  cd /var/www/html/mahara/htdocs
  php -S 127.0.0.1:8000
Run a test suite
  cd test/behat
  bin/behat
This will run tests for all features in the folder test/behat/features





Revision as of 16:16, 15 December 2014

How to install Mahara and Behat

Note: These instructions for Mahara and Behat setup are only for machines running Linux. They will not for Windows machines


Install Apache, PHP5, Database, Git:

 sudo apt-get install php5 php5-cli php5-pgsql php5-xmlrpc php5-intl php5-curl php5-gd php5-xdebug php5-dbg postgresql apache2 git curl

Restart Apache

  sudo service apache2 restart

Make a mahara directory in the same place as Moodle

  sudo mkdir /var/www/html/mahara

Then change into the Mahara directory cd /var/www/html/mahara

Then change the permission

sudo chown username:username /var/www/html/mahara

Get Mahara clone.

  git clone https://gitorious.org/mahara/ngson2000s-mahara.git .

Checkout correct version

  git checkout --track origin/behat

Become Postgres user:

 sudo su postgres

Open psql.After some preamble you should see the prompt postgres=#.

 psql

You should now see postgres=# ready and awaiting your command.

Create a user and don't use the PW that you use for your workstation:

 CREATE USER maharauser WITH PASSWORD 'yourpassword';
 

As you previously did, you should see postgres=# You are now going to create a database:

 CREATE DATABASE mahara WITH OWNER maharauser;

Exit to leave psql by pressing Ctrl-D

Exit back to your own user:

 exit

Make a data directory:

 sudo mkdir /var/www/maharadata

Make directory writeable by mahara:

 sudo chmod 777 /var/www/maharadata


In the code below make sure you change <your email address> to your actual work email address, without the <> signs.

<?php
$cfg = new stdClass();

$branch = 'master';

// database connection details
// valid values for dbtype are 'postgres8' and 'mysql5'
$cfg->dbtype   = 'postgres';
$cfg->dbhost   = 'localhost';
$cfg->dbuser   = 'maharauser';
$cfg->dbname   = "mahara";
$cfg->dbpass   = 'password'; 

$cfg->dataroot = "/var/www/maharadata";

$cfg->sendemail = true;
$cfg->sendallemailto = '<your email address>';

$cfg->productionmode = false;
$cfg->perftofoot = true;


An example config.php should appear:

  • Copy all of the code above
  • open text editor from start menu
  • paste code
  • save file in the directory: /var/www/html/mahara/htdocs/ and call it config.php
  • save

Behat installation with Mahara

Add these config settings to the bottom of your config.php file.

// Behat config
$cfg->dbprefix = ''; // Behat complains without this
$cfg->wwwroot = 'http://127.0.0.1/mahara/htdocs'
$cfg->behat_dbprefix = 'behat_'; // must not empty
$cfg->behat_dataroot = '/var/www/maharadata/behat';
$cfg->behat_wwwroot = 'http://localhost:8000';

Make a data directory:

 sudo mkdir /var/www/maharadata/behat

Make directory writeable by mahara:

 sudo chmod 777 /var/www/maharadata/behat

Initialise Behat

  cd /var/www/html/mahara
  php test/behat/scripts/init.php

disable test site

 php test/behat/scripts/util.php --disable

Go to url to install http://127.0.0.1/mahara/htdocs/admin/index.php

Click "Install Mahara" on the webpage

Click "Continue" on the webpage

You need to change the password and the email. Set the email to your work email address.

Re-enable the test site so we can run the tests

 php test/behat/scripts/util.php --enable

Run the selenium server in another terminal

 java -jar /path/to/your/selenium/server/selenium-server-standalone-2.NN.N.jar

Run the standalone PHP webserver

 cd /var/www/html/mahara/htdocs
 php -S 127.0.0.1:8000

Run a test suite

 cd test/behat
 bin/behat

This will run tests for all features in the folder test/behat/features