Skip to content

Commit

Permalink
Merge pull request #54 from bu-ist/hotfix/phpunit-test-fix
Browse files Browse the repository at this point in the history
Hotfix/Fix phpunit tests
  • Loading branch information
jdub233 authored Aug 13, 2020
2 parents b3be27b + e047c93 commit a11b13b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 44 deletions.
72 changes: 42 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
language: php

sudo: false
dist: trusty

language: php

php:
- 5.6
- 7.0
- 7.1
notifications:
email:
on_success: never
on_failure: change

env:
- WP_VERSION=nightly
- WP_VERSION=latest
- WP_VERSION=4.7
- WP_VERSION=4.6
branches:
only:
- /.*/

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

before_install:
- composer self-update

install:
- composer install --prefer-dist
matrix:
include:
- php: 7.4
env: WP_VERSION=latest
- php: 7.4
env: WP_VERSION=5.4.2
- php: 7.2
env: WP_VERSION=latest
- php: 7.2
env: WP_VERSION=5.4.2
- php: 7.0
env: WP_VERSION=latest
- php: 7.0
env: WP_VERSION=5.4.2

before_script:
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- |
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
composer global require "phpunit/phpunit=5.7.*"
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
phpenv config-rm xdebug.ini
else
composer global require "phpunit/phpunit=4.8.*"
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
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
composer global require wp-coding-standards/wpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
fi
- git config --global user.email "[email protected]"
- git config --global user.name "Travis CI"
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
script:
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
after_script:
- ./bin/codeclimate.sh

addons:
codeclimate:
repo_token: CODECLIMATE_REPO_TOKEN
- |
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
phpcs
fi
47 changes: 36 additions & 11 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${6-false}

WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
TMPDIR=${TMPDIR-/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}

download() {
if [ `which curl` ]; then
Expand All @@ -23,8 +25,15 @@ download() {
fi
}

if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
WP_TESTS_TAG="tags/$WP_VERSION"
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
WP_TESTS_TAG="branches/$WP_VERSION"
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
WP_TESTS_TAG="tags/${WP_VERSION%??}"
else
WP_TESTS_TAG="tags/$WP_VERSION"
fi
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
WP_TESTS_TAG="trunk"
else
Expand All @@ -50,18 +59,34 @@ install_wp() {
mkdir -p $WP_CORE_DIR

if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
mkdir -p /tmp/wordpress-nightly
download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
mkdir -p $TMPDIR/wordpress-nightly
download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip
unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
else
if [ $WP_VERSION == 'latest' ]; then
local ARCHIVE_NAME='latest'
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
# https serves multiple offers, whereas http serves single.
download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
LATEST_VERSION=${WP_VERSION%??}
else
# otherwise, scan the releases and get the most up to date minor version of the major release
local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
fi
if [[ -z "$LATEST_VERSION" ]]; then
local ARCHIVE_NAME="wordpress-$WP_VERSION"
else
local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
fi
else
local ARCHIVE_NAME="wordpress-$WP_VERSION"
fi
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
fi

download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
Expand All @@ -80,7 +105,7 @@ install_test_suite() {
# set up testing suite
mkdir -p $WP_TESTS_DIR
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/images/ $WP_TESTS_DIR/data/images
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi

if [ ! -f wp-tests-config.php ]; then
Expand Down
2 changes: 1 addition & 1 deletion bu-navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Author: Boston University (IS&T)
Author URI: http://sites.bu.edu/web/
Description: Provides alternative navigation elements designed for blogs with large page counts
Version: 1.2.15
Version: 1.2.18
Text Domain: bu-navigation
Domain Path: /languages
*/
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bu-navigation",
"version": "1.2.11",
"version": "1.2.18",
"description": "Provides alternative navigation elements designed for blogs with large page counts",
"main": "bu-navigation.php",
"directories": {
Expand Down

0 comments on commit a11b13b

Please sign in to comment.