language: php

php:
  - 5.4

branches:
  except:
    - 7.x-1.x

mysql:
  database: drupal
  username: root
  encoding: utf8

env:
  - UPGRADE=none
  - UPGRADE=7.x-2.13
  - UPGRADE=7.x-2.12
  - UPGRADE=7.x-2.11
  - UPGRADE=7.x-2.10
  - UPGRADE=7.x-2.9
  - UPGRADE=7.x-2.8
  - UPGRADE=7.x-2.7
  - UPGRADE=7.x-2.6
  - UPGRADE=7.x-2.5
  - UPGRADE=7.x-2.4
  - UPGRADE=7.x-2.3
  - UPGRADE=7.x-2.2
  - UPGRADE=7.x-2.1
  - UPGRADE=7.x-2.0

install:
  - sudo apt-get update > /dev/null
  - "mysql -e 'create database drupal;'"

  # Install latest Drush 6.
  - export PATH="$HOME/.composer/vendor/bin:$PATH"
  - composer global require --no-interaction --prefer-source drush/drush:6.*

  # Build Behat dependencies
  - cd ./tests/behat
  - composer install --no-interaction --prefer-source
  - cd ../../../

  # Build Codebase
  - mkdir private_files
  - mkdir profiles
  - mv commerce_kickstart profiles/
  - mkdir drupal
  - mv profiles drupal/

  # Test the current branch
  - cd drupal
  - drush make --yes profiles/commerce_kickstart/drupal-org-core.make --prepare-install
  - drush make --yes profiles/commerce_kickstart/drupal-org.make --no-core --contrib-destination=profiles/commerce_kickstart
  - cd ../

  # Download an old version to test upgrading from.
  - if [[ "$UPGRADE" != none ]]; then drush dl commerce_kickstart-$UPGRADE; fi

  # Setup files
  - sudo chmod -R 777 drupal/sites/all

  # Setup display for Selenium
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start
  - sleep 5

  # Get Selenium
  - wget http://selenium.googlecode.com/files/selenium-server-standalone-2.37.0.jar
  - java -jar selenium-server-standalone-2.37.0.jar > /dev/null 2>&1 &
  - sleep 5

   # Disable sendmail
  - echo sendmail_path=`which true` >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

before_script:

  # Do the site install (either the current revision or old for the upgrade).
  - if [[ "$UPGRADE" == none ]]; then cd drupal; else cd commerce_kickstart-$UPGRADE; fi
  - drush si commerce_kickstart --db-url=mysql://root:@127.0.0.1/drupal --account-name=admin --account-pass=admin --site-mail=admin@example.com --site-name="Commerce Kickstart" --yes
  - cd ../drupal

  # If we're an upgrade test, run the upgrade process.
  - if [[ "$UPGRADE" != none ]]; then cp -a ../commerce_kickstart-$UPGRADE/sites/default/* sites/default/ && drush updb --yes; fi

  # Start server
  - drush runserver --server=builtin 8888 > /dev/null 2>&1 &
  - sleep 3
  - cd profiles/commerce_kickstart/tests/behat

script:

  - DISTRO=`echo $TRAVIS_BUILD_DIR | sed -e "s/\/[^\/]*$//"`
  - export BEHAT_PARAMS="extensions[Drupal\\DrupalExtension\\Extension][drupal][drupal_root]=$DISTRO/drupal"
  - ./bin/behat --config behat.travis.yml

notifications:

  irc: "chat.freenode.net#drupal-commerce"
