Tuffa php tillbehör

Idag har jag ägnat lite tid om att organisera om php koden jag använder för att kör PHPUnit testing och i samband med det råkade jag hitta http://phing.info. Phing är ungefär Ant fast för php 🙂

Det mitt lilla build script gör är att:

  • Exportera kod från mitt repo till target
  • kör de test som finns i target/test på koden i target
  • Flytta in produktions inställningar
  • Har ett devtest target som kör unit tester på koden jag arbetar med.

[xml]

<?xml version="1.0"?>

<project name="Minstartsida.nu" default="dist" basedir=".">

<!–
Use this target for running test in your working copy while programming.
–>
<target name="devtest">
<echo msg="Tests start" />
<phpunit codecoverage="false" haltonfailure="true" haltonerror="true">
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset dir="./test">
<include name="**/*Test*.php"/>
</fileset>
</batchtest>
</phpunit>
<echo msg="Tests end" />
</target>

<!–
Make a clean export of the from subversion deleting ./target dir if it exists.
–>
<target name="prepare">
<echo msg="Delete ./target dir" />
<delete dir="./target" includeemptydirs="true" verbose="true" failonerror="true" />
<echo msg="Exporting project from subversion repo" />
<svnexport svnpath="/usr/bin/svn" username="" password="" nocache="true" repositoryurl="http://www.minlinuxserver.com/mysvn/minstartsida.nu/trunk/" todir="./target" />
</target>

<!–
Run tests (These test run in your ./taget/test)
–>
<target name="test" depends="prepare">
<echo msg="Tests start (target)" />
<phpunit codecoverage="false" haltonfailure="true" haltonerror="true">
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset dir="./target/test">
<include name="**/*Test*.php"/>
</fileset>
</batchtest>
</phpunit>
<echo msg="Tests end (target)" />
</target>

<!–
configure for production
–>
<target name="dist" depends="test">
<echo msg="Copying Configuration for production" />
<copy file="./target/main/config/config.php" tofile="./target/main/include/config.php" overwrite="true"/>
</target>
</project>

[/xml]