Setting up wordpress test environment

Step 1 : Getting your virtual environment up and running.

cd ~/Public
mkdir faisal
cd faisal
git clone .
vagrant up
vagrant ssh

Step 2: Install SVN to get test wordpress codebase from wordpress.

sudo apt-get update
sudo apt-get install subversion

Step 3: Install phpUnit to run your unit tests

curl -O
sudo chmod +x phpunit-4.8.phar
sudo mv phpunit-4.8.phar /usr/local/bin/phpunit
phpunit --version

StepĀ 4: Install WP-CLI to setupĀ the test environment

curl -O
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp-cli
wp-cli --version

Step 5: Setting up the test plugin folder

curl -O
tar xvzf latest.tar.gz .
cd wp-content/plugins/
mkdir demo
cd demo
touch demo.php
wp scaffold plugin-tests demo

Step 6: Setting up the test environment

cd ~/Public/faisal
bash bin/ wordpress_test root root localhost latest

Step 6: Check if test is running or not.

cd ~/Public/faisal/wp-content/plugins/demo/

You should now see something similar to this –