Skip to content

Instantly share code, notes, and snippets.

@ErnieAtLYD
Last active November 10, 2017 20:08
Show Gist options
  • Save ErnieAtLYD/ffae6db194639efc9934e49f38f46cab to your computer and use it in GitHub Desktop.
Save ErnieAtLYD/ffae6db194639efc9934e49f38f46cab to your computer and use it in GitHub Desktop.
Getting WordPress Unit Tests working through CodeShip Basic (as of November 2017)
phpenv local 7.0
composer install --prefer-dist --no-interaction
curl -s "https://wordpress.org/latest.tar.gz" > "/tmp/wordpress.tar.gz"
mkdir -p /tmp/wordpress
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C /tmp/wordpress/
curl -s "https://raw.github.com/markoheijnen/wp-mysqli/master/db.php" > "/tmp/wordpress/wp-content/db.php"
mkdir -p /tmp/wordpress-tests-lib
svn co --quiet https://develop.svn.wordpress.org/tags/4.8.3/tests/phpunit/includes/ /tmp/wordpress-tests-lib/includes
svn co --quiet https://develop.svn.wordpress.org/tags/4.8.3/tests/phpunit/data/ /tmp/wordpress-tests-lib/data
curl -s "https://develop.svn.wordpress.org/tags/4.8.3/wp-tests-config-sample.php" > "/tmp/wordpress-tests-lib/wp-tests-config.php"
sed -i "s:dirname( __FILE__ ) . '/src/':'/tmp/wordpress/':" /tmp/wordpress-tests-lib/wp-tests-config.php
sed -i "s/youremptytestdbnamehere/test/" /tmp/wordpress-tests-lib/wp-tests-config.php
sed -i "s/yourusernamehere/$MYSQL_USER/" /tmp/wordpress-tests-lib/wp-tests-config.php
sed -i "s/yourpasswordhere/$MYSQL_PASSWORD/" /tmp/wordpress-tests-lib/wp-tests-config.php
sed -i "s|localhost|${DB_HOST}|" /tmp/wordpress-tests-lib/wp-tests-config.php
# No need to create a database, because MySQL 5.6 is already part of Codeship Basic PHP.
# Reminder: on CodeShip they name their test DB... wait for it... test.
# mysql -e 'CREATE DATABASE test;'
# mysqladmin create test --user="$MYSQL_USER" --password="$MYSQL_PASSWORD" --host=localhost --protocol=tcp
vendor/bin/phpunit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment