language: php

dist: trusty

addons:
  chrome: stable

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

env:
    global:
        - DISPLAY=:99.0
        - SELENIUM_VERSION=3.9.1
    matrix:
        - DEPS=high PROFILE=default
        - DEPS=low PROFILE=default
        - DEPS=high PROFILE=symfony2
        - DEPS=low PROFILE=symfony2

php:
    - 5.5
    - 5.6
    - 7.2
    - 7.3
    - 7.4
    - nightly

matrix:
    exclude:
        - php: 7.4
          env: DEPS=low PROFILE=default
        - php: 7.4
          env: DEPS=low PROFILE=symfony2
        - php: nightly
          env: DEPS=low PROFILE=default
        - php: nightly
          env: DEPS=low PROFILE=symfony2
    allow_failures:
        - php: nightly
    fast_finish: true

before_script:
    - Xvfb $DISPLAY -extension RANDR &> /dev/null &

    - LATEST_CHROMEDRIVER_VERSION=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
    - wget --no-verbose https://chromedriver.storage.googleapis.com/$LATEST_CHROMEDRIVER_VERSION/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip -d ~/bin

    - wget "https://selenium-release.storage.googleapis.com/${SELENIUM_VERSION%%.[[:digit:]]}/selenium-server-standalone-${SELENIUM_VERSION}.jar" -O selenium.jar
    - java -jar selenium.jar &> /dev/null &

    - php -S localhost:8080 -t tests/fixtures/www &> /dev/null &
    - cp behat.yml{.dist,}
    - COMPOSER_PATH="/home/travis/.phpenv/versions/$TRAVIS_PHP_VERSION/bin/composer"
    - php -d memory_limit=-1 $COMPOSER_PATH install

    - test "$DEPS" == "high" || php -d memory_limit=-1 $COMPOSER_PATH update --prefer-lowest
    - test ${TRAVIS_PHP_VERSION:0:1} -lt 7 || composer update atoum/atoum

script:
    - ./bin/atoum
    - ./bin/behat -fprogress --tags="~@user&&~@>php${TRAVIS_PHP_VERSION:0:3}" --no-interaction --profile=$PROFILE