Skip to content
Permalink
Browse files

Fixed an issue that Codeception did not run on Travis due to recent c…

…hanges on the Codeception builds.
  • Loading branch information...
michaeluno committed Feb 24, 2019
1 parent 90a18d5 commit 813b7b6e21e5ce3040c3106922063291b63ffbf7
@@ -15,6 +15,9 @@
*.old
*.bak

# PHP script files
*.phar

# Temporary directories.
*/_del/
*/_old/
@@ -13,6 +13,9 @@ php:

- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

# HHVM is disabled because wp-cli causes an error.
# - hhvm
@@ -1,5 +1,8 @@
Change Log

### 1.1.2 - 2019/02/23
- Fixed an issue that has no longer been able to run on Travis tests against PHP 5.6 by changing the Codeception version to v2.5.4 for the PHP 5.x build.

### 1.1.1
- Added some environment variables in the settings, accessible within the script and processes run from it.
- Made the setting variable accessible from PHP test code.
@@ -5,19 +5,24 @@ downloadCodeception() {
# For other versions @see https://codeception.com/builds
# download "http://codeception.com/codecept.phar" "$1"

# v2.5.4 for PHP 5.6
# v2.5.4 (stable as of 2019/02/23)
# download "http://codeception.com/releases/2.5.4/codecept.phar" "$1"

# v2.5.1 ~ v2.5.4 for PHP 5.6 causes an error PHP Warning: require_once(phar://codecept.phar/autoload.php): failed to open st ream: phar error: invalid url or non-existent phar "phar://codecept.phar/autoload. ...\codecept.phar on line 5
# Maybe related @see https://github.com/Codeception/Codeception/issues/4875
download "https://codeception.com/releases/2.5.4/php54/codecept.phar" "$1"
# download "https://codeception.com/releases/2.5.1/php54/codecept.phar" "$1"

# v2.5.1 (stable as of 2018/11/01) -> does not run on Travis tests against PHP 5.6
# download "http://codeception.com/releases/2.5.1/codecept.phar" "$1"

# v2.5.0
# download "https://codeception.com/releases/2.5.0/codecept.phar" "$1"

# v2.4.5 -> PHP Warning: Cannot declare class PHPUnit_Framework_TestCase, because the name is already in use in ...\wordpress-tests-lib\includes\phpunit6-compat.php
# v2.4.5 -> PHP Warning: Cannot declare class PHPUnit_Framework_TestCase, because the name is already in use in ...\wordpress-tests-lib\includes\phpunit6-compat.php
# download "https://codeception.com/releases/2.4.5/codecept.phar" "$1"

# v2.3.9 -> PHP Warning: Cannot declare class PHPUnit_Framework_TestCase, because the name is already in use in ...\wordpress-tests-lib\includes\phpunit6-compat.php
# v2.3.9 -> PHP Warning: Cannot declare class PHPUnit_Framework_TestCase, because the name is already in use in ...\wordpress-tests-lib\includes\phpunit6-compat.php
# download "https://codeception.com/releases/2.3.9/codecept.phar" "$1"

# v2.2.12 -> with PHP 7.2 [PHPUnit_Framework_Exception] count(): Parameter must be an array or an object that implements Countable
@@ -49,7 +54,8 @@ downloadCodeception() {
exit 1
fi
# Output the version in case an error occurs.
php "$1" --version
# Codeception Builds for PHP 5.x has been not able to call the file with absolute path
# php "$1" --version

# c3
# @see https://github.com/Codeception/c3
@@ -2,7 +2,7 @@

# Script information
SCRIPT_NAME="WordPress Plugin The Test Suite Installer"
SCRIPT_VERSION="1.0.1"
SCRIPT_VERSION="1.1.2"

# Scripts defining custom functions
source $(dirname $0)/include/download.sh
@@ -58,7 +58,8 @@ cd "$WORKING_DIR"

TEMP=$([ -z "${TEMP}" ] && echo "/tmp" || echo "$TEMP")
WP_CLI="$TEMP/wp-cli.phar"
CODECEPT="$TEMP/codecept.phar"
CODECEPTFILENAME="codecept.phar"
CODECEPT="$TEMP/$CODECEPTFILENAME"
C3="$TEMP/c3.php"
TEMP_PROJECT_DIR="$TEMP/$PROJECT_SLUG"

@@ -306,7 +307,9 @@ installCodeception() {

# Run the bootstrap to generate necessary files.
echo Creating Codeception configuration files.
php "$CODECEPT" bootstrap "$WP_TEST_DIR/wp-content/plugins/$PROJECT_SLUG/test/"
cd "$TEMP"
php $CODECEPTFILENAME bootstrap "$WP_TEST_DIR/wp-content/plugins/$PROJECT_SLUG/test/"
cd "$WORKING_DIR"

# Restore the global configuration distribution file. (codeception.dist.yml)
mv "$CONFIG_DIST_FILE_BACKUP" "$CONFIG_DIST_FILE"
@@ -354,9 +357,14 @@ EOM
}

# Download necessary applications
downloadWPCLI "$WP_CLI"
downloadCodeception "$CODECEPT"
evacuateProjectFiles
echo Downloading WP-CLI
downloadWPCLI "$WP_CLI"
echo Downloading Codeception
downloadCodeception "$CODECEPT"
cd "$TEMP"
php "$CODECEPTFILENAME" --version
cd "$WORKING_DIR"
evacuateProjectFiles

# Install components
if [[ REINSTALL_PROJECT_FILES -ne 1 ]]; then
@@ -23,9 +23,9 @@ do
printVersion
exit 1
;;
l)
l)
COVERAGE_FILE_PATH=$OPTARG
;;
;;
c)
CONFIGURATION_FILE_PATH=$OPTARG
;;
@@ -45,13 +45,13 @@ fi
source "$CONFIGURATION_FILE_PATH"
echo "Using the configuration file: $CONFIGURATION_FILE_PATH"

