<?xml version="1.0" encoding="UTF-8"?>
<project name="OWS Carveout" default="unit_lint"
    xmlns:if="ant:if" xmlns:unless="ant:unless">

    <target name="unit_lint" depends="phpcs,phpunit"/>

    <property name="unittestsdir" value="${basedir}/tests"/>
    <property name="execdir" value="${basedir}/vendor/bin"/>

    <target name="get-php-bin" description="Find out where php binary is">
        <exec executable="/usr/bin/which" outputProperty="php-bin">
            <arg value="php"/>
        </exec>
    </target>

    <target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer">
        <exec executable="${basedir}/vendor/bin/phpcs" failonerror="true">
            <arg value="--extensions=php"/>
            <arg value="-s"/>
            <arg value="--standard=PSR2"/>
            <arg value="--ignore=vendor,app.php"/>
            <arg path="${basedir}"/>
        </exec>
    </target>

    <target name="phpunit" description="Run unit tests with PHPUnit">
        <exec executable="${execdir}/phpunit" dir="${unittestsdir}" failonerror="true">
            <arg value="--coverage-html"/>
            <arg value="${basedir}/build/coverage"/>
            <arg value="--coverage-clover"/>
            <arg value="${basedir}/build/logs/phpunit.coverage.xml"/>
            <arg value="--log-junit"/>
            <arg value="${basedir}/build/logs/phpunit.xml"/>
            <arg value="--filter" unless:blank="${testFilter}"/>
            <arg value="${testFilter}" unless:blank="${testFilter}"/>
        </exec>
    </target>
</project>
