Skip to content

A30001881/phpunit-simple-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple example of unit testing with PHPUnit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%