Setting up PHPUnit Testing For WordPress Plugins and Laravel.

Here’s my new tutorial I would like to share with you all is Setting up PHP Unit Testing For WordPress Plugins and Laravel.

What is Unit Testing and PHPUnit?

PHPUnit is a framework independent library for unit testing PHP.

Unit testing is a method by which small units of code are tested against expected results. Unit Testing helps to reduce such types of bugs. PHPUnit saves a lot of development time for developers because by writing unit tests, our code becomes less prone to defects.

I started using PHPUnit for my personal projects for both WordPress plugins and Laravel. I am no expert in Unit Testing but I am going to share with you guys how easy it is to install on your WP and Laravel Projects.

Requirements:

– I am currently using Homestead/Vagrant. It will also work with Docker and MAMP

– PHP 7 +

– Composer

– WP CLI for WordPress

– Laravel and/or WordPress

Setting up PHPUnit Testing in WordPress

Commands:

composer require --dev phpunit/phpunit ^7

Setting up PHPUnit Testing in WordPress

Setting up PHPUnit Testing in WordPress

Setting up PHPUnit Testing in Laravel

Setting up PHPUnit Testing in Laravel

Let me know if you have any questions or feedback on this tutorial.

Up Next: Test-Driven Design in Laravel Framework

Buy Me A Coffee

Leave a Reply

Powered by WordPress.com.

Up ↑

%d bloggers like this: