PHPUnit installation in Windows: Difference between revisions
m (Minor grammatical changes) |
|||
Line 5: | Line 5: | ||
==Before you start== | ==Before you start== | ||
If you see '''launch as administrator''' | If you see '''launch as administrator''' below it means that you need to work around User Account Controls restrictions. There are several ways to do that: | ||
* Click Start button. Type 'cmd' and, instead of pressing Return, press Ctrl + Shift + Return. This should give you a popup prompt to confirm permissions, then run the command prompt as administrator. | * Click Start button. Type 'cmd' and, instead of pressing Return, press Ctrl + Shift + Return. This should give you a popup prompt to confirm permissions, then run the command prompt as administrator. | ||
* Install some file manager such as TotalCommander and launch it using right click + "Run as administrator". Then all programs started from the file manager have full administrative access. | * Install some file manager such as TotalCommander and launch it using right click + "Run as administrator". Then all programs started from the file manager have full administrative access. | ||
* Open file Explorer and type "C:\windows\system32", then find cmd.exe and right click and select "Run as administrator". | * Open file Explorer and type "C:\windows\system32", then find cmd.exe and right click and select "Run as administrator". | ||
* Start the Command Prompt as Administrator by clicking Start, All programs and Accessories, then right-click on Command Prompt link and selecting "Run as Administrator" from the context menu. | |||
* Temporarily turn off UAC. | * Temporarily turn off UAC. | ||
It is possible to paste text into command line (cmd.exe) by clicking | It is possible to paste text into command line (cmd.exe) by right-clicking inside the terminal window selecting "Paste". | ||
If you are using 64bit Windows, use "C:\Program Files (x86)" instead of "C:\Program Files" where it is written in the instructions below. | |||
==Install Apache 2.2== | ==Install Apache 2.2== | ||
* | * Download the Apache server installer from http://httpd.apache.org/download.cgi (for example httpd-2.2.22-win32-x86-openssl-0.9.8t.msi). | ||
* | * Install it to the default location "C:\Program Files\Apache Software Foundation\Apache2.2\". | ||
* | * Create a "C:\server\workspace" directory. | ||
* | * Edit the "C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf" file so that it resembles the following. | ||
DocumentRoot "C:/server/workspace" | DocumentRoot "C:/server/workspace" | ||
Line 30: | Line 33: | ||
==Install PHP== | ==Install PHP== | ||
Do not use PHP 5.4.x because it does not have | Do not use PHP 5.4.x because it does not have a Windows installer yet and some extensions are not compatible. Moodle 2.3 is going to be the first version fully compatible with PHP 5.4. | ||
* | * Download the '''thread safe''' PHP 5.3.x installer from http://windows.php.net/download/ (for example php-5.3.10-Win32-VC9-x86.msi) | ||
* | * Launch the PHP installer. | ||
** | ** Install it to default location "C:\Program Files\PHP\". | ||
** | ** Select the "Apache 2.2.x Module". | ||
** Apache configuration | ** Apache configuration should be installed in "C:\Program Files\Apache Software Foundation\Apache2.2\conf\". | ||
** | ** Select "PHP / Script Executable" to be installed. | ||
** | ** Select "PHP / Extensions / Multi-Byte" to be installed. | ||
** | ** Select "PHP / Extras / PEAR Install" to be installed. | ||
* | * Add index.php to C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf | ||
<IfModule dir_module> | <IfModule dir_module> | ||
Line 46: | Line 49: | ||
</IfModule> | </IfModule> | ||
* | * Download the '''thread safe''' PHP 5.3.x zip package from http://windows.php.net/download/ (for example php-5.3.10-Win32-VC9-x86.zip) | ||
* | * Extract the zip file so it overwrites files in "C:\Progam Files\PHP\"; this will give you missing libs and extensions. | ||
* | * Edit "C:\Program Files\PHP\php.ini", add the line <code>extension=php_intl.dll</code> at the end of the Dynamic Extensions section (or uncomment it if it is already present). | ||
==Verify Apache and PHP configuration== | ==Verify Apache and PHP configuration== | ||
* | * Restart windows. | ||
* | * Launch cmd.exe as a normal user. | ||
* | * Verify <code>php.exe --version</code> prints version information, if not fix system PATH setting to include "C:\Program Files\PHP". | ||
* | ** Right-click on My Computer | ||
** Select Properties | |||
** If you are using Windows Vista or beyond, click "Advanced system settings". Windows XP users can skip this step. | |||
** On the Advanced tab, click "Environment Variables". | |||
** Find the Path variable under "System variables" and edit it. | |||
** Add your PHP directory path to this variable. | |||
** Close all System property windows for this to take effect. | |||
** Restart any cmd.exe terminals to start using the new Path value. | |||
* Create "C:\server\workspace\index.php" file with the following content. | |||
<code php> | <code php> | ||
Line 62: | Line 73: | ||
</code> | </code> | ||
* | * Open http://127.0.0.1/ in you browser and verify all necessary extensions, including intl, are present in the list shown. | ||
* | * Delete "C:\server\workspace\index.php". | ||
==Install PEAR== | ==Install PEAR== | ||
Launch cmd.exe '''as administrator''' and run the following commands. | |||
cd "C:\Program Files\PHP" | cd "C:\Program Files\PHP" | ||
go-pear.bat | go-pear.bat | ||
* | * Confirm "system". | ||
* | * Type 12 and select the "C:\Program Files\PHP" directory. | ||
* | * Hit Enter a few times. | ||
start PEAR_ENV.reg | start PEAR_ENV.reg | ||
* | * Optionally, you can set the proxy server manually. | ||
pear config-set http_proxy my.proxy.is:80 | pear config-set http_proxy my.proxy.is:80 | ||
* | * Upgrade all PEAR packages. | ||
pear upgrade | pear upgrade | ||
==Install PHPUnit== | ==Install PHPUnit== | ||
Launch cmd.exe '''as administrator''' and install PHPUnit using the following commands. | |||
cd "C:\Program Files\PHP" | cd "C:\Program Files\PHP" | ||
Line 94: | Line 105: | ||
==Install PostgreSQL== | ==Install PostgreSQL== | ||
* | * Download PostgreSQL from http://www.enterprisedb.com/products-services-training/pgdownload#windows (for example postgresql-9.1.3-1-windows.exe). | ||
* | * Install PostgreSQL with some default locale using UTF-8 (skip the StackBuilder). | ||
* | * Launch PgAdmin III - double click on "PostgreSQL 9.1 (localhost:5432)", right-click on "Databases (1)" and create new database called "moodle". | ||
==Install Git and clone Moodle repository== | ==Install Git and clone Moodle repository== | ||
* | * Download git from http://code.google.com/p/msysgit/downloads/list?can=3 (for example Git-1.7.10-preview20120409.exe). | ||
* | * Install git. | ||
* | * Start "Git bash" (icon on desktop) and clone Moodle using the following commands. | ||
cd /C/server/workspace | cd /C/server/workspace | ||
git clone git://github.com/moodle/moodle.git | git clone git://github.com/moodle/moodle.git | ||
* | * Close the bash window. | ||
==Install Moodle== | ==Install Moodle== | ||
* | * Create a directory called "C:\server\moodledata". | ||
* | * Create a directory called "C:\server\phpu_moodledata". | ||
* | * Create a file "C:\server\workspace\moodle\config.php" with the following content. | ||
<code php> | <code php> | ||
Line 141: | Line 152: | ||
</code> | </code> | ||
* | * Optionally to manually creating a config.php file, go to http://127.0.0.1/moodle and finish standard installation. | ||
==Initialise test environment== | ==Initialise test environment== | ||
Launch cmd.exe as normal user and run the following command. | |||
cd C:\server\workspace\moodle | cd C:\server\workspace\moodle | ||
php admin\tool\phpunit\cli\init.php | php admin\tool\phpunit\cli\init.php | ||
==Execute all tests== | ==Execute all tests== | ||
Launch cmd.exe as normal user and run the following command. | |||
cd C:\server\workspace\moodle | cd C:\server\workspace\moodle | ||
phpunit | phpunit | ||
[[Category:Unit testing]] | [[Category:Unit testing]] |
Revision as of 08:08, 24 April 2012
Moodle 2.3
This step-by-step guide is intended for developers only, it can not be used for production servers!
Before you start
If you see launch as administrator below it means that you need to work around User Account Controls restrictions. There are several ways to do that:
- Click Start button. Type 'cmd' and, instead of pressing Return, press Ctrl + Shift + Return. This should give you a popup prompt to confirm permissions, then run the command prompt as administrator.
- Install some file manager such as TotalCommander and launch it using right click + "Run as administrator". Then all programs started from the file manager have full administrative access.
- Open file Explorer and type "C:\windows\system32", then find cmd.exe and right click and select "Run as administrator".
- Start the Command Prompt as Administrator by clicking Start, All programs and Accessories, then right-click on Command Prompt link and selecting "Run as Administrator" from the context menu.
- Temporarily turn off UAC.
It is possible to paste text into command line (cmd.exe) by right-clicking inside the terminal window selecting "Paste".
If you are using 64bit Windows, use "C:\Program Files (x86)" instead of "C:\Program Files" where it is written in the instructions below.
Install Apache 2.2
- Download the Apache server installer from http://httpd.apache.org/download.cgi (for example httpd-2.2.22-win32-x86-openssl-0.9.8t.msi).
- Install it to the default location "C:\Program Files\Apache Software Foundation\Apache2.2\".
- Create a "C:\server\workspace" directory.
- Edit the "C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf" file so that it resembles the following.
DocumentRoot "C:/server/workspace" <Directory "C:/server/workspace"> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>
Install PHP
Do not use PHP 5.4.x because it does not have a Windows installer yet and some extensions are not compatible. Moodle 2.3 is going to be the first version fully compatible with PHP 5.4.
- Download the thread safe PHP 5.3.x installer from http://windows.php.net/download/ (for example php-5.3.10-Win32-VC9-x86.msi)
- Launch the PHP installer.
- Install it to default location "C:\Program Files\PHP\".
- Select the "Apache 2.2.x Module".
- Apache configuration should be installed in "C:\Program Files\Apache Software Foundation\Apache2.2\conf\".
- Select "PHP / Script Executable" to be installed.
- Select "PHP / Extensions / Multi-Byte" to be installed.
- Select "PHP / Extras / PEAR Install" to be installed.
- Add index.php to C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf
<IfModule dir_module> DirectoryIndex index.php index.html </IfModule>
- Download the thread safe PHP 5.3.x zip package from http://windows.php.net/download/ (for example php-5.3.10-Win32-VC9-x86.zip)
- Extract the zip file so it overwrites files in "C:\Progam Files\PHP\"; this will give you missing libs and extensions.
- Edit "C:\Program Files\PHP\php.ini", add the line
extension=php_intl.dll
at the end of the Dynamic Extensions section (or uncomment it if it is already present).
Verify Apache and PHP configuration
- Restart windows.
- Launch cmd.exe as a normal user.
- Verify
php.exe --version
prints version information, if not fix system PATH setting to include "C:\Program Files\PHP".- Right-click on My Computer
- Select Properties
- If you are using Windows Vista or beyond, click "Advanced system settings". Windows XP users can skip this step.
- On the Advanced tab, click "Environment Variables".
- Find the Path variable under "System variables" and edit it.
- Add your PHP directory path to this variable.
- Close all System property windows for this to take effect.
- Restart any cmd.exe terminals to start using the new Path value.
- Create "C:\server\workspace\index.php" file with the following content.
<?php
echo phpinfo();
- Open http://127.0.0.1/ in you browser and verify all necessary extensions, including intl, are present in the list shown.
- Delete "C:\server\workspace\index.php".
Install PEAR
Launch cmd.exe as administrator and run the following commands.
cd "C:\Program Files\PHP" go-pear.bat
- Confirm "system".
- Type 12 and select the "C:\Program Files\PHP" directory.
- Hit Enter a few times.
start PEAR_ENV.reg
- Optionally, you can set the proxy server manually.
pear config-set http_proxy my.proxy.is:80
- Upgrade all PEAR packages.
pear upgrade
Install PHPUnit
Launch cmd.exe as administrator and install PHPUnit using the following commands.
cd "C:\Program Files\PHP" pear config-set auto_discover 1 pear install pear.phpunit.de/PHPUnit pear install phpunit/DbUnit
Install PostgreSQL
- Download PostgreSQL from http://www.enterprisedb.com/products-services-training/pgdownload#windows (for example postgresql-9.1.3-1-windows.exe).
- Install PostgreSQL with some default locale using UTF-8 (skip the StackBuilder).
- Launch PgAdmin III - double click on "PostgreSQL 9.1 (localhost:5432)", right-click on "Databases (1)" and create new database called "moodle".
Install Git and clone Moodle repository
- Download git from http://code.google.com/p/msysgit/downloads/list?can=3 (for example Git-1.7.10-preview20120409.exe).
- Install git.
- Start "Git bash" (icon on desktop) and clone Moodle using the following commands.
cd /C/server/workspace git clone git://github.com/moodle/moodle.git
- Close the bash window.
Install Moodle
- Create a directory called "C:\server\moodledata".
- Create a directory called "C:\server\phpu_moodledata".
- Create a file "C:\server\workspace\moodle\config.php" with the following content.
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'pgsql';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'postgres';
$CFG->dbpass = 'PUT POSTGRESQL PASSWORD HERE';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbsocket' => ,
);
$CFG->wwwroot = 'http://127.0.0.1/moodle';
$CFG->dataroot = 'C:\\server\\moodledata';
$CFG->passwordsaltmain = 'some random rubbish goes here';
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;
$CFG->phpunit_prefix = 'phpu_';
$CFG->phpunit_dataroot = 'C:\\server\\phpu_moodledata';
require_once(dirname(__FILE__) . '/lib/setup.php');
- Optionally to manually creating a config.php file, go to http://127.0.0.1/moodle and finish standard installation.
Initialise test environment
Launch cmd.exe as normal user and run the following command.
cd C:\server\workspace\moodle php admin\tool\phpunit\cli\init.php
Execute all tests
Launch cmd.exe as normal user and run the following command.
cd C:\server\workspace\moodle phpunit