Introduction to PHP Unit Testing

The purpose of these lessons is to get a conceptual understanding of PHPUnit Testing using WP_PHPUnit for WordPress Plugin / Theme. These lessons are aimed at Beginner – Intermediate developers who are familiar with the PHPUnit Framework.

Pre-Requisites ✅

  1. Knowledge of WordPress Development
    1. These lessons are aimed to help developers write Unit Tests for WordPress Plugins / Themes. It is a mandatory requisite to know at least basic WordPress Development
    2. You can learn WordPress development from here: https://developer.wordpress.org/
  2. Knowledge of writing basic PHPUnit Test
    1. As WP PHPUnit is built upon PHPUnit we need to be familiar with PHP Unit Framework first in order to use WP PHP Unit framework.
    2. You can learn PHP Unit from here: https://phpunit.de/
  3. Using Composer & NPM
    1. Composer is a tool package manager for PHP Frameworks / Libraries like PHPUnit, WP PHPUnit
    2. NPM is a package manager for JS frameworks / libraries
    3. Learn more about composer here: https://getcomposer.org/

Learn more about NPM here: https://www.npmjs.com/

Objectives 🎯

After completing these lessons you will be able to:

  1. Setup WP PHPUnit Testing Environment for Plugins / Themes.
  2. Choose the right test cases for WordPress Plugin / Themes.
  3. Write Unit Tests for plugin using WP PHPUnit framework.
  4. Write Efficient & Test-Driven code.