HOME > Development > PHP Unit Testing with PHPUnit

PHP Unit Testing with PHPUnit

  • Development
  • Mar 13, 2025
SynopsisPHP Unit Testing with PHPUnit, available at $84.99, has an av...
PHP Unit Testing with PHPUnit  No.1

PHP Unit Testing with PHPUnit, available at $84.99, has an average rating of 4.53, with 48 lectures, 6 quizzes, based on 2380 reviews, and has 10408 subscribers.

You will learn about 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 Have improved documentation for your code Get support directly from the instructor This course is ideal for individuals who are PHP developers who want to improve the quality of their code by writing automated tests for their functions and classes or PHP developers who want to learn the PHPUnit testing framework or This course is about unit testing – this course is probably not for you if youre looking to learn how to test the user interface It is particularly useful for PHP developers who want to improve the quality of their code by writing automated tests for their functions and classes or PHP developers who want to learn the PHPUnit testing framework or This course is about unit testing – this course is probably not for you if youre looking to learn how to test the user interface.

Enroll now: PHP Unit Testing with PHPUnit

Summary

Title: PHP Unit Testing with PHPUnit

Price: $84.99

Average Rating: 4.53

Number of Lectures: 48

Number of Quizzes: 6

Number of Published Lectures: 48

Number of Published Quizzes: 6

Number of Curriculum Items: 54

Number of Published Curriculum Objects: 54

Original Price: $109.99

Quality Status: approved

Status: Live

What You Will 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
  • Have improved documentation for your code
  • Get support directly from the instructor
  • Who Should Attend

  • PHP developers who want to improve the quality of their code by writing automated tests for their functions and classes
  • PHP developers who want to learn the PHPUnit testing framework
  • This course is about unit testing – this course is probably not for you if youre looking to learn how to test the user interface
  • Target Audiences

  • PHP developers who want to improve the quality of their code by writing automated tests for their functions and classes
  • PHP developers who want to learn the PHPUnit testing framework
  • This course is about unit testing – this course is probably not for you if youre looking to learn how to test the user interface
  • 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!

    Course Curriculum

    Chapter 1: Introduction and project setup

    Lecture 1: Introduction

    Lecture 2: Install PHP and Composer (Windows)

    Lecture 3: Install PHP and Composer (macOS)

    Lecture 4: Install PHP and Composer (Linux)

    Lecture 5: Create a project folder and install PHPUnit

    Chapter 2: Unit testing with PHPUnit: the basics

    Lecture 1: Write and run your first test: an introduction to assertions

    Lecture 2: Test a function: using multiple assertions

    Lecture 3: Test that incorrect results are not returned: using multiple test methods

    Lecture 4: Test a class: fixing bugs through testing

    Lecture 5: How to name your test methods

    Chapter 3: Configuring the PHPUnit test environment

    Lecture 1: The PHPUnit test runner: specify different options when running tests

    Lecture 2: Configure PHPUnit: the XML configuration file

    Lecture 3: Autoload classes being tested using Composer

    Chapter 4: Test dependencies, fixtures and exceptions

    Lecture 1: Unit test a queue class

    Lecture 2: Test dependencies: make one test method dependent on another

    Lecture 3: Fixtures: set up the known state of the tests using setUp and tearDown

    Lecture 4: Easily add a new test method using the test fixture

    Lecture 5: Share fixtures between tests for resource-intensive data

    Lecture 6: Testing exceptions: expecting code to throw an exception

    Chapter 5: Test doubles: mocks and stubs

    Lecture 1: Test doubles: create mock objects to remove dependencies on external resources

    Lecture 2: Dependency injection: inject objects that a class depends on

    Lecture 3: Test object interactions: verify how a dependency is used

    Lecture 4: Customise the creation of the mock object: the getMockBuilder method

    Chapter 6: Mockery – an alternative mocking framework with a human-readable syntax

    Lecture 1: Mock a dependency that doesnt exist yet

    Lecture 2: Using Mockery: installation and integration with PHPUnit

    Lecture 3: Using Mockery to mock a dependency that doesnt exist yet

    Lecture 4: PHPUnit vs Mockery: Returning different values on subsequent method calls

    Lecture 5: Mockery Spies: Make assertions on a call after the event

    Chapter 7: Test-driven development

    Lecture 1: Test-driven development: set up a TDD project

    Lecture 2: Write the test first, then write the code to make it pass

    Lecture 3: Write just enough code to make the test pass

    Lecture 4: Add tests and refactor code until the tests pass

    Lecture 5: Add more tests and application code functionality

    Lecture 6: Another test, more functionality, and more refactoring

    Lecture 7: Data providers: provide a test method with a collection of data

    Chapter 8: Testing non-public methods and properties and abstract classes

    Lecture 1: Testing non-public methods

    Lecture 2: Testing protected methods using inheritance

    Lecture 3: Testing private methods using reflection

    Lecture 4: Testing private methods with arguments using reflection

    Lecture 5: Testing protected and private attributes

    Lecture 6: Testing abstract classes

    Chapter 9: Testing static methods

    Lecture 1: Testing static methods

    Lecture 2: The problem with static methods: dependencies and mocking

    Lecture 3: Option 1: Refactor code to remove the static method

    Lecture 4: Option 2: Pass the dependency as a callable

    Lecture 5: Option 3: Use Mockery alias mocks to stub the static method call

    Chapter 10: Conclusion

    Lecture 1: Conclusion

    Lecture 2: Bonus Lecture: discount PHP hosting

    Instructors

  • PHP Unit Testing with PHPUnit  No.2
    Dave Hollingworth
    IT Trainer
  • Rating Distribution

  • 1 stars: 11 votes
  • 2 stars: 27 votes
  • 3 stars: 176 votes
  • 4 stars: 837 votes
  • 5 stars: 1329 votes
  • Frequently Asked Questions

    How long do I have access to the course materials?

    You can view and review the lecture materials indefinitely, like an on-demand channel.

    Can I take my courses with me wherever I go?

    Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don’t have an internet connection, some instructors also let their students download course lectures. That’s up to the instructor though, so make sure you get on their good side!