language: php

php:
  - 5.3
  - 5.4
  - 5.5
  - 5.6
  - 7
  - hhvm

services:
  - memcached
  - redis-server

before_install:
  - pear list --allchannels

install:
  - if [[ $TRAVIS_PHP_VERSION != '5.6' && $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != 'hhvm-nightly' && $TRAVIS_PHP_VERSION != '7' ]]; then phpenv config-rm xdebug.ini;  fi
  - sudo apt-get install parallel
  - composer install --no-interaction --prefer-source

before_script:
  - cp tests/TestConfiguration.php.travis tests/TestConfiguration.php
  - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then mkdir -p build/coverage; fi

script:
  # Run tests for the various components in parallel
  - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then ls -d tests/ZendTest/* | grep -v 'tests/ZendTest/_files' | grep -v 'tests/ZendTest/AllTests' | parallel --gnu -P 0 'echo "Running {} tests"; php ./vendor/bin/phpunit -c tests/phpunit.xml.dist --colors=always --coverage-php build/coverage/coverage-{/.}.cov {};' || exit 1; fi
  - if [[ $TRAVIS_PHP_VERSION != '5.6' ]]; then ls -d tests/ZendTest/* | grep -v 'tests/ZendTest/_files' | grep -v 'tests/ZendTest/AllTests' | parallel --gnu -P 0 'echo "Running {} tests"; php ./vendor/bin/phpunit -c tests/phpunit.xml.dist --colors=always {};' || exit 1; fi

  # Run coding standard checks in parallel
  - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then ls -d library/Zend/* tests/ZendTest/* bin | parallel --gnu -P 0 'echo "Running {} CS checks"; php ./vendor/bin/php-cs-fixer fix {} -v --diff --dry-run --config-file=.php_cs;' || exit 1; fi

after_script:
  # Merges the individual clover reports of each component into a single clover.xml
  - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then php vendor/bin/phpcov merge --clover build/logs/clover.xml build/coverage; fi
  - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then php vendor/bin/coveralls; fi

notifications:
  irc: "irc.freenode.org#zftalk.dev"
  email: false

matrix:
  fast_finish: true
  allow_failures:
    - php: 7
    - php: hhvm
