Permalink
Fetching contributors…
Cannot retrieve contributors at this time
86 lines (76 sloc) 3.18 KB
language: php
matrix:
include:
# aliased to a recent 5.6.x version
- php: "5.6"
env: WP_VERSION=4.8
- php: '5.6'
env:
- WP_VERSION=latest
#- SNIFF=1
- WP_MULTISITE=0
- php: '5.6'
env:
- WP_VERSION=latest
#- SNIFF=1
- WP_MULTISITE=1
# aliased to a recent 7.x version
- php: '7.0'
env: WP_VERSION=4.8
- php: '7.0'
env: WP_VERSION=latest
- php: '7.1'
env: WP_VERSION=4.8
- php: '7.1'
env: WP_VERSION=latest
before_script:
# Set up CodeSniffer
- export PHPCS_DIR=/tmp/phpcs
- export SNIFFS_DIR=/tmp/sniffs
# Install CodeSniffer for WordPress Coding Standards checks.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi
# Install WordPress Coding Standards.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_DIR; fi
# Install PHP Compatibility sniffs.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $SNIFFS_DIR/PHPCompatibility; fi
# Set install path for PHPCS sniffs.
# @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs --config-set installed_paths $SNIFFS_DIR; fi
# After CodeSniffer install you should refresh your path.
- if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi
# Set up unit tests
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
# Properly handle PHPUnit versions
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- |
if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then
composer global require "phpunit/phpunit=4.8.*"
elif [[ ${TRAVIS_PHP_VERSION:0:2} == "7." && ${WP_VERSION} == "4.8" ]]; then
composer global require "phpunit/phpunit=5.7.*"
fi
- |
if [[ -n $COMPOSER_BIN_DIR && -x $COMPOSER_BIN_DIR/phpunit ]]; then
$COMPOSER_BIN_DIR/phpunit --version
else
phpunit --version
fi
script:
# Search for PHP syntax errors.
- find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
# WordPress Coding Standards.
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
# @link http://pear.php.net/package/PHP_CodeSniffer/
# -p flag: Show progress of the run.
# -s flag: Show sniff codes in all reports.
# -v flag: Print verbose output.
# -n flag: Do not print warnings. (shortcut for --warning-severity=0)
# --standard: Use WordPress as the standard.
# --extensions: Only sniff PHP files.
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs -p -s -v -n . --standard="WordPress-VIP" --extensions=php; fi
# Run unit tests
- |
if [[ -n $COMPOSER_BIN_DIR && -x $COMPOSER_BIN_DIR/phpunit ]]; then
$COMPOSER_BIN_DIR/phpunit
else
phpunit
fi