Skip to content

Commit c13143e

Browse files
authored
Merge pull request #844 from 10up/fix/unit-tests
Switch PHPUnit test install script to use `git` instead of `svn`
2 parents 57d27bd + 25c0baf commit c13143e

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

bin/install-wp-tests.sh

+28-14
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
1818
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}
1919

2020
download() {
21-
if [ `which curl` ]; then
22-
curl -s "$1" > "$2";
23-
elif [ `which wget` ]; then
24-
wget -nv -O "$2" "$1"
25-
fi
21+
if [ `which curl` ]; then
22+
curl -s "$1" > "$2";
23+
elif [ `which wget` ]; then
24+
wget -nv -O "$2" "$1"
25+
fi
26+
}
27+
28+
# Check if git is installed
29+
check_git_installed() {
30+
if ! command -v git > /dev/null; then
31+
echo "Error: git is not installed. Please install git and try again."
32+
exit 1
33+
fi
2634
}
2735

2836
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
@@ -35,6 +43,7 @@ elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
3543
WP_TESTS_TAG="tags/$WP_VERSION"
3644
fi
3745
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
46+
WP_BRANCH="trunk"
3847
WP_TESTS_TAG="trunk"
3948
else
4049
# http serves a single offer, whereas https serves multiple. we only want one
@@ -45,6 +54,7 @@ else
4554
echo "Latest WordPress version could not be found"
4655
exit 1
4756
fi
57+
WP_BRANCH=$LATEST_VERSION
4858
WP_TESTS_TAG="tags/$LATEST_VERSION"
4959
fi
5060

@@ -104,12 +114,16 @@ install_test_suite() {
104114
if [ ! -d $WP_TESTS_DIR ]; then
105115
# set up testing suite
106116
mkdir -p $WP_TESTS_DIR
107-
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
108-
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
117+
check_git_installed
118+
git clone --depth 1 --branch $WP_BRANCH https://github.com/wordpress/wordpress-develop $TMPDIR/wordpress-develop
119+
rm -r $TMPDIR/wordpress-develop/.git
120+
mv $TMPDIR/wordpress-develop/tests/phpunit/includes/ $WP_TESTS_DIR/includes
121+
mv $TMPDIR/wordpress-develop/tests/phpunit/data/ $WP_TESTS_DIR/data
122+
rm -r $TMPDIR/wordpress-develop
109123
fi
110124

111125
if [ ! -f wp-tests-config.php ]; then
112-
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
126+
download https://raw.githubusercontent.com/wordpress/wordpress-develop/${WP_BRANCH}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
113127
# remove all forward slashes in the end
114128
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
115129
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
@@ -144,12 +158,12 @@ install_db() {
144158
fi
145159

146160
# create database
147-
if [ -z $DB_PASS ] ; then
148-
echo 'No DB password'
149-
mysqladmin create $DB_NAME --user="$DB_USER" $EXTRA
150-
else
151-
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
152-
fi
161+
if [ -z $DB_PASS ] ; then
162+
echo 'No DB password'
163+
mysqladmin create $DB_NAME --user="$DB_USER" $EXTRA
164+
else
165+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
166+
fi
153167
}
154168

155169
install_wp

0 commit comments

Comments
 (0)