drupal-unit

Create and run Drupal unit tests with UnitTestCase and mocked dependencies.

67|13|Updated Apr 15, 2026
One-click install
npx skills add https://github.com/edutrul/drupal-ai --skill drupal-unit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drupal-unit
Source: https://github.com/edutrul/drupal-ai/tree/main/.claude/skills/drupal-unit
Command: npx skills add https://github.com/edutrul/drupal-ai --skill drupal-unit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Unit tests for Drupal code often require full Drupal bootstrap; this skill enables testing isolated PHP logic without bootstrapping and with mocked dependencies.

Core Features & Use Cases

  • Pure PHP unit tests without Drupal bootstrap
  • Mock dependencies with PHPUnit
  • Use UnitTestCase as base class

Quick Start

Create a basic unit test using UnitTestCase and run it with PHPUnit in a Drupal module project.

Frequently Asked Questions about drupal-unit

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

FAQPage Schema
How do I run isolated PHP unit tests in Drupal without a full bootstrap?

To run isolated PHP unit tests in Drupal without bootstrapping, use the UnitTestCase base class to test pure PHP logic independently, mocking dependencies to avoid loading the full Drupal environment.

Can I mock dependencies when writing unit tests for Drupal modules?

Yes, you can mock dependencies when writing Drupal unit tests by using PHPUnit's mocking features within the UnitTestCase base class to isolate PHP components and test them without bootstrapping Drupal.

What is the difference between UnitTestCase and a full Drupal test bootstrap?

UnitTestCase allows testing isolated PHP logic with mocked dependencies without initializing the Drupal environment, whereas a full bootstrap loads the entire Drupal instance for integration testing.

Do I need PHPUnit installed to run Drupal unit tests with UnitTestCase?

Yes, PHPUnit must be available in your environment, and your Drupal module project must be configured to run tests using the UnitTestCase base class for isolated PHP logic.

When should I use UnitTestCase for testing Drupal components instead of other test types?

Use UnitTestCase when testing isolated PHP logic in Drupal modules with mocked dependencies, avoiding the overhead of a full Drupal bootstrap for faster and more focused unit testing.