#!/bin/sh

set +x
set -e

# generate autoload-files. keep in sync with debian/rules::override_dh_auto_build

phpab --template debian/autoload-test-autopkgtest.php.tpl \
  --output test/autoload.php \
  test

# keep in sync with debian/rules
SEPARATOR="$(php -n -r "require_once '/usr/share/php/PHPUnit/Autoload.php';echo ((int) explode('.', \PHPUnit\Runner\Version::series())[0]) >= 11 ? ' --exclude-group ' : ',';")"
SKIP_32_BIT="$(php -n -r "echo (PHP_INT_SIZE === 4 || php_uname('m') === 's390x') ? '${SEPARATOR}32bit-incompatible' : '';")"

# keep in sync with debian/rules::override_dh_auto_test
LC_ALL=C.UTF-8 phpunit --no-coverage --exclude-group selenium${SEPARATOR}network${SEPARATOR}git-revision${SEPARATOR}ext-xdebug${SEPARATOR}extension-iconv${SEPARATOR}with-trigger-error${SKIP_32_BIT} --bootstrap $(dirname $0)/phpunit-bootstrap-dep8.php
