Skip to content
UdemyPHPPaid courseAll LevelsCertificate

PHP Unit Testing with PHPUnit (Udemy.com)

Unit test your PHP code using the PHPUnit testing framework: find bugs quickly and early, and improve your code quality

Created by: Dave Hollingworth

Last updated April 2026

icon
What you will learn

  • Write automated tests for your PHP functions and classes
  • Write better code with less bugs, in less time
  • Develop code using test-driven development (TDD)
  • Know that the code you write works how you want it to
  • Learn the industry-standard PHPUnit testing framework
  • Get support directly from the instructor

How it compares

Against the other 151 rated Udemy courses in PHP on CourseDuck:

  • Rating4.7 out of 5higher than 91% of them
  • Reviews2,806#11 of 152 by number of reviews
  • Length2.8 hoursshorter than 78% of them
  • Last updatedApril 2026more recently than 94% of them

icon
Course Description

If you are a PHP developer and you want to learn how to write better code, with fewer bugs, you will need to know how to write unit tests.

Learn how to unit test your PHP code using the PHPUnit testing framework.

  • Learn what unit tests are

  • Learn how to write unit tests using PHPUnit

  • Build a test suite for PHP functions and classes

  • Make test methods dependent on each other

  • Use test doubles: mocks and stubs, including how to use Mockery

  • Learn how and why you should use dependency injection

  • Learn test-driven development (TDD)

  • Learn how to test protected and private methods and properties (and whether you actually should or not!)

  • Learn how to test abstract classes

A skill that will enable you to write higher quality code, in a shorter time, with better documentation and fewer bugs.

Learning how to write unit tests for your code will make you write better code. With automated tests, you can find bugs more easily, and if you break something you'll notice straight away.

Many experienced developers write unit tests for their code. It's a repeatable way of checking that the code works as intended, and also serves as documentation. Many popular PHP projects are unit tested, such as WordPress and Moodle, and if you use frameworks such as Laravel or Symfony, these provide tight integration with the PHPUnit testing framework.

Content and Overview

How do you currently test your code? Maybe you run your code in a browser, use var_dump a lot and so on. The problem with this is that you only tend to test new code - you don't go back and test old code. What if you add some new code that breaks the old code?

With automated unit tests, you have more control. If your new code breaks something, you'll notice straight away. You can fix bugs more easily, thereby reducing development time.

Tests are also a form of documentation, just like comments: they serve to show why the code has been written that way.

  • Suitable for all PHP developers, you'll start by learning the basics of unit testing PHP code, including how to use assertions.

  • Then you'll learn how to test functions and classes, and how to configure the PHPUnit framework.

  • Next you'll learn how to use test dependencies, fixtures and how to test for exceptions.

  • You'll also see how test doubles work - mock objects and stub methods.

  • Then you'll learn how to write code using test-driven development - writing the tests first, then the code.

  • You'll also learn how to test protected and private class methods and properties, and whether this is actually a good idea or not.

  • Testing static methods is covered in detail, including several methods for dealing with static dependencies.

When you complete the course you'll be able to write unit tests for your existing PHP code, and develop new code using test-driven development.

Complete with all the code shown in the lectures, you'll be able to work alongside the instructor and will receive a verifiable certificate of completion upon finishing the course.

Also, at all times throughout the course you have access to the instructor in the Q&A section to ask for help with any topic related to the course.

Enrol now and add unit testing to your PHP skillset!

icon
Udemy Discount

The discount is applied through our link. Open the course from here and Udemy's current promotional price is applied at checkout on most courses, no code to type.

Some courses are excluded from Udemy's promotions. If the price does not drop, clear your browser cookies and use the button again.

icon
Instructor Details

Dave Hollingworth

  Hi, I'm Dave Hollingworth. I'm an IT trainer and web application developer. I've been programming for over thirty years, and teaching IT since 1999.

    I've developed enterprise-level applications on platforms ranging from mainframes to mobiles: from my first web application, a quotes system created for a major insurance company back in 1999 - the first of its type in the sector - to interactive learning management systems for online language learning. 

    I've taught courses ranging from basic use of email to advanced web application development, both online and in-person. I've been teaching on Udemy since 2012. 

    I'm passionate about technology, and love teaching it! I believe it's possible to explain even the most complex subjects in a simple, straightforward way that doesn't confuse the student. 

    I look forward to welcoming you onto one of my courses! 

icon
More courses by Dave Hollingworth

$13.99

$74.99

$99.99

$64.99

icon
More PHP courses

$11.99

Free

$64.99

$11.99

$13.99

$74.99

icon
Reviews

4.7

2,806 ratings on Udemy

Select a bar to show only those reviews.Select the bar again to show every rating.

By Mahammadali Manknojiya on 1/30/2026

I had a great experience with this PHPUnit course. The concepts were explained clearly, with practical examples that made testing easy to understand and apply. It strengthened my confidence in writing effective unit tests and integrating them into real projects. Highly recommended for anyone looking to level up their PHP testing skills.

By Jeff Brown on 10/9/2025

not bad, I've worked with phpunit for years, but mostly just modifying existing code not constructing from scratch, however I wanted to get through stubbing and mocking correctly to handle my own current work. as I almost never had a need to modify those elements in practice, however new role requires more of this.

By Vishal Saxena on 3/20/2025

I recently completed the PHPUnit course, and overall, it was a brief and well-structured learning experience. The course helped me brush up on Test-Driven Development (TDD) concepts, and the instructor explained the topics clearly, making it easy to follow along. However, I did notice that some of the content, including the code examples and versions, are a bit outdated. An update to align with the latest PHPUnit versions and practices would make this course even better.

By Anonymized User on 6/30/2022

I found this course exactly what I was looking for. Author has covered almost all the points and concept which we require in our projects. All the concepts and chapters are explained so well with good demonstration, I found it really very easy to understand and I was able to implement it in my company project with ease. Thanks to the Author for putting his efforts to make this course easy to understand.

By Rajapaksha Thewage Eranga Lanka Perera on 3/28/2022

I had been struggling for years to understand how this php unit test works and why should I learn it. Finally I got it from you. I really understood how hard was my programming career without PHP unit. You made my programming life very easier by sharing this knowledge. Thank you so much!

By Anonymized User on 9/14/2021

Great course, recomended to start learn and use unit testing and to get more confident with this practice or even TDD. Of course as students we must to continue to interiorize and update our skills and on own code beyond these useful knowledges and tools offered by the course.

By Vladimir Glechikov on 6/3/2020

It's a very good course because it is built so, that I can code every exercise one by one following the author. And I recommend to pass it only such way, not just watching, but writing all code yourself. Also it is possible to save all passing history into git this way. Thank you, Dave!

By Rahul Pai on 1/2/2020

A thorough course on phpunit and unit testing of code with relevant close to real time scenarios was really helpful. Thank you for this course, Dave. Look forward to more of your courses and updated ones in the current, if any. The video content and the explanation with it is good. Maybe a little louder recording wouldn't hurt the ears (i had a hard time to hear the video course sometimes though at full volume). Overall, a great effort and thanks again for this wonderful course. Keep up the good work.

By Cody Wehunt on 12/3/2019

The course was very good and clear most of the time. The cut and paste of the code made it go a bit to fast. Sections 1-5 were great in terms of building upon the previous. Sections 6-9 were a bit more tricky as previously used classes changed and you lost the build progression and had to spend too much time trading in and out code in my opinion. But was a very good course and explained PHPUnit very well in my opinion.

By Bruno Avinint on 6/4/2019

This course is spot on on the topic of unit tests using phpunit. Very well paced and structured. I am learning a lot about the tool Maybe I'd like some methodology about when and how to apply unit tests in general but it's probably outside the scope of this course. Update: I finished the course, and I stand by my earlier comments. it's good all the way. We even get a course on Test Driven Development so this course is very complete. Dave, the teacher is active and answers questions from the students. As a foreign language student, I must say that his diction is very easy to follow. One might wish the course was a tad longer, maybe a few more exercises, but to be fully honest, it's also very appreciable that the course is split in very short, to the point, videos with a teacher who knows what he is doing and where he is taking the students when you have a busy schedule.

By Jon Prichard

The course is well structured and taught so far.

By Alessandro Romano

Spiegazione semplice da comprendere! Molto utile

Showing 12 of 57 reviews

icon
Quality Score

No CourseDuck member has rated this course yet. Taken it? Give each part a thumbs up or down.

Content Quality
/
Video Quality
/
Qualified Instructor
/
Course Pace
/
Course Depth & Coverage
/

Overall Score : 94 / 100