mirror of
https://ghproxy.net/https://github.com/elementor/activity-log.git
synced 2025-10-04 15:35:59 +08:00
Added Travis files
This commit is contained in:
parent
c7edc4a6fe
commit
1f0ef16594
3 changed files with 92 additions and 40 deletions
45
.travis.yml
45
.travis.yml
|
@ -5,46 +5,17 @@ language: php
|
|||
|
||||
# PHP version used in first build configuration.
|
||||
php:
|
||||
- "5.5"
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
# WordPress version used in first build configuration.
|
||||
env:
|
||||
- WP_VERSION=master
|
||||
- WP_VERSION=latest WP_MULTISITE=0
|
||||
- WP_VERSION=latest WP_MULTISITE=1
|
||||
- WP_VERSION=3.8.3 WP_MULTISITE=0
|
||||
- WP_VERSION=3.8.3 WP_MULTISITE=1
|
||||
|
||||
# Next we define our matrix of additional build configurations to test against.
|
||||
# The versions listed above will automatically create our first configuration,
|
||||
# so it doesn't need to be re-defined below.
|
||||
|
||||
# WP_VERSION specifies the tag to use. The way these tests are configured to run
|
||||
# requires at least WordPress 3.8. Specify "master" to test against SVN trunk.
|
||||
|
||||
# Note that Travis CI supports listing these above to automatically build a
|
||||
# matrix of configurations, but we're being nice here by manually building a
|
||||
# total of four configurations even though we're testing 4 versions of PHP
|
||||
# along with 2 versions of WordPress (which would build 8 configs otherwise).
|
||||
# This takes half as long to run while still providing adequate coverage.
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: "5.3"
|
||||
env: WP_VERSION=master
|
||||
- php: "5.4"
|
||||
env: WP_VERSION=3.8.1
|
||||
- php: "5.2"
|
||||
env: WP_VERSION=3.8.1
|
||||
|
||||
# Clones WordPress and configures our testing environment.
|
||||
before_script:
|
||||
- export PLUGIN_SLUG=$(basename $(pwd))
|
||||
- git clone --depth=50 --branch="$WP_VERSION" git://develop.git.wordpress.org/ /tmp/wordpress
|
||||
- cd ..
|
||||
- mv "$PLUGIN_SLUG" "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
|
||||
- cd /tmp/wordpress
|
||||
- mysql -e "CREATE DATABASE wordpress_tests;" -uroot
|
||||
- cp wp-tests-config-sample.php wp-tests-config.php
|
||||
- sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
|
||||
- sed -i "s/yourusernamehere/travis/" wp-tests-config.php
|
||||
- sed -i "s/yourpasswordhere//" wp-tests-config.php
|
||||
- cd "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
|
||||
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
|
||||
|
||||
script: phpunit
|
||||
script: phpunit
|
78
bin/install-wp-tests.sh
Normal file
78
bin/install-wp-tests.sh
Normal file
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DB_NAME=$1
|
||||
DB_USER=$2
|
||||
DB_PASS=$3
|
||||
DB_HOST=${4-localhost}
|
||||
WP_VERSION=${5-master}
|
||||
|
||||
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
||||
WP_CORE_DIR=/tmp/wordpress/
|
||||
|
||||
set -ex
|
||||
|
||||
install_wp() {
|
||||
mkdir -p $WP_CORE_DIR
|
||||
|
||||
if [ $WP_VERSION == 'latest' ]; then
|
||||
local ARCHIVE_NAME='latest'
|
||||
else
|
||||
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
||||
fi
|
||||
|
||||
wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
|
||||
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
||||
|
||||
wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
|
||||
}
|
||||
|
||||
install_test_suite() {
|
||||
# portable in-place argument for both GNU sed and Mac OSX sed
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
local ioption='-i ""'
|
||||
else
|
||||
local ioption='-i'
|
||||
fi
|
||||
|
||||
# set up testing suite
|
||||
mkdir -p $WP_TESTS_DIR
|
||||
cd $WP_TESTS_DIR
|
||||
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
|
||||
|
||||
wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
|
||||
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
|
||||
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
|
||||
sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
|
||||
sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
|
||||
sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
|
||||
}
|
||||
|
||||
install_db() {
|
||||
# parse DB_HOST for port or socket references
|
||||
local PARTS=(${DB_HOST//\:/ })
|
||||
local DB_HOSTNAME=${PARTS[0]};
|
||||
local DB_SOCK_OR_PORT=${PARTS[1]};
|
||||
local EXTRA=""
|
||||
|
||||
if ! [ -z $DB_HOSTNAME ] ; then
|
||||
if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
|
||||
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
||||
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
||||
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
||||
elif ! [ -z $DB_HOSTNAME ] ; then
|
||||
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
||||
fi
|
||||
fi
|
||||
|
||||
# create database
|
||||
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
|
||||
}
|
||||
|
||||
install_wp
|
||||
install_test_suite
|
||||
install_db
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
|
||||
// Create our own test case to prevent repeating ourself
|
||||
require_once getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php';
|
||||
$_tests_dir = getenv( 'WP_TESTS_DIR' );
|
||||
if ( ! $_tests_dir )
|
||||
$_tests_dir = '/tmp/wordpress-tests-lib';
|
||||
|
||||
require_once $_tests_dir . '/includes/functions.php';
|
||||
|
||||
tests_add_filter(
|
||||
'muplugins_loaded',
|
||||
|
@ -19,4 +22,4 @@ tests_add_filter(
|
|||
// Do this action last
|
||||
tests_add_filter( 'shutdown', 'drop_tables', 999999 );
|
||||
|
||||
require getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/bootstrap.php';
|
||||
require $_tests_dir . '/includes/bootstrap.php';
|
Loading…
Add table
Add a link
Reference in a new issue