drupal-testing

Generate PHPUnit tests for Drupal modules across Unit, Kernel, Functional, and FunctionalJavascript types.

1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-testing
Source: https://github.com/proofoftom/drupal-skills/tree/main/skills/drupal-testing
Command: npx skills add https://github.com/proofoftom/drupal-skills --skill drupal-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write effective and correct automated tests for Drupal modules, ensuring code quality and preventing regressions.

Core Features & Use Cases

  • Test Type Selection: Guides you to choose the most appropriate PHPUnit test type (Unit, Kernel, Functional, FunctionalJavascript) based on the code being tested.
  • Correct Setup: Demonstrates the essential setUp() patterns, module declarations ($modules), and annotations (@group) required for tests to run correctly.
  • Use Case: You've built a new content entity type and want to ensure its CRUD operations work as expected. This Skill will help you write a Kernel test to verify entity saving, loading, and deletion without needing a full browser.

Quick Start

Write a kernel test for the my_module module to verify its service.

Frequently Asked Questions about drupal-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write PHPUnit tests for Drupal modules?

Writing PHPUnit tests for Drupal modules involves selecting the correct test type, structuring setUp() methods, declaring necessary modules, and adding @group annotations to ensure tests run correctly.

What's the best way to choose between Drupal Kernel and Functional tests?

Choosing between Drupal Kernel and Functional tests requires selecting the lowest sufficient test level for optimal performance, using Kernel tests for services without a browser and Functional tests when full web requests are necessary.

How do I set up a Kernel test to verify a Drupal service?

Setting up a Kernel test to verify a Drupal service requires declaring the module in the $modules array, implementing the setUp() method for initialization, and writing assertions to validate the service behavior without a full browser environment.

When do I need FunctionalJavascript tests instead of standard Functional tests in Drupal?

You need FunctionalJavascript tests instead of standard Functional tests in Drupal when verifying client-side interactions like JavaScript execution and dynamic UI updates that standard Functional tests cannot evaluate.

Why are my Drupal PHPUnit tests failing to load dependencies?

Drupal PHPUnit tests fail to load dependencies when the required modules are not properly declared in the $modules array within the test class, preventing the test environment from initializing the necessary services.