mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Add tests files
This commit is contained in:
+71
-17
@@ -1,27 +1,81 @@
|
|||||||
|
# Travis CI Configuration File
|
||||||
|
|
||||||
sudo: false
|
# Tell Travis CI we're using PHP
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
notifications:
|
# Setup a global environment and overide as needed
|
||||||
on_success: never
|
|
||||||
on_failure: change
|
|
||||||
|
|
||||||
php:
|
|
||||||
- nightly # PHP 7.0
|
|
||||||
- 5.6
|
|
||||||
- 5.5
|
|
||||||
- 5.4
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- WP_PROJECT_TYPE=plugin WP_VERSION=latest WP_MULTISITE=0 WP_TEST_URL=http://localhost:12000 WP_TEST_USER=test WP_TEST_USER_PASS=test
|
global:
|
||||||
|
- WP_TRAVISCI=phpunit
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.composer/cache/files
|
||||||
|
- $HOME/.cache/yarn
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# Test WP trunk/master and two latest versions on minimum (5.2).
|
||||||
|
# Test WP latest two versions (4.5, 4.3) on most popular (5.5, 5.6).
|
||||||
|
# Test WP latest stable (4.5) on other supported PHP (5.3, 5.4).
|
||||||
|
# Test WP trunk/master on edge platforms (7.0, PHP nightly).
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
|
include:
|
||||||
|
- env: WP_TRAVISCI="yarn lint"
|
||||||
|
- env: WP_TRAVISCI="yarn test-client"
|
||||||
|
- env: WP_TRAVISCI="yarn test-gui"
|
||||||
|
- php: "5.2"
|
||||||
|
- php: "5.3"
|
||||||
|
- php: "5.5"
|
||||||
|
- php: "5.6"
|
||||||
|
- php: "7.0"
|
||||||
|
- php: "7.1"
|
||||||
|
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: nightly
|
- php: "7.1"
|
||||||
|
# - php: "nightly"
|
||||||
|
|
||||||
|
# whitelist branches for the "push" build check.
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
#- master-stable
|
||||||
|
#- /^branch-.*$/
|
||||||
|
#- feature/*
|
||||||
|
|
||||||
|
# Clones WordPress and configures our testing environment.
|
||||||
before_script:
|
before_script:
|
||||||
- git clone https://github.com/Seravo/wordpress-test-template wp-tests
|
- phpenv config-rm xdebug.ini
|
||||||
- bash wp-tests/bin/install-wp-tests.sh test root '' localhost $WP_VERSION
|
- export PLUGIN_SLUG=$(basename $(pwd))
|
||||||
|
- source ~/.nvm/nvm.sh
|
||||||
|
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
||||||
|
- |
|
||||||
|
if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then
|
||||||
|
composer global require "phpunit/phpunit=5.7.*"
|
||||||
|
elif [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then
|
||||||
|
composer global require "phpunit/phpunit=4.8.*"
|
||||||
|
fi
|
||||||
|
- nvm install 6
|
||||||
|
- nvm use 6
|
||||||
|
- ./tests/prepare-wordpress.sh
|
||||||
|
- mysql -e "set global wait_timeout = 3600;"
|
||||||
|
|
||||||
#script:
|
script:
|
||||||
# - cd wp-tests/spec && bundle exec rspec test.rb
|
- ./tests/run-travis.sh
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
# We need notifications for successful builds
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
webhooks: https:/ultimatemember.com/travis.php
|
||||||
|
email:
|
||||||
|
- heychampsupertramp@gmail.com
|
||||||
|
# Encrypted Slack notification address.
|
||||||
|
- secure: "WQdTdmYuifSW0hiJGXpQGKystMASC50QvxHlyUL5SM3h5GP8aCgeSsHuXvKPe3dT3Pffhk0dSHBfDtdWFwSHW/upURhg0vs4dm7+nxxvGZiTPzKcuAIjgvCoqWM7teyda/XqFGNSnv+XsT34uoyPhhFgd45T3oS+QQ3aNCruFak="
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt( $ch, CURLOPT_URL, 'https://api.wordpress.org/core/version-check/1.7/' );
|
||||||
|
|
||||||
|
// Set so curl_exec returns the result instead of outputting it.
|
||||||
|
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||||
|
|
||||||
|
// Get the response and close the channel.
|
||||||
|
$response = curl_exec( $ch );
|
||||||
|
curl_close( $ch );
|
||||||
|
|
||||||
|
$versions = json_decode( $response );
|
||||||
|
$versions = $versions->offers;
|
||||||
|
|
||||||
|
// Sorting available WordPress offers by version number
|
||||||
|
function offer_version_sort( $first, $second ) {
|
||||||
|
return version_compare( $first->version, $second->version, '<' );
|
||||||
|
}
|
||||||
|
|
||||||
|
uasort( $versions, 'offer_version_sort' );
|
||||||
|
|
||||||
|
$version_stack = array();
|
||||||
|
|
||||||
|
foreach( $versions as $offer ) {
|
||||||
|
list( $major, $minor ) = explode( '.', $offer->version );
|
||||||
|
|
||||||
|
$base = $major . '.' . $minor;
|
||||||
|
|
||||||
|
if (
|
||||||
|
! isset( $version_stack[ $base ] )
|
||||||
|
|| version_compare( $offer->version, $version_stack[ $base ] ) ) {
|
||||||
|
|
||||||
|
// There is no version like this yet or there is a newer patch to this major version
|
||||||
|
$version_stack[ $base ] = $offer->version;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( count( $version_stack ) === 2 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$wp_versions = array_values( $version_stack );
|
||||||
|
|
||||||
|
if ( empty( $argv[1] ) ) {
|
||||||
|
print $wp_versions[0] . "\n";
|
||||||
|
} else if ( '--previous' === $argv[1] ) {
|
||||||
|
print $wp_versions[1] . "\n";
|
||||||
|
} else {
|
||||||
|
die(
|
||||||
|
"Unknown argument: " . $argv[1] . "\n"
|
||||||
|
. "Use with no arguments to get the latest stable WordPress version, or use `--previous' to get the previous stable major release.\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# If this is an NPM environment test we don't need a developer WordPress checkout
|
||||||
|
|
||||||
|
if [ "$WP_TRAVISCI" != "phpunit" ]; then
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This prepares a developer checkout of WordPress for running the test suite on Travis
|
||||||
|
|
||||||
|
mysql -u root -e "CREATE DATABASE wordpress_tests;"
|
||||||
|
|
||||||
|
CURRENT_DIR=$(pwd)
|
||||||
|
|
||||||
|
for WP_SLUG in 'master' 'latest' 'previous'; do
|
||||||
|
echo "Preparing $WP_SLUG WordPress...";
|
||||||
|
|
||||||
|
cd $CURRENT_DIR/..
|
||||||
|
|
||||||
|
case $WP_SLUG in
|
||||||
|
master)
|
||||||
|
git clone --depth=1 --branch master git://develop.git.wordpress.org/ /tmp/wordpress-master
|
||||||
|
;;
|
||||||
|
latest)
|
||||||
|
git clone --depth=1 --branch `php ./$PLUGIN_SLUG/tests/get-wp-version.php` git://develop.git.wordpress.org/ /tmp/wordpress-latest
|
||||||
|
;;
|
||||||
|
previous)
|
||||||
|
git clone --depth=1 --branch `php ./$PLUGIN_SLUG/tests/get-wp-version.php --previous` git://develop.git.wordpress.org/ /tmp/wordpress-previous
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
cp -r $PLUGIN_SLUG "/tmp/wordpress-$WP_SLUG/src/wp-content/plugins/$PLUGIN_SLUG"
|
||||||
|
cd /tmp/wordpress-$WP_SLUG
|
||||||
|
|
||||||
|
cp wp-tests-config-sample.php wp-tests-config.php
|
||||||
|
sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
|
||||||
|
sed -i "s/yourusernamehere/root/" wp-tests-config.php
|
||||||
|
sed -i "s/yourpasswordhere//" wp-tests-config.php
|
||||||
|
|
||||||
|
echo "Done!";
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0;
|
||||||
Reference in New Issue
Block a user