PHPUnit

Drupal 8 unit testing with PHPUnit

Introduction

PHPUnit is used in Drupal 8 for unit testing individual class methods without requiring a full Drupal environment. SimpleTest is still supported but should only be used for tests requiring a full Drupal environment.

In order to test Drupal modules without a Drupal environment, you need to use PHPUnit's object mocking functionality to create mock objects and inject these into the objects being tested.