PHPUnit: Testing with a Bite

Buy Access

It's Friday night... it's stormy... the office is empty... and you're deploying fresh code to production. Suddenly, an alarm! What!? The fences are down!? The dinosaurs are escaping! Somehow, your beautiful code contained a bug! And as the raptors surround you, one thought keeps coming back: if only we had written tests.


In this tutorial, we're going to jump over the hurdle of learning how to test so you can save the day!

  • Basic unit testing
  • Test-Driven-Development: how to do it, when to do it!
  • Mocking and test doubles! Creating mocks in PHPUnit & Prophecy
  • Using data providers to run tests over and over again with different input
  • Running code before and after each test
  • Testing for exceptions
  • Handling the database in tests
  • Integration tests: testing with real objects
  • Functional testing!
  • Continuous Integration (CI): let the robots run your tests

So grab your keyboard, reboot the system, and start testing with us!

Your Guides

Andrew Marcinkevičius Ryan Weaver Leanna Pelham

Questions? Conversation?

  • 2018-01-16 Scott Gutman

    Once again you have created a wonderful tutorial that I enjoyed very much! Thank you and I love the humor.

  • 2017-12-01 Diego Aguiar

    Hey Irfan
    If you mean beginner to testing, then yes :)
    This course is not that complex, but at least you need to be familiar with PHP and OO concepts
    To your question "Are you guys using any PHP framework?", yes, we show you how to test with PHPUnit, it's a very good open source framework, and actually we use it here in KnpU.


  • 2017-11-30 Irfan

    Is this course for absolute beginner ? I never tested my code before. Are you guys using any PHP framework ?

  • 2017-11-10 Victor Bocharsky

    Hey Simon,

    Haha, no problem! I just explained our complex workflow a bit ;) On the other hand I totally understand you, it'd be cool to watch as many videos at once as you want and take a break when you want :)


  • 2017-11-10 Simon Carr

    Thanks Victor. It was not a criticism, just a question and your strategy serves everyone, like you say, I can just wait, but I think I will still watch them as they come out they are like a box of chocolates, you eat them as soon as you see them.

  • 2017-11-10 Victor Bocharsky

    Hey Simon,

    We want to deliver our content as soon as possible to our users, i.e. we publish new videos right after they are ready. It depends, but most of the time we are able to process 1 video per day. It's a complex process, we need to recode video, record audio, then make them both together and add some special effects like a cool animation, video notes, etc. So we *can* release an entire course at once, but then you need to wait a few weeks when we record and process all the videos in this course. But as I said, we chose a different strategy - release new videos as soon as they are ready. If you want to see the entire course in the same breath, take a break and return in a few weeks, I think to that time almost all the videos will be released. Thanks for understanding!


  • 2017-11-10 Simon Carr

    Is it normal that we get one video per day? or will we see a few all at once?

  • 2017-10-06 Wil Iglesias

    Great! Thanks weaverryan!

  • 2017-10-04 weaverryan

    Yo Wil Iglesias!

    Haha, well then I have good news :). We will finish our Ansistrano tutorial (over the next couple of weeks) and then PHPUnit will be right after that. So, I expect it to start being released this month!


  • 2017-10-04 Wil Iglesias

    Hi Ryan! When will the PHPUnit tutorial come out? Because it's just what I've been waiting for to improve my superpowers ;)

  • 2017-08-02 weaverryan

    Haha "the usual question" :). Yes indeed! I hope over the next few months we'll start to be able to give concrete estimates very early on - our process is actually quite solid and predictable these days (woo!).


  • 2017-08-02 Andrew M.

    I would give a rough guess that it should be published 1-3 months before the year ends (it's right now in coding stages), but there always might be some unplanned issues delaying it.

  • 2017-08-02 Victor Bocharsky

    Hey Mehdi,

    Sorry, we don't have any ETA because this course is on early planning stage yet, but you can track it here: or press "Notify me when course is available" and we'll email you ;)


  • 2017-08-01 Mehdi

    Hi, This is really what I need. let me be the first to ask the usual question :)
    any ETA yet?

  • 2017-08-01 Andriy Frankevych

    Yes! Just in time, I was waiting for this <3