language: php
sudo: required
dist: trusty
cache:
    directories:
        - $HOME/.composer/cache/files

php:
    - 5.4
    - 5.5
#    - 5.6
#    - 7.2

env:
    global:
        - TEST_COMMAND="composer test"
        - BUZZ_TEST_SERVER="http://127.0.0.1:8080/server.php"
        - TEST_PROXY="127.0.0.1:3128"
        - PHP_FCGI_CHILDREN=10
        - PHP_FCGI_MAX_REQUESTS=10
        - COMPOSER_FLAGS="--prefer-dist"

matrix:
    allow_failures:
        - php: hhvm
          dist: trusty
    fast_finish: true
    include:
        - php: 5.5
          env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"
        - php: 7.0
          env: SYMFONY_PHPUNIT_VERSION=6.3
        - php: 7.1
          env: SYMFONY_PHPUNIT_VERSION=6.3

before_install:
    - echo "" | sudo add-apt-repository ppa:nginx/stable > /dev/null 2>&1
    - sudo apt-get -qq update
    - sudo apt-get -qq install nginx squid
    - sudo stop squid3
    - curl --version

install:
    - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
    - sudo sh ./test/.travis/configure-php.sh $USER $(phpenv version-name)
    - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
    - sudo nginx -p test -c .travis/etc/nginx.conf
    - sudo squid3 -f test/.travis/etc/squid.conf
    - composer update $COMPOSER_FLAGS
    - ./vendor/bin/simple-phpunit install

before_script:
    - vendor/bin/http_test_server > /dev/null 2>&1 &

script:
    - $TEST_COMMAND

after_success:
    - if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
    - if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
