Skip to content

Commit

Permalink
Import theme data to the test site
Browse files Browse the repository at this point in the history
Data url obtained from the official docs, here: https://codex.wordpress.org/Theme_Unit_Test
  • Loading branch information
Vicente Canales committed Jun 7, 2023
1 parent fc9f3e1 commit 605e862
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TMPDIR=${TMPDIR-/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress}
WP_CLI_CMD=$WP_CORE_DIR/wp-cli.phar

download() {
if [ `which curl` ]; then
Expand Down Expand Up @@ -93,6 +94,8 @@ install_wp() {
fi

download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
download https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar $WP_CORE_DIR/wp-cli.phar
chmod +x $WP_CORE_DIR/wp-cli.phar
}

install_test_suite() {
Expand Down Expand Up @@ -176,6 +179,27 @@ install_db() {
fi
}


# downloads and imports theme unit test data
# from https://github.com/WPTT/theme-test-data/blob/master/themeunittestdata.wordpress.xml
import_theme_data() {
# download theme unit test data if it doesn't exist
if [ ! -f $WP_CORE_DIR/wp-content/themes/themeunittestdata.wordpress.xml ]; then
download https://raw.githubusercontent.com/WPTT/theme-test-data/master/themeunittestdata.wordpress.xml $WP_CORE_DIR/wp-content/themes/themeunittestdata.wordpress.xml
fi
WP_ADMIN_EMAIL='themeshaperwp+demos@gmail.com'
# install site
$WP_CLI_CMD core install --url=$WP_URL --title=$WP_TITLE --admin_user=$WP_ADMIN_USER --admin_password=$WP_ADMIN_PASS --admin_email=$WP_ADMIN_EMAIL --path=$WP_CORE_DIR
# create wp-config file
if [ ! -f $WP_CORE_DIR/wp-config.php ]; then
$WP_CLI_CMD core config --dbname=$DB_NAME --dbuser=$DB_USER --dbpass=$DB_PASS --dbhost=$DB_HOST --path=$WP_CORE_DIR
fi
# use wp cli to import the theme unit test data
$WP_CLI_CMD plugin install wordpress-importer --activate --path=$WP_CORE_DIR
$WP_CLI_CMD import $WP_CORE_DIR/wp-content/themes/themeunittestdata.wordpress.xml --authors=create --path=$WP_CORE_DIR
}

install_wp
install_test_suite
install_db
import_theme_data

0 comments on commit 605e862

Please sign in to comment.