dist: trusty

language: php

matrix:
  include:
    - php: 5.4
      env: COMPOSER_VERSION=1.6.*
    - php: 5.4
      env: COMPOSER_VERSION=1.9.*
    - php: 5.4
      env: COMPOSER_VERSION=1.10.*
    - php: 5.4
      env: COMPOSER_VERSION=2

    - php: 5.5
      env: COMPOSER_VERSION=1.6.*
    - php: 5.5
      env: COMPOSER_VERSION=1.9.*
    - php: 5.5
      env: COMPOSER_VERSION=1.10.*
    - php: 5.5
      env: COMPOSER_VERSION=2

    - php: 5.6
      env: COMPOSER_VERSION=1.6.*
    - php: 5.6
      env: COMPOSER_VERSION=1.9.*
    - php: 5.6
      env: COMPOSER_VERSION=1.10.*
    - php: 5.6
      env: COMPOSER_VERSION=2

    - php: 7.0
      env: COMPOSER_VERSION=1.6.*
    - php: 7.0
      env: COMPOSER_VERSION=1.9.*
    - php: 7.0
      env: COMPOSER_VERSION=1.10.*
    - php: 7.0
      env: COMPOSER_VERSION=2

    - php: 7.1
      env: COMPOSER_VERSION=1.6.*
    - php: 7.1
      env: COMPOSER_VERSION=1.9.*
    - php: 7.1
      env: COMPOSER_VERSION=1.10.*
    - php: 7.1
      env: COMPOSER_VERSION=2

    - php: 7.2
      env: COMPOSER_VERSION=1.6.*
    - php: 7.2
      env: COMPOSER_VERSION=1.9.*
    - php: 7.2
      env: COMPOSER_VERSION=1.10.*
    - php: 7.2
      env: COMPOSER_VERSION=2

    - php: 7.3
      env: COMPOSER_VERSION=1.6.*
    - php: 7.3
      env: COMPOSER_VERSION=1.9.*
    - php: 7.3
      env: COMPOSER_VERSION=1.10.*
    - php: 7.3
      env: COMPOSER_VERSION=2

    - php: 7.4
      env: COMPOSER_VERSION=1.6.*
    - php: 7.4
      env: COMPOSER_VERSION=1.9.*
    - php: 7.4
      env: COMPOSER_VERSION=1.10.*
    - php: 7.4
      env: COMPOSER_VERSION=2

    - php: nightly
      env: COMPOSER_VERSION=2

  allow_failures:
    - php: nightly

sudo: false

# cache vendor dirs
cache:
  directories:
    - $HOME/.composer/cache
    - $HOME/.bin

install:
  - travis_retry composer self-update && composer --version
  - export PATH="$HOME/.composer/vendor/bin:$PATH"
  - travis_retry composer install --prefer-dist --no-interaction

before_script:
  - |
    if [ $TRAVIS_PHP_VERSION = '5.6' ]; then
      PHPUNIT_FLAGS="--coverage-clover=clover.xml"
    else
      phpenv config-rm xdebug.ini || return 0
    fi
  - |
    if [ $COMPOSER_VERSION = 2 ] ; then
      composer require --dev "composer/composer:^2.0@dev" --update-with-dependencies
    else
      composer require --dev "composer/composer:$COMPOSER_VERSION" --update-with-dependencies
    fi

script:
  - ./vendor/bin/phpunit --verbose $PHPUNIT_FLAGS
  - cd tests/scripts && sh run.sh
