mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 10:46:11 +09:00
Add tests files
This commit is contained in:
@@ -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