# Set up variables
# Set up variables
TEMP=$([ -z "${TEMP}" ] && echo "/tmp" || echo "$TEMP")
CODECEPT="$TEMP/codecept.phar"

# convert any Windows path to linux/unix path to be usable for some path related commands such as basename
cd "$WP_TEST_DIR"
WP_TEST_DIR=$(pwd)
WP_TEST_DIR=$(pwd)
CODECEPT_TEST_DIR="$WP_TEST_DIR/wp-content/plugins/$PROJECT_SLUG/test"

echo "Project Slug: $PROJECT_SLUG"
@@ -61,6 +61,10 @@ set -ex

# Make sure Codeception is installed
downloadCodeception "$CODECEPT"
## Codeception PHP 5.x Build has not been able to call the phar file absolute path since around January 2019
cp "$CODECEPT" codecept.phar
CODECEPT=codecept.phar
php $CODECEPT --version

# Check if the codecemption configuration file exists.
if [ ! -f "$CODECEPT_TEST_DIR/codeception.yml" ]; then
@@ -72,19 +76,19 @@ fi
# @usage php codecept run -c /path/to/my/project
# @see http://codeception.com/install
# @bug the --steps option makes the coverage not being generated
if [[ $WP_MULTISITE = 1 ]]; then
if [[ $WP_MULTISITE = 1 ]]; then
echo "Testing against a multi-site."
OPTION_SKIP_GROUP=
OPTION_GROUP="--group multisite --group ms-files"
else
echo "Testing against a normal site."
OPTION_SKIP_GROUP="--skip-group multisite"
OPTION_GROUP=
fi
fi
if [[ ! -z "$COVERAGE_FILE_PATH" ]]; then
OPTION_COVERAGE="--coverage-xml"
OPTION_COVERAGE="--coverage-xml --coverage-html"
else
else
OPTION_COVERAGE=
fi

@@ -108,7 +112,7 @@ if [[ ! -z "$COVERAGE_FILE_PATH" ]]; then
echo "Copying the xml coverage file to the specified location."
cd "$WORKING_DIR"
cp -f "$GENERATED_COVERAGE_XML_FILE_PATH" "$COVERAGE_FILE_PATH"
fi
fi
fi

echo "Tests have completed!"
@@ -64,6 +64,10 @@ echo "Coverage File Path: $COVERAGE_FILE_PATH"

# Make sure Codeception is installed
downloadCodeception "$CODECEPT"
## Codeception PHP 5.x Build has not been able to call the phar file absolute path since around January 2019
cp "$CODECEPT" codecept.phar
CODECEPT=codecept.phar
php $CODECEPT --version

# Check if the codecemption configuration file exists.
if [ ! -f "$CODECEPT_TEST_DIR/codeception.yml" ]; then
@@ -63,6 +63,10 @@ echo "Coverage File Path: $COVERAGE_FILE_PATH"

# Make sure Codeception is installed
downloadCodeception "$CODECEPT"
## Codeception PHP 5.x Build has not been able to call the phar file absolute path since around January 2019
cp "$CODECEPT" codecept.phar
CODECEPT=codecept.phar
php $CODECEPT --version

# Check if the codecemption configuration file exists.
if [ ! -f "$CODECEPT_TEST_DIR/codeception.yml" ]; then
@@ -63,6 +63,10 @@ echo "Coverage File Path: $COVERAGE_FILE_PATH"

