#!/bin/bash
set -e
cd "$(git rev-parse --show-toplevel)"

phpcs_root="$(dirname $(dirname $(which phpcs)))"

if [ -z "$phpcs_root" ] || [ ! -d "$phpcs_root" ] || [ ! -e "$phpcs_root/tests/AllTests.php" ]; then
	echo "Unable to locate phpcs on path to locate the root of the PHP_CodeSniffer project" 1>&2
	exit 1
fi

find . \( -name '*.php' \) -exec php -lf {} \;

phpunit --filter WordPress "$phpcs_root/tests/AllTests.php"
