drupal-kernel

Validate Drupal kernel tests using KernelTestBase for service and database behavior.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kernel-based testing for Drupal modules using KernelTestBase to validate services, DB operations, and hooks with minimal bootstrap.

Core Features & Use Cases

  • Provides isolated kernel tests for Drupal modules (service containers, DB schemas, and entity operations) without a full browser.
  • Demonstrates setup patterns: installEntitySchema, installSchema, installConfig, and entity type creation in tests.
  • Helps you verify module behavior through assertions on entities, config, and hooks.

Quick Start

Run kernel tests for your module by placing tests under docroot/modules/custom/your_module/tests/src/Kernel and running the PHPUnit command that targets those tests.

Frequently Asked Questions about drupal-kernel

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

FAQPage Schema
How do I write a Drupal kernel test to validate module services and database operations?

Drupal kernel tests using KernelTestBase validate service interactions and database operations with minimal bootstrap. You place tests under tests/src/Kernel and use explicit module loading along with assertions to verify entity schemas, config installations, and hook behavior.

When do I need a kernel test instead of a full browser test for my Drupal module?

You need a kernel test when you require isolated, fast verification of entity schemas, config installations, and kernel-level logic without the overhead of a full browser. KernelTestBase provides minimal bootstrap configuration to test service containers and database operations efficiently.

How do I install entity schemas and config in a Drupal KernelTestBase setup?

You install entity schemas and config in a Drupal KernelTestBase setup by applying specific setup patterns including installEntitySchema, installSchema, and installConfig. These methods prepare the minimal bootstrap environment required for testing module behavior.

Can I test Drupal hooks and entity operations without a full browser environment?

Yes, you can test Drupal hooks and entity operations without a full browser by using KernelTestBase. It provides an isolated environment with minimal bootstrap configuration to explicitly verify outcomes for entity operations, config, and hooks through direct assertions.

What are the limitations of using KernelTestBase for Drupal module testing?

KernelTestBase is limited to testing kernel-level logic, service interactions, and database operations with minimal bootstrap. It does not handle browser-based interactions or full UI testing, requiring explicit module loading and explicit assertions to verify all outcomes.

Where do I place PHPUnit kernel test files for a custom Drupal module?

You place PHPUnit kernel test files for a custom Drupal module under docroot/modules/custom/your_module/tests/src/Kernel. You then run the PHPUnit command targeting those tests to execute the kernel-level validation for your module.