Skip to content

Commit 55adab7

Browse files
authored
Download the correct WP test environment
1 parent c4b1c25 commit 55adab7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

bin/install-wp-tests.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ else
3434
wp core download --version="$WP_VERSION" --path="$WP_CORE_DIR" --force
3535
fi
3636

37+
# Capture the output of the wp-cli command in the variable "output" to extract the WP version
38+
output=$(wp core download --version=latest --path="$WP_CORE_DIR" --force)
39+
40+
# Use grep to extract the version number
41+
LATEST_WP=$(echo "$output" | grep -oP 'Downloading WordPress \K[0-9]+\.[0-9]+\.[0-9]+')
42+
echo "Latest WP version to use: $LATEST_WP"
43+
3744
# Create a wp-config file for the test environment
3845
cd "$WP_CORE_DIR"
3946
wp config create --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASS" --dbhost="$DB_HOST" --skip-check
@@ -48,8 +55,8 @@ wp core install --url=example.dev --title="Test Site" --admin_user=admin --admin
4855

4956
# Download the testing framework
5057
mkdir -p "$WP_TESTS_DIR"
51-
svn checkout https://develop.svn.wordpress.org/trunk/tests/phpunit/includes/ "$WP_TESTS_DIR/includes"
52-
svn export https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php "$WP_TESTS_DIR/includes/wp-tests-config-sample.php"
58+
svn checkout https://develop.svn.wordpress.org/tags/$LATEST_WP/tests/phpunit/includes/ "$WP_TESTS_DIR/includes"
59+
svn export https://develop.svn.wordpress.org/tags/$LATEST_WP/wp-tests-config-sample.php "$WP_TESTS_DIR/includes/wp-tests-config-sample.php"
5360

5461
# Copy the wp-tests-config.php file template from the downloaded includes
5562
cp "$WP_TESTS_DIR/includes/wp-tests-config-sample.php" "$WP_TESTS_DIR/wp-tests-config.php"

0 commit comments

Comments
 (0)