language: php

php:
  - 5.3

mysql:
  database: drupal
  username: root
  encoding: utf8

before_script:
  # navigate out of module directory to prevent blown stack by recursive module lookup
  - cd ../..

  # install drush
  - pear channel-discover pear.drush.org
  - pear install drush/drush-5.8.0
  - phpenv rehash

  # install php packages required for running a web server from drush on php 5.3
  - sudo apt-get update > /dev/null
  - sudo apt-get install -y --force-yes php5-cgi php5-mysql

  # create new site, stubbing sendmail path with true to prevent delivery errors and manually resolving drush path
  - mysql -e 'create database drupal'
  - php -d sendmail_path=`which true` `pear config-get php_dir`/drush/drush.php --yes core-quick-drupal --profile=testing --no-server --db-url=mysql://root:@127.0.0.1/drupal --enable=simpletest message

  # reference and enable module in build site
  - ln -s $(readlink -e $(cd -)) message/drupal/sites/all/modules/message
  - cd message/drupal
  - drush --yes pm-enable message

  # start a web server on port 8080, run in the background; wait for initialization
  - drush runserver 127.0.0.1:8080 &
  - until netstat -an 2>/dev/null | grep '8080.*LISTEN'; do true; done

script: drush test-run Message --uri=http://127.0.0.1:8080
