language: php

cache:
  directories:
    - .phpunit
    - $HOME/.composer/cache/files

branches:
  only:
    - master
    - /^\d+\.(\d+|x)$/

matrix:
  fast_finish: true
  include:
    # lowest dependencies
    - php: 7.1
      env: COMPOSER_FLAGS="--prefer-lowest"
    # Symfony 3 LTS
    - php: 7.2
      env: SYMFONY_REQUIRE="3.4.*"
    # Symfony 4.3
    - php: 7.3
      env: SYMFONY_REQUIRE="4.3.*"
    # Symfony 4.4
    - php: 7.4
      env: SYMFONY_REQUIRE="4.4.*" COVERAGE=yes
    # development dependencies
    - php: 7.4
      env: DEPENDENCIES='dev'
  allow_failures:
    - php: 7.4
      env: DEPENDENCIES='dev'

before_install:
  - echo "memory_limit=4G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
  - if [ "$COVERAGE" != "yes" ]; then phpenv config-rm xdebug.ini || true; fi
  - composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
  - if [ "$DEPENDENCIES" != "" ]; then composer config minimum-stability $DEPENDENCIES; fi
  - if [ "$SYMFONY_LTS" != "" ]; then composer require --dev --no-update symfony/lts=$SYMFONY_LTS; fi

install:
  - composer update $COMPOSER_FLAGS --prefer-dist
  - ./phpunit install

script:
  - if [ "$COVERAGE" = "yes" ]; then ./phpunit --coverage-clover=coverage.clover; else ./phpunit; fi
  - if [ "$COVERAGE" = "yes" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi
  - if [ "$COVERAGE" = "yes" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
