sudo: false
dist: trusty

language: php

notifications:
  email:
    on_success: never
    on_failure: change

branches:
  except:
    - gh-pages

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

php:
  - 7.4
  - 7.3
  - 7.2.6
  - 7.1.18
  - 7.0.32
  - 5.6.37
  - nightly

env:
  - WP_VERSION=latest WP_MULTISITE=0
  - WP_VERSION=4.9 WP_MULTISITE=0

jobs:
  include:
    - php: 5.4
      dist: precise
      env: WP_VERSION=5.3 WP_MULTISITE=1
    - php: 5.4
      dist: precise
      env: WP_VERSION=4.9 WP_MULTISITE=0
    - php: 5.3
      dist: precise
      env: WP_VERSION=5.3 WP_MULTISITE=0
    - php: 5.3
      dist: precise
      env: WP_VERSION=4.9 WP_MULTISITE=1
  allow_failures:
    - php: 5.3
    - php: 5.4
    - php: nightly

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
  - |
    if [[ ! -z "$WP_VERSION" ]] ; then
      bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
      composer global require "phpunit/phpunit=4.8.*|5.7.*"
    fi

script:
  - |
    if [[ ! -z "$WP_VERSION" ]] ; then
      phpunit
      WP_MULTISITE=1 phpunit
    fi
  - |
    if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
      phpcs
    fi
