Testing with PHPUnit

Laravel Testing Series: PHPUnit & Xdebug Essentials

Test Laravel apps with PHPUnit: feature and unit tests for CRUD, validation, authorization and Sanctum APIs, plus Xdebug coverage.

Laravel Testing Series: PHPUnit & Xdebug Essentials

Who this course is for

  • Laravel Developers who are working with Laravel and want to improve their testing skills to ensure their applications are robust and reliable
  • PHP developers looking to get hands-on experience with PHPUnit and automated testing within the Laravel framework
  • Backend Developers who primarily focus on backend code and want to ensure their APIs, business logic, and database interactions are well-tested
  • Professionals looking to stand out as Laravel experts in the industry
  • Anyone eager to elevate their Laravel development skills to new heights

What you'll learn

  • Master the fundamentals of feature and unit testing in Laravel
  • Get hands-on experience with configuring PHPUnit for testing in Laravel projects
  • Learn how to build and run different types of tests, including creating custom test suites
  • Implement best practices for naming and organizing your tests effectively
  • Write tests for HTTP requests and plan tests for different modules
  • Ensure consistency in your test environment by utilizing the RefreshDatabase trait
  • Gain expertise in testing CRUD operations such as creating, updating, retrieving, and deleting
  • Understand how to write validation and authorization tests for different operations
  • Dive into API testing and use Sanctum for authentication in Laravel APIs
  • Learn the differences between actingAs and Sanctum actingAs methods for API authentication
  • Apply the 3A rule (Arrange, Act, Assert) and chaining assertions to improve your tests
  • Refactor and optimize your test setup for better readability and maintainability
  • Learn how to measure code coverage using Xdebug and analyze test coverage reports
  • Explore real-world testing scenarios and improve the quality of your Laravel applications through effective testing
  • Follow Laravel testing best practices to create robust, reliable, and maintainable tests

Topics covered

An overview of the main modules. See the course page on Udemy for the full, up-to-date curriculum.

1

Introduction

2

Laravel Testing Essentials

3

Testing Requests and Planning

4

Category Retrieving Test

5

3A Rule, Chaining, and setUp Refactoring

6

Category Creating Test & Validation

7

Category Updating Test & Validation

8

Category Deleting & Authorization Test

9

Category API Testing

10

Code Coverage Using Xdebug

11

Finalizing the course

Prerequisites

  • Basic understanding of Laravel is required
  • Basic understanding of models, seeders, migrations and basic CRUD operations is required
  • Knowledge of Laravel's basic features like Eloquent ORM, Blade templating, and middleware
  • Any computer and OS will work — Windows, macOS or Linux

Your instructor

Mahmoud Anwar

Mahmoud Anwar

Senior Laravel/PHP developer and technical educator specializing in backend engineering, with 21+ programming courses created for developers worldwide.

More about Mahmoud
Keep going
Next step

Have a technical challenge?

Tell me about your application, your goals and your constraints. We'll work out the right next step together.