language: php

php:
  - 5.4
  - 5.5
  - 5.6
  - hhvm

# 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:
  allow_failures:
    - php: hhvm
    - php: 5.6

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 application:
  - composer install --dev --prefer-dist -d apps/basic
  - cd apps/basic && composer require --dev codeception/codeception:1.8.*@dev codeception/specify:* codeception/verify:*
  - php vendor/bin/codecept build && cd ../..
  - cd apps && php -S localhost:8080 &

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");'

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

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