Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/trebormc/drupal-ai-agentsnpx agentmods add skills/trebormc/drupal-ai-agents/drupal-unit-testWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/trebormc/drupal-ai-agents/drupal-unit-test)<a href="https://agentmods.dev/skills/trebormc/drupal-ai-agents/drupal-unit-test"><img src="https://agentmods.dev/badge/skills/trebormc/drupal-ai-agents/drupal-unit-test/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/trebormc/drupal-ai-agents/drupal-unit-test"><img src="https://agentmods.dev/badge/skills/trebormc/drupal-ai-agents/drupal-unit-test.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00136 | $0.02828 |
| Opus 5.5 | $0.00054 | $0.01131 |
| Sonnet 5.5 | $0.00027 | $0.00566 |
| Haiku 4.5 | $0.00014 | $0.00283 |
Grade A, and why
drupal-unit-test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 302 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Environment
All commands via ssh web. Use $DDEV_DOCROOT for paths.
Detect test gaps: ssh web drush audit:run phpunit --filter="module:MODULE" --format=json
Drupal 10+11 Compatibility (CRITICAL)
Use PHPDoc annotations only — NEVER PHP 8 attributes. Drupal 10 = PHPUnit 9.x (no attribute support).
| Use THIS | NOT this |
|---|---|
@coversDefaultClass \My\Class |
#[CoversClass(MyClass::class)] |
@covers ::methodName |
#[Covers('methodName')] |
@group mymodule |
#[Group('mymodule')] |
@dataProvider providerName |
#[DataProvider('providerName')] |
Workflow
- Read source class in
src/ - Check existing tests in
tests/src/Unit/ - Generate test class following templates below
- Run test (Form ROOT — requires project phpunit.xml; if missing, use Form CORE from the drupal-testing skill):
ssh web ./vendor/bin/phpunit $DDEV_DOCROOT/modules/custom/MODULE/tests/src/Unit/Service/MyServiceTest.php - Run PHPCS — always try Audit module first:
# Preferred: Audit module (check if installed first) ssh web drush audit:run phpcs --filter="module:MODULE" --format=json # Fallback only if Audit module not installed: ssh web ./vendor/bin/phpcs --standard=Drupal,DrupalPractice $DDEV_DOCROOT/modules/custom/MODULE/tests/src/Unit/
File Structure & Namespace
$DDEV_DOCROOT/modules/custom/MODULE/tests/src/Unit/
├── Service/MyServiceTest.php # Drupal\Tests\MODULE\Unit\Service
├── Plugin/Block/MyBlockTest.php # Drupal\Tests\MODULE\Unit\Plugin\Block
├── Form/MyFormTest.php # Drupal\Tests\MODULE\Unit\Form
└── Controller/MyControllerTest.php # Drupal\Tests\MODULE\Unit\Controller
Template: Service Test (Complete Example)
<?php
declare(strict_types=1);
namespace Drupal\Tests\mymodule\Unit\Service;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\mymodule\Service\MyService;
use Drupal\Tests\UnitTestCase;
/**
* Tests the MyService class.
*
* @coversDefaultClass \Drupal\mymodule\Service\MyService
* @group mymodule
*/
class MyServiceTest extends UnitTestCase {
protected MyService $service;
protected ConfigFactoryInterface $configFactory;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->configFactory = $this->createMock(ConfigFactoryInterface::class);
$this->service = new MyService($this->configFactory);
}
/**
* @covers ::process
*/
public function testProcessValidInput(): void {
$config = $this->createMock(ImmutableConfig::class);
$config->method('get')->willReturn('value');
$this->configFactory->method('get')->willReturn($config);
$result = $this->service->process('test');
$this->assertIsArray($result);
$this->assertNotEmpty($result);
}
/**
* @covers ::process
* @dataProvider processDataProvider
*/
public function testProcessScenarios(string $input, bool $expectEmpty): void {
$config = $this->createMock(ImmutableConfig::class);
$config->method('get')->willReturn('default');
$this->configFactory->method('get')->willReturn($config);
$result = $this->service->process($input);
$this->assertEquals($expectEmpty, empty($result));
}
/**
* @return array
* Test scenarios.
*/
public static function processDataProvider(): array {
return [
'valid input' => ['valid', FALSE],
'another case' => ['other', FALSE],
];
}
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 302 lines · 136 tokens per session scan A 7010a234d927
drupal-unit-test is a skill published in the GitHub repository trebormc/drupal-ai-agents (11 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 136 tokens to every session and 2,828 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
test-master
Generates test files, creates mocking strategies, analyzes code coverage, designs test architectures, and produces test plans and defect reports across functional, performance, and security testing disciplines. Use when writing unit tests, integration tests, or E2E tests; creating test strategies or automation…
migrate-xunit-to-xunit-v3
Migrate .NET test projects from xUnit.net v2 to xunit.v3 and fix v3 breaks. Use for package/CPM conversion, OutputType=Exe, preserving the VSTest or MTP runner (including projects currently using YTest.MTP.XUnit2), incompatible TFMs, async void tests, string-to-Type attributes, custom Fact/Theory/BeforeAfterTest…
go-testing
Trigger: Go tests, go test coverage, Bubbletea teatest, golden files. Apply focused Go testing patterns.
dart-test
DART Test: unit tests, integration tests, CI validation, and debugging.
principle-test-behavior-not-implementation
Apply when you write, change, or keep a test. Assert what the code's users can observe, so that the test fails when that behavior breaks and keeps passing when only the internals change.
mobiai-ios-testing
Use when writing or running tests in an iOS project — unit tests, UI tests, snapshot tests, choosing the right framework.