A simple example of unit testing with PHPUnit
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src Initial commit Jan 21, 2018
tests
.gitignore
composer.json
composer.lock
phpunit.xml
readme.md

readme.md

A Simple PHPUnit Example

This is a simple example of unit testing in PHP with PHPUnit. I used these examples as part of a talk given at Sheffield PHP on the 18th January 2018. The talk has been written up as a blog post: PHPUnit: What, Why, How?.

Please feel free to download this repository and give the unit tests a try.

As mentioned in my blog post try adding a second test case for the Average::median method to test when an even set of numbers is passed to the method.

If you succeed at that, then try taking a test driven development approach to adding a new method to Average for calculating the modal average by writing a test first.

Getting Started

Clone this repository and then run Composer:-

composer install

You will then be able to run the unit tests using:-

./vendor/bin/phpunit