# Make sure Codeception is installed
downloadCodeception "$CODECEPT"
## Codeception PHP 5.x Build has not been able to call the phar file absolute path since around January 2019
cp "$CODECEPT" codecept.phar
CODECEPT=codecept.phar
php $CODECEPT --version

# Check if the codecemption configuration file exists.
if [ ! -f "$CODECEPT_TEST_DIR/codeception.yml" ]; then
@@ -1,30 +1,30 @@
# Using export so that test php scripts can access these values with `getenv()`.

# Script settings
export PROJECT_SLUG="sample-tdd-plugin"
export PROJECT_SLUG="plugin-template"
export PROJECT_TITLE="Plugin Template"
export PROJECT_MAIN_FILE="plugin-template.php"

# The repository root directory. Leave it empty to automatically set. '../' will be set in that case.
export PROJECT_DIR=""

# Database settings
export DB_NAME="sample-tdd-plugin-test"
export DB_USER="root"
export DB_PASS="root"
export DB_NAME="test-${PROJECT_SLUG}"
export DB_USER=""
export DB_PASS=""
export DB_HOST="localhost"
export WP_VERSION="latest"
export WP_TABLE_PREFIX="wptests_"

# Site settings
export WP_TEST_DIR="/test_wp/test-sample-tdd=plugin"
export WP_URL="http://localhost/test_wp/test-sample-tdd=plugin"
export WP_TEST_DIR="Z:/htdocs/test-${PROJECT_SLUG}"
export WP_URL="http://localhost/test-${PROJECT_SLUG}"
export WP_ADMIN_USER_NAME="admin"
export WP_ADMIN_PASSWORD="admin"
export WP_ADMIN_EMAIL="wpplugins@michaeluno.jp"
export WP_SITE_TITLE="Testing Sample TDD Plugin"
export WP_ADMIN_EMAIL="test@your-domain.com"
export WP_SITE_TITLE="Testing ${PROJECT_TITLE}"

# Installing plugin slug hosted on wordperss.org, the path to a local zip file, or URL to a remote zip file.
# Do nto use `export` for these.
# INSTALL_PLUGINS[0]="http://downloads.wordpress.org/plugin/admin-page-framework.latest-stable.zip"
# INSTALL_PLUGINS[1]='...' // add more like so

@@ -1,27 +1,31 @@
# Script Settings

# The plugin slug
PROJECT_SLUG="admin-page-framework"
export PROJECT_SLUG="admin-page-framework"
export PROJECT_TITLE="Admin Page Framework"
export PROJECT_MAIN_FILE="admin-page-framework-loader.php"
# The repository root directory. Leave it empty to automatically set. '../' will be set in that case.
PROJECT_DIR="./"
export PROJECT_DIR="./"

# Database Settings
DB_NAME="test-admin-page-framework"
DB_USER="root"
DB_PASS=""
DB_HOST="127.0.0.1"
WP_VERSION="latest"
export DB_NAME="test-${PROJECT_SLUG}"
export DB_USER="root"
export DB_PASS=""
export DB_HOST="127.0.0.1"
export WP_VERSION="latest"
export WP_TABLE_PREFIX="wptests_"

# Site Settings
WP_TEST_DIR="./test-admin-page-framework"
WP_URL="http://127.0.0.1:4000/test-admin-page-framework/"
WP_ADMIN_USER_NAME="admin"
WP_ADMIN_PASSWORD="admin"
WP_ADMIN_EMAIL="admin-page-framework@michaeluno.jp"
WP_SITE_TITLE="Testing Admin Page Framework on Travis CI"
# Site settings
export WP_TEST_DIR="./test-admin-page-framework"
export WP_URL="http://127.0.0.1:4000/test-${PROJECT_SLUG}"
export WP_ADMIN_USER_NAME="admin"
export WP_ADMIN_PASSWORD="admin"
export WP_ADMIN_EMAIL="admin-page-framework@michaeluno.jp"
export WP_SITE_TITLE="Testing ${PROJECT_TITLE} on Travis CI"

# Installing plugin slug hosted on wordperss.org, the path to a local zip file, or URL to a remote zip file.
;INSTALL_PLUGINS[0]="http://downloads.wordpress.org/plugin/admin-page-framework.latest-stable.zip"
# INSTALL_PLUGINS[1]='...' // add more like so
# INSTALL_PLUGINS[0]="http://downloads.wordpress.org/plugin/admin-page-framework.latest-stable.zip"
# INSTALL_PLUGINS[1]='...' // add more like so

# Overriding Environment Variable
# WP_MULTISITE=0
# export WP_MULTISITE=0

0 comments on commit 813b7b6

Please sign in to comment.
You can’t perform that action at this time.