diff --git a/.gitignore b/.gitignore index 49fd402..e19ddc0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ +## editors .idea/ +.*.sw[op] + +## packaging /debian + +## test +/vendor /build /coverage diff --git a/.travis.yml b/.travis.yml index d73b9eb..694e1c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,27 +9,23 @@ php: matrix: include: - - php: '5.3' - dist: precise - sudo: required + - php: '5.3' + dist: precise + sudo: required + fast_finish: true + allow_failures: + - php: nightly cache: directories: - vendor env: - - ICINGAWEB_VERSION=2.4.1 PHPCS_VERSION=2.9.1 + - ICINGAWEB_VERSION=2.5.1 before_script: - - test -d vendor || mkdir vendor - # TODO: Re-enable after dropping 5.3 support: - # - curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar - - test -e vendor/phpcs-${PHPCS_VERSION}.phar || wget -O vendor/phpcs-${PHPCS_VERSION}.phar https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar - - test -e vendor/v${ICINGAWEB_VERSION}.tar.gz || (cd vendor/ && wget https://github.com/Icinga/icingaweb2/archive/v${ICINGAWEB_VERSION}.tar.gz) - - test -d vendor/icingaweb2-${ICINGAWEB_VERSION} || (cd vendor && tar xfz v${ICINGAWEB_VERSION}.tar.gz) - - ln -s vendor/icingaweb2-${ICINGAWEB_VERSION}/library/Icinga - - ln -s vendor/icingaweb2-${ICINGAWEB_VERSION}/library/vendor/Zend + - ./test/setup_vendor.sh script: - - php vendor/phpcs-${PHPCS_VERSION}.phar + - php vendor/phpcs.phar - phpunit --testdox || phpunit --verbose diff --git a/test/bootstrap.php b/test/bootstrap.php index 79dcd68..e12df22 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -7,6 +7,10 @@ call_user_func(function () { if (! class_exists('PHPUnit_Framework_TestCase')) { require_once __DIR__ . '/phpunit-compat.php'; } + + $include_path = $basedir . '/vendor' . PATH_SEPARATOR . ini_get('include_path'); + ini_set('include_path', $include_path); + require_once $basedir . '/library/Businessprocess/Test/Bootstrap.php'; Bootstrap::cli($basedir); }); diff --git a/test/setup_vendor.sh b/test/setup_vendor.sh new file mode 100755 index 0000000..b9b8c45 --- /dev/null +++ b/test/setup_vendor.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +set -ex + +MODULE_HOME=${MODULE_HOME:="$(dirname "$(readlink -f $(dirname "$0"))")"} +PHP_VERSION="$(php -r 'echo phpversion();')" + +# see also .travis.yml +ICINGAWEB_VERSION=${ICINGAWEB_VERSION:=2.5.1} +ICINGAWEB_GITREF=${ICINGAWEB_GITREF:=} + +PHPCS_VERSION=${PHPCS_VERSION:=2.9.1} + +if [ "$PHP_VERSION" '<' 5.6.0 ]; then + PHPUNIT_VERSION=${PHPUNIT_VERSION:=4.8} +else + PHPUNIT_VERSION=${PHPUNIT_VERSION:=5.7} +fi + +cd ${MODULE_HOME} + +test -d vendor || mkdir vendor +cd vendor/ + +# icingaweb2 +if [ -n "$ICINGAWEB_GITREF" ]; then + icingaweb_path="icingaweb2" + test ! -L "$icingaweb_path" || rm "$icingaweb_path" + + if [ ! -d "$icingaweb_path" ]; then + git clone https://github.com/Icinga/icingaweb2.git "$icingaweb_path" + fi + + ( + set -e + cd "$icingaweb_path" + git fetch -p + git checkout -f "$ICINGAWEB_GITREF" + ) +else + icingaweb_path="icingaweb2-${ICINGAWEB_VERSION}" + if [ ! -e "${icingaweb_path}".tar.gz ]; then + wget -O "${icingaweb_path}".tar.gz https://github.com/Icinga/icingaweb2/archive/v"${ICINGAWEB_VERSION}".tar.gz + fi + if [ ! -d "${icingaweb_path}" ]; then + tar xf "${icingaweb_path}".tar.gz + fi + + rm -f icingaweb2 + ln -svf "${icingaweb_path}" icingaweb2 +fi +ln -svf "${icingaweb_path}"/library/Icinga +ln -svf "${icingaweb_path}"/library/vendor/Zend + +# phpunit +phpunit_path="phpunit-${PHPUNIT_VERSION}" +if [ ! -e "${phpunit_path}".phar ]; then + wget -O "${phpunit_path}".phar https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar +fi +ln -svf "${phpunit_path}".phar phpunit.phar + +# phpcs +phpcs_path="phpcs-${PHPCS_VERSION}" +if [ ! -e "${phpcs_path}".phar ]; then + wget -O "${phpcs_path}".phar \ + https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar +fi +ln -svf "${phpcs_path}".phar phpcs.phar