#!/bin/bash
#
# Run unit tests with PHPUnit
#
# @author      Steve Talbot
# @copyright   Copyright (c) Solviq Ltd 2016-9
# @license     MIT

mkdir -p var/test
today=`date +%Y%m%d`
vendor/bin/phpunit --disallow-test-output --verbose --colors=always "$@" |tee "var/test/phpunit-$today.txt"
status=${PIPESTATUS[0]}  # PIPESTATUS is bash-specific
sed -i -r 's/\x1B\[(([0-9]+)(;[0-9]+)*)?[m,K,H,f,J]//g' "var/test/phpunit-$today.txt"

exit $status
