language: php

php:
  - 5.4
  - 5.5
  - 5.6
  - hhvm
  - hhvm-nightly

# run build against PHP 5.6 and hhvm but allow them to fail
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail
matrix:
  fast_finish: true
  allow_failures:
    - php: 5.6
    - php: hhvm
    - php: hhvm-nightly

services:
  - redis-server
  - memcached
  - elasticsearch
  - mongodb

install:
  - composer self-update && composer --version
# core framework:
  - composer install --prefer-dist
  - tests/unit/data/travis/mongodb-setup.sh
  - tests/unit/data/travis/apc-setup.sh
  - tests/unit/data/travis/memcache-setup.sh
  - tests/unit/data/travis/cubrid-setup.sh
# basic and advanced application:
  - tests/unit/data/travis/setup-apps.sh

before_script:
  - echo 'elasticsearch version ' && curl http://localhost:9200/
  - mysql -e 'CREATE DATABASE yiitest;';
  - psql -U postgres -c 'CREATE DATABASE yiitest;';
  - tests/unit/data/travis/sphinx-setup.sh
  - mongo yii2test --eval 'db.addUser("travis", "test");'
# basic and advanced application:
  - tests/unit/data/travis/init-apps.sh

script:
  - vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --exclude-group mssql,oci,wincache,xcache,zenddata
  - cd apps/basic && php vendor/bin/codecept run
  - cd ../advanced/backend && ../vendor/bin/codecept run
  - cd ../common && ../vendor/bin/codecept run
  - cd ../frontend && ../vendor/bin/codecept run

after_script:
  - cd ../../..
  - wget https://scrutinizer-ci.com/ocular.phar
  - php ocular.phar code-coverage:upload --format=php-clover coverage.clover
