Installing PHPUnit, CruiseControl, and Selenium

Install PHP Unit, and Selenium

		pear channel-discover pear.phpunit.de
		pear isntall phpunit.de
		pear install phpunit/PHPUnit_Selenium
		

Download the Selenium Standalone Server and run it. The PHPUnit selenium code will make calls to the Selenium server.

		java -jar selenium-server-standalone-2.39.0.jar
		

Next download cruisecontrol-bin-2.8.4.zip and unpackage it

Install PHP Under Control

		pear channel-discover components.ez.no
		pear channel-discover pear.phpundercontrol.org
		pear install --alldeps phpuc/phpUnderControl-beta
		

Download phpUnderControl Cruisecontrol Upgrade

		git clone git://github.com/phpundercontrol/phpUnderControl.git
		
		C:\phpUnderControl\bin>
		phpuc install C:\cruisecontrol-bin-2.8.4
		
		

The CruiseControl File config.xml in the cruisecontrol-bin-2.8.4

<cruisecontrol>
		<project name="projectname" buildafterfailed="false">
		<schedule interval="30">
		<ant anthome="apache-ant-1.7.0" buildfile="C:\tests\build.xml"/>
		</schedule>
		</project>
		</cruisecontrol>		

The Ant file in the home directory of the project

<?xml version="1.0" encoding="UTF-8"?>
 <project name="testbuild" default="phpunit" basedir=".">
   <target name="phpunit">
      <exec executable="C:\PHP\phpunit.bat" dir="C:\tests\phpunit" failonerror="on">
	  <arg line="--log-junit C:\tests\build\logs\phpunit.xml
	     --configuration C:\tests\phpunit.xml
	     --include-path C:\PHP\pear C:\tests\includes C:\project\includes"
		/>
     </exec>
  </target>
 </project>		

Modify config.xml in the Cruisecontrol directory. There are quite a few other elements inside the projects tag that you should use but to get it working all you need is schedule.

<project name="project-01" buildafterfailed="false">
    <schedule interval="30">
        <ant anthome="apache-ant-1.7.0" buildfile="C:\tests\build.xml"/>
    </schedule> 
  </project>		

Add phpunit.xml to the root directory of the test project

<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         syntaxCheck="false">
  <testsuites>
    <testsuite name="Tests">
      <directory suffix=".php">C:\tests\folder\index</directory>
      <directory suffix=".php">C:\tests\folder\login</directory>
      <directory suffix=".php">C:\tests\folder\registration</directory>

    </testsuite>
  </testsuites>
 </phpunit>		


Need Help?

Because I like writing code I would be happy to help you solve problems if you have questions you cannot find the answer to yourself for some reason.

Contact me