sudo: false
dist: trusty

language: php

php:
  #- 5.6
  #- 7.0
  - 7.1
  #- 7.2
  #- hhvm

env:
  - PAYEX_VERSION="master" WOO_VERSION="3.6.5" WP_VERSION=latest

notifications:
  email:
    on_success: never
    on_failure: change

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

matrix:
  fast_finish: true
  allow_failures:
    - php: hhvm
    - php: 7.2

install:
  - cd /tmp
  - git clone https://github.com/woocommerce/woocommerce
  - cd woocommerce/
  - git checkout tags/$WOO_VERSION
  - bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION
  - cd /tmp
  - mkdir /tmp/tmp1
  - wget https://github.com/SwedbankPay/swedbank-pay-woocommerce-payments/archive/master.zip
  - unzip /tmp/master.zip -d /tmp/tmp1
  - mv /tmp/tmp1/swedbank-pay-woocommerce-payments-master/ /tmp/tmp1/swedbank-pay-woocommerce-payments/
  - cd /tmp/tmp1
  - zip -r /tmp/swedbank-pay-woocommerce-payments.zip ./
  - cd /tmp/wordpress
  - curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  - php wp-cli.phar core config --dbname=woocommerce_test --dbuser=root --dbpass='' --dbhost=localhost --dbprefix=wp_
  - php wp-cli.phar core install --url="http://localhost:8080" --title="Example" --admin_user=admin --admin_password=password --admin_email=info@example.com --path=/tmp/wordpress --skip-email
  - php wp-cli.phar plugin install /tmp/swedbank-pay-woocommerce-payments.zip --activate
  - cd $TRAVIS_BUILD_DIR

before_script:
  - export PATH="$HOME/.composer/vendor/bin:$PATH"
  - |
    if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
      phpenv config-rm xdebug.ini
    else
      echo "xdebug.ini does not exist"
    fi
script:
  - |
    phpunit
    WP_MULTISITE=1 phpunit
deploy:
  provider: script
  script: curl -u "travis:${app_token}" -d "release=${TRAVIS_TAG:1}" "http://magento7.aait.nu/scripts/payex-woocommerce-checkout/deploy.php"
  on:
    tags: true
    all_branches: true
