Skip to content

WenkeZhou/phpunit-tutorial

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPUnit Tutorial for Lonestar PHP 2015

Getting started

In order to minimize the amount of time necessary to get setup, please use the following steps to get setup.

  • Fork this repo to a local folder on your computer or a Vagrant VM
  • Install Composer if it's not already installed (https://getcomposer.org)
  • Run composer install which will install the tools necessary for the tutorial
  • Look around, code will be flowing in over the next few days, so please feel free to take a look at the examples we are going to bre working through.

A forked repo will allow you to commit your tests back to your version of this repo for reference. As much fun as it would be to merge in all those PRs, I'm certain you'd rather be able to save them yourselves.

What you need

  • A computer
  • Yourself
  • A basic understanding of Object Oriented Programming (seriously, just know what it is, nothing more than that)
  • A desire to want to learn how to write Unit Tests with PHPUnit

Bonus

  • If you've worked with composer, that will help, if not we'll have a little crash course - so no worries
  • If you've worked with Git, that's great too, if not, we'll cover enough to get through the tutorial
  • If you've written tests before, that's a bonus as well, let me know and perhaps you offer some assistance to others in the tutorial.

Expectations

We're going to keep this light, practical and hopefully helpful! There are a number of topics we are going to try to cover, they include.

  • Installing PHPUnit via Composer
  • Dependency Injection
  • Autoloading (PSR-4)
  • Setup/Tear Down
  • Understanding assertions
  • Testing Sucess
  • Testing Failure
  • Data Fixtures
  • Data Providers
  • Mocks
  • Code Coverage reports

In addition to those topics, we're going to be working through some actual code and writing tests for them. Some of the examples may require you to prove the existing code is working. Others may require you to find a bug in a code by using tests, it'll be clear at the beginning of each example what you are expected to do.

We are going to be doing more than just writing tests for simple arithmetic, my goal is try to try to find some examples of things that actually come up in the day to day and teach you how to write tests for those. The mocks will get into dealing with APIs, Databases and external data sources, while assertion aspect will get into things like data manipulation, serialization and things of that nature.

Finally

Hope to see you there, if you have a chance to work through the setup prior to the tutorial that's great. We're all there to learn, so if you come prepared and have a grip on Git and Composer, I may ask for your help in getting everyone up to speed. Other than that, we have 3 hours, I'll be available before and after if there are more questions. My goal is to keep this session light, helpful and informative.

In the meantime, if you have any questions, feel free to tweet me @shrtwhitebldguy or drop me an email at mfrost.design@gmail.com. Hope to see you there!

About

PHPUnit Tutorial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%