language: php
services:
  - mysql

php:
  - 7.1

mysql:
  database: drupal
  username: root
  encoding: utf8

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

install:
  - export PATH="$HOME/.composer/vendor/bin:$PATH"
  - composer global require drush/drush:8.1.* torotil/upal:1.1.3 phpunit/phpunit:6.4.*

before_script:
  - repo=`pwd`
  - root=$HOME/test-root
  - mysql -e 'create database drupal'
  - php -d include_path=`pwd` -d sendmail_path=`which true` ~/.composer/vendor/bin/drush.php --yes core-quick-drupal --core=drupal-7.x --profile=testing --no-server --db-url=mysql://root:@127.0.0.1/drupal --root=$root
  - ln -s $repo $root/sites/all/modules/module_under_test
  - cd $root
  - drush dl webform ctools options_element psr0
  - drush --yes pm-enable form_builder_webform form_builder_examples

script:
  - cd $repo
  - UPAL_ROOT=$root UPAL_WEB_URL=http://127.0.0.1 phpunit --bootstrap=$HOME/.composer/vendor/torotil/upal/bootstrap.php --coverage-clover=coverage.xml .

after_success:
  - bash <(curl -s https://codecov.io/bash)
