update dev environment
All checks were successful
continuous-integration/drone/push Build is passing

* remove remaining Robo calls from Composer scripts
* update WP test bootstrap
* update dev dependencies
This commit is contained in:
Stefan Kalscheuer 2021-10-18 19:55:42 +02:00
parent caf471d3bf
commit e607ae270f
4 changed files with 58 additions and 33 deletions

View File

@ -23,7 +23,7 @@ jobs:
- name: Setup WP - name: Setup WP
run: bash bin/install-wp-tests.sh wordpress root root localhost "${{ matrix.wordpress }}" run: bash bin/install-wp-tests.sh wordpress root root localhost "${{ matrix.wordpress }}"
- name: Install - name: Install
run: composer install run: composer install --no-interaction
- name: Test - name: Test
run: composer test run: composer test

View File

@ -15,7 +15,7 @@ SKIP_DB_CREATE=${6-false}
TMPDIR=${TMPDIR-/tmp} TMPDIR=${TMPDIR-/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/} WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress}
download() { download() {
if [ `which curl` ]; then if [ `which curl` ]; then
@ -25,7 +25,11 @@ download() {
fi fi
} }
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
WP_BRANCH=${WP_VERSION%\-*}
WP_TESTS_TAG="branches/$WP_BRANCH"
elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
WP_TESTS_TAG="branches/$WP_VERSION" WP_TESTS_TAG="branches/$WP_VERSION"
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
@ -47,7 +51,6 @@ else
fi fi
WP_TESTS_TAG="tags/$LATEST_VERSION" WP_TESTS_TAG="tags/$LATEST_VERSION"
fi fi
set -ex set -ex
install_wp() { install_wp() {
@ -59,10 +62,10 @@ install_wp() {
mkdir -p $WP_CORE_DIR mkdir -p $WP_CORE_DIR
if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
mkdir -p $TMPDIR/wordpress-nightly mkdir -p $TMPDIR/wordpress-trunk
download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip rm -rf $TMPDIR/wordpress-trunk/*
unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/ svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress
mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR
else else
if [ $WP_VERSION == 'latest' ]; then if [ $WP_VERSION == 'latest' ]; then
local ARCHIVE_NAME='latest' local ARCHIVE_NAME='latest'
@ -104,8 +107,9 @@ install_test_suite() {
if [ ! -d $WP_TESTS_DIR ]; then if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite # set up testing suite
mkdir -p $WP_TESTS_DIR mkdir -p $WP_TESTS_DIR
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes rm -rf $WP_TESTS_DIR/{includes,data}
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi fi
if [ ! -f wp-tests-config.php ]; then if [ ! -f wp-tests-config.php ]; then
@ -113,6 +117,7 @@ install_test_suite() {
# remove all forward slashes in the end # remove all forward slashes in the end
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s:__DIR__ . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
@ -121,6 +126,23 @@ install_test_suite() {
} }
recreate_db() {
shopt -s nocasematch
if [[ $1 =~ ^(y|yes)$ ]]
then
mysqladmin drop $DB_NAME -f --user="$DB_USER" --password="$DB_PASS"$EXTRA
create_db
echo "Recreated the database ($DB_NAME)."
else
echo "Leaving the existing database ($DB_NAME) in place."
fi
shopt -u nocasematch
}
create_db() {
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}
install_db() { install_db() {
if [ ${SKIP_DB_CREATE} = "true" ]; then if [ ${SKIP_DB_CREATE} = "true" ]; then
@ -144,7 +166,14 @@ install_db() {
fi fi
# create database # create database
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ]
then
echo "Reinstalling will delete the existing test database ($DB_NAME)"
read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB
recreate_db $DELETE_EXISTING_DB
else
create_db
fi
} }
install_wp install_wp

View File

@ -18,16 +18,16 @@
"type": "wordpress-plugin", "type": "wordpress-plugin",
"require": { "require": {
"php": ">=5.6", "php": ">=5.6",
"composer/installers": "~1.7" "composer/installers": "~1.12"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5|^6|^7",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7", "dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"matthiasmullie/minify": "^1.3",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^5|^6|^7",
"slowprog/composer-copy-file": "~0.3", "slowprog/composer-copy-file": "~0.3",
"squizlabs/php_codesniffer": "^3.6", "squizlabs/php_codesniffer": "^3.6",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"wp-coding-standards/wpcs": "^2.3", "wp-coding-standards/wpcs": "^2.3",
"matthiasmullie/minify": "^1.3",
"yoast/phpunit-polyfills": "^1.0" "yoast/phpunit-polyfills": "^1.0"
}, },
"scripts": { "scripts": {
@ -38,16 +38,7 @@
"@minify" "@minify"
], ],
"build": [ "build": [
"@minify", "@minify"
"robo build"
],
"package": [
"@minify",
"robo package"
],
"deploy": [
"@minify",
"robo deploy:all"
], ],
"test": [ "test": [
"phpunit" "phpunit"

View File

@ -1,25 +1,29 @@
<?php <?php
/** /**
* PHPUnit bootstrap file * PHPUnit bootstrap file.
* *
* @package SCLiveticker * @package SCLiveticker
*/ */
require_once __DIR__ . '/../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
$_tests_dir = getenv( 'WP_TESTS_DIR' ); $_tests_dir = getenv( 'WP_TESTS_DIR' );
if ( ! $_tests_dir ) { if ( ! $_tests_dir ) {
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; $_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
} }
if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) { // Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file.
echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?"; $_phpunit_polyfills_path = getenv( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' );
if ( false !== $_phpunit_polyfills_path ) {
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path );
}
if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit( 1 ); exit( 1 );
} }
// Give access to tests_add_filter() function. // Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php'; require_once "{$_tests_dir}/includes/functions.php";
/** /**
* Manually load the plugin being tested. * Manually load the plugin being tested.
@ -27,7 +31,8 @@ require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin() { function _manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/stklcode-liveticker.php'; require dirname( dirname( __FILE__ ) ) . '/stklcode-liveticker.php';
} }
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
// Start up the WP testing environment. // Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php'; require "{$_tests_dir}/includes/bootstrap.php";