os: linux

dist: xenial

language: php

notifications:
  email:
    on_success: never
    on_failure: change

branches:
  only:
    - master

php:
  - 5.6
  - 7.4

services:
  - mysql

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

jobs:
  include:
    - php: 5.6
      env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1
    - php: 7.3
      env: WP_VERSION=5.2
    - php: 7.4
      env: WP_VERSION=latest WP_MULTISITE=1 WPSNIFF=1

before_script:
  - export PATH="$HOME/.config/composer/vendor/bin:$PATH"
  - phpenv config-rm xdebug.ini
  - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
  - |
    if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then
      composer global require phpunit/phpunit ^5
    else
      composer global require phpunit/phpunit ^7
    fi
  - |
  - composer global require squizlabs/php_codesniffer:3.5.0 wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer phpcompatibility/phpcompatibility-wp

script:
  - if [[ "$WPSNIFF" == "1" ]]; then phpcs --standard=phpcs.ruleset.xml --extensions=php .; fi
  - phpunit
