Permalink
Fetching contributors…
Cannot retrieve contributors at this time
111 lines (97 sloc) 3.21 KB
sudo: required
language: php
notifications:
email: false
php:
- '7.1'
- nightly
matrix:
fast_finish: true
allow_failures:
- php: nightly
- env: WP_VERSION=nightly
services:
- mysql
cache:
apt: true
directories:
- vendor
- $HOME/.composer/cache/files
addons:
apt:
packages:
- libjpeg-dev
- libpng12-dev
- php5-fpm
- php5-mysql
- nginx
hosts:
- wp.localhost
env:
global:
- WP_FOLDER="/tmp/wordpress"
- WP_URL="http://wp.localhost"
- WP_DOMAIN="wp.localhost"
- DB_NAME="test"
- TEST_DB_NAME="wploader"
- WP_TABLE_PREFIX="wp_"
- WP_ADMIN_USERNAME="admin"
- WP_ADMIN_PASSWORD="admin"
matrix:
- WP_VERSION=latest
- WP_VERSION=nightly
before_install:
# create the databases that will be used in the tests
- mysql -e "create database IF NOT EXISTS $DB_NAME;" -uroot
- mysql -e "create database IF NOT EXISTS $TEST_DB_NAME;" -uroot
# set up folders
- mkdir -p $WP_FOLDER
- mkdir tools
# install wp-cli in the `tools` folder
- wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -P $(pwd)/tools/
- chmod +x tools/wp-cli.phar && mv tools/wp-cli.phar tools/wp
# append the `tools` folder to the PATH
- export PATH=$PATH:$(pwd)/tools
# prepend the `vendor/bin` folder the PATH
- export PATH=vendor/bin:$PATH
install:
- composer install --prefer-dist
# install WordPress
- cd $WP_FOLDER
- wp core download --version=$WP_VERSION
- wp config create --dbname="$DB_NAME" --dbuser="root" --dbpass="" --dbhost="127.0.0.1" --dbprefix="$WP_TABLE_PREFIX"
- wp core install --url="$WP_URL" --title="Test" --admin_user="$WP_ADMIN_USERNAME" --admin_password="$WP_ADMIN_PASSWORD" --admin_email="admin@$WP_DOMAIN" --skip-email
- wp rewrite structure '/%postname%/' --hard
# update WordPress database to avoid prompts
- wp core update-db
# copy the plugin in the WordPress plugin folder
- cp -r $TRAVIS_BUILD_DIR $WP_FOLDER/wp-content/plugins/idlikethis
# show the plugins folder contents to make sure the plugin folder is there
- ls $WP_FOLDER/wp-content/plugins
# activate the plugin
- wp plugin activate idlikethis
# make sure the plugin is active on the site
- wp plugin list --status=active
# export a dump of the just installed database to the _data folder
- wp db export $TRAVIS_BUILD_DIR/tests/_data/dump.sql
# get back to the build folder
- cd $TRAVIS_BUILD_DIR
# open up the site folder to allow the PHP application to read/write/execute on it
- sudo chmod -R 777 $WP_FOLDER
# copy the Nginx configuration file to the available sites
- sudo cp build/travis-nginx-conf /etc/nginx/sites-available/$WP_DOMAIN
- sudo sed -e "s?%WP_FOLDER%?$WP_FOLDER?g" --in-place /etc/nginx/sites-available/$WP_DOMAIN
- sudo sed -e "s?%WP_DOMAIN%?$WP_DOMAIN?g" --in-place /etc/nginx/sites-available/$WP_DOMAIN
# enable the site
- sudo ln -s /etc/nginx/sites-available/$WP_DOMAIN /etc/nginx/sites-enabled/
before_script:
# restart Nnginx and PHP-FPM services
- sudo service php5-fpm restart
- sudo service nginx restart
# build Codeception modules
- codecept build
script:
- codecept run acceptance
- codecept run functional
- codecept run integration
- codecept run unit