Install Steps:
Windows:
-------------
1. PHP Install:
1.1 Precautions: Before installing, first check is php available in your system. If so either delete or continue with existing one.
1.2 Check system | enviroment variables, is path or variables are set, either delete or continue with same.
1.3 NowiInstall PHP [ visit site - http://windows.php.net/downloads/releases/ download either msi or zip package. Preferably in C:\php folder]
2. PEAR install:
2.1 Precautions: First check in your system, PEAR already exists. If so continue or delete.
If u r deleting means, need to delete all system environment variable those are set earlier.
2.2 Open cmd prompt, goto php folder & install PEAR package.
C:\php>go-pear.bat
This will install the pear package, but some times for the packages latest PEAR version might be needed. So visit the site, http://pear.php.net/package/PEAR/download to check the latest versions. & then type command as mentioned in the site.
2.3 While installing, pear.bat will prompt to know the location for installing.
Carefully set the locations, by default choose C:\php
2.4 To know, PEAR is install successfully, type in cmd prompt, C:\php> pear -config
It displays all config settings & commands.
3. PHPUnit Install:
3.1 Check PHPUnit package already exists in C:\php\PEAR folder. If not, proceed as below.
3.2 Before installing PHPUnit, need to initialize the channels(websites) from which dependency packages are to be downloaded. To do this,
C:\php> pear update-channels or pear channel-update ; it will update all channels.
OR
discover each channel as below
pear channel-discover pear.phpunit.de
pear channel-discover pear.phpunit.com
pear channel-discover pear.symfony-project.com
pear channel-discover components.ez.no
3.3 Now install PHPUnit. C:\php> pear install phpunit/PHPUnit
make sure u will get the message - install ok: channel:<>/PHPUnit<version>
If you did not get this message, instead any error message means, follow them carefully & try to succeed in installing the PHPUnit.
After installing successfully, to check phpunit is installed correctly, then try to locate the file phpunit.bat in C:\php folder. If exists means, it is installed correctly.
4. Write & Execute PHP unit tests.
4.1 Open any editor & write php test code. Example:
<?php
require_once 'PHPUnit/Framework.php';
class StackTest extends PHPUnit_Framework_TestCase
{
public function testPushAndPop()
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
}
?>
4.2 Save file as Class name, StackTest.php in the c:\php folder.
4.3 Run the test, C:\php> phpunit StackTest.php, will get result as below:
PHPUnit 3.5.14 by Sebastian Bergmann.
Time: 1 second, Memory: 3.00Mb
OK (1 test, 5 assertions)
5. Explore more about PHPUnit testing, assertions - http://www.phpunit.de/manual/3.4/en/writing-tests-for-phpunit.html
6. Selenium RC setup:
6.1 Download selenium RC jar file & locate anywhere. Ex: C:\Selenium|Selenium-server.jar
6.2 Open cmd prompt, then run jar file, C:\Selenium> java -jar selenium-server.jar
Now selenium server starts running at the backend.
7. Preparing test script using Selenium IDE
7.1 Open Mozilla firefox browser > Tools > Selenium IDE ( if not installed, install IDE as addon)
7.2 Record your script > export as PHPUnit script.
7.3 Selenium script in PHPUnit framework
7.4 Save file in C:\php under either class name or any of your choice.
8. Running the scripts
8.1 In one cmd prompt, selenium server will be running.
8.2 Open one more cmd prompt to run the script like C:\php> phpunit Example
See below how the script will be executed