My project is a WordPress plugin. I’m using circleci for continuous integration.
I’m trying to set up my circle.yml file so that I can run my phpunit tests. I’m following this example to install WordPress etc on the CI environment. Here’s what DOESN’T WORK for me:
## Customize test commands
test:
pre:
# download wordpress for wp-cli to use
- curl -s https://wordpress.org/latest.tar.gz > /tmp/wordpress.tar.gz
- 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
# Create DB. No password is required for the MySQL user `ubuntu`
- mysql -u ubuntu -e "create database wordpress"
# Download WordPress into `wordpress` directory
- ./vendor/wp-cli/wp-cli/bin/wp core download --allow-root --path=wordpress
# Generate `wp-config.php` file
- ./vendor/wp-cli/wp-cli/bin/wp core config --allow-root --dbname=wordpress --dbuser=ubuntu --dbhost=localhost --path=wordpress
# Install WordPress
- ./vendor/wp-cli/wp-cli/bin/wp core install --allow-root --admin_name=admin --admin_password=admin --admin_email=admin@example.com --url=http://wp-github-pipeline.dev:8080 --title=WordPress --path=wordpress
# Clone Pipeline plugin from GitHub
- git clone git@github.com:TransitScreen/wp-github-pipeline.git wordpress/wp-content/plugins/wp-github-pipeline
#install dependencies
- cd wordpress/wp-content/plugins/wp-github-pipeline
- composer install
# And use WP-CLI to activate it
# ERROR HAPPENS HERE!!
- ./vendor/wp-cli/wp-cli/bin/wp plugin activate wp-github-pipeline --path=wordpress
override:
- phpunit # use PHPunit for testing
This is the error mentioned in the comments above:
PHP Fatal error: Cannot redeclare clirender() (previously declared in phar:///home/ubuntu/wp-github-pipeline/wp-cli.phar/vendor/wp-cli/php-cli-tools/lib/cli/cli.php:26) in /home/ubuntu/wp-github-pipeline/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 28
Fatal error: Cannot redeclare clirender() (previously declared in phar:///home/ubuntu/wp-github-pipeline/wp-cli.phar/vendor/wp-cli/php-cli-tools/lib/cli/cli.php:26) in /home/ubuntu/wp-github-pipeline/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 28 ./wp-cli.phar plugin activate wp-github-pipeline --path=wordpress r
Here’s what I eventually got working, adapted from this: