Unit testing with PHP Unit the comolete course

  • Course level: Beginner


Unit testing with PHP Unit. 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.

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 it straight away.

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

  1. Learn what unit tests are
  2. Learn how to write unit tests using PHP Unit
  3. Build a test suite for PHP functions and classes
  4. Make test methods depend on each other
  5. Use test doubles: mocks and stubs, including how to use Mockery

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.

Who this course is for:

  1. PHP developers who want to improve the quality of their code by writing automated tests for their functions and classes
  2. PHP developers who want to learn the PHP Unit testing framework
  3. This course is about unit testing – this course is probably not for you if you’re looking to learn how to test the user interface

What Will I Learn?

  • Write automated tests for your functions and classes
  • Write better code with less bugs, in less time
  • Develop code using test-driven development
  • Know that the code you write works how you want it to

Topics for this course

10 Lessons

Unit testing with PHPUnit

Setting up PHPUnit00:00:00
Writing your first test00:00:00
Testing a User model00:00:00
Clearing up test method names00:00:00
Using the setUp method00:00:00
Testing a collection class00:00:00
Testing a Calculator: Addition00:00:00
Testing a Calculator: Division00:00:00
Testing a Calculator: Finishing up00:00:00
PHP Unit
27 £

Enrolment validity: Lifetime


  • You must know PHP, including object-oriented code
  • Be happy running commands in the terminal / command line on your computer
  • Ideally have PHP and Composer installed, but a brief overview of installing these will be covered