Skip to content

Commit

Permalink
Make setting up tests easier
Browse files Browse the repository at this point in the history
  • Loading branch information
tlovett1 committed Aug 14, 2019
1 parent 998eb0c commit 7217835
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DB_USER=$2
DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${6-false}
CREATE_DB_IF_EXISTS=${6-false}

TMPDIR=${TMPDIR-/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
Expand Down Expand Up @@ -126,10 +126,6 @@ install_test_suite() {

install_db() {

if [ ${SKIP_DB_CREATE} = "true" ]; then
return 0
fi

# parse DB_HOST for port or socket references
local PARTS=(${DB_HOST//\:/ })
local DB_HOSTNAME=${PARTS[0]};
Expand All @@ -146,10 +142,15 @@ install_db() {
fi
fi

# create database
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
if [ ${CREATE_DB_IF_EXISTS} = "true" ]; then
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA || echo "Database already exists."
else
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
fi
}

install_wp
install_test_suite
install_db

echo "Done!"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"lint": "phpcs .",
"lint-fix": "phpcbf .",
"test": "phpunit",
"setup-local-tests": "bash bin/install-wp-tests.sh wordpress_test root password mysql latest"
"setup-local-tests": "bash bin/install-wp-tests.sh ep_wp_test root password mysql latest true"
},
"extra": {
"installer-paths": {
Expand Down

0 comments on commit 7217835

Please sign in to comment.