drupal-dtt
Skill71 starsChanged 7 months agoMITView on GitHub
Drupal Test Traits (DTT) ExistingSite tests — testing against a live Drupal site, creating content, asserting pages, and running tests with DDEV.
In this repository35 other files it gives its agents.
- ddev-expertSkill
- docker-localSkill
- drupal-accessSkill
- drupal-cachingSkill
- drupal-composerSkill
- drupal-configSkill
- drupal-contrib-mgmtSkill
- drupal-debuggingSkill
- drupal-drushSkill
- drupal-entity-apiSkill
- drupal-eventsSkill
- drupal-fieldsSkill
- drupal-form-ajaxSkill
- drupal-form-alterSkill
- drupal-form-apiSkill
- drupal-form-validationSkill
- drupal-hooksSkill
- drupal-htmxSkill
- drupal-javascriptSkill
- drupal-kernelSkill
- drupal-menusSkill
- drupal-migrationsSkill
- drupal-paragraphsSkill
- drupal-pluginsSkill
- drupal-queriesSkill
- drupal-renderSkill
- drupal-routesSkill
- drupal-search-apiSkill
- drupal-securitySkill
- drupal-servicesSkill
- drupal-stateSkill
- drupal-taxonomySkill
- drupal-twigSkill
- drupal-unitSkill
- SKILL.mdSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
When you need real content, config, and users
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Drupal Test Traits (DTT) — ExistingSite Tests
When to Use
- Testing against a real, running Drupal site
- Smoke tests and integration tests against production-like data
- When you need real content, config, and users
- Regression tests for bugs found in production
Basic Structure
// tests/src/ExistingSite/MyFeatureTest.php
namespace Drupal\Tests\my_module\ExistingSite;
use weitzman\DrupalTestTraits\ExistingSiteBase;
/**
* Tests My Feature on an existing site.
*
* @group my_module
* @group existing_site
*/
final class MyFeatureTest extends ExistingSiteBase {
public function testHomepageLoads(): void {
$this->drupalGet('/');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Welcome');
}
public function testArticleCreation(): void {
// Create a user with role
$user = $this->createUser();
$user->addRole('editor');
$user->save();
$this->drupalLogin($user);
// Create a node
$node = $this->createNode([
'type' => 'article',
'title' => 'Test Article',
'status' => 1,
]);
$this->drupalGet('/node/' . $node->id());
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Test Article');
}
public function testFormSubmission(): void {
$this->drupalGet('/contact');
$this->assertSession()->statusCodeEquals(200);
$this->submitForm([
'name' => 'Test User',
'mail' => 'test@example.com',
'message[0][value]' => 'Test message',
], 'Send message');
$this->assertSession()->pageTextContains('Your message has been sent.');
}
}Common Assertions
// HTTP status
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->statusCodeEquals(403);
$this->assertSession()->statusCodeEquals(404);
// Page content
$this->assertSession()->pageTextContains('Expected text');
$this->assertSession()->pageTextNotContains('Missing text');
// Elements
$this->assertSession()->elementExists('css', '.my-class');
$this->assertSession()->elementTextContains('css', 'h1', 'Page Title');
$this->assertSession()->linkExists('My Link');
$this->assertSession()->linkByHrefExists('/my-path');
// Fields
$this->assertSession()->fieldExists('edit-title-0-value');
$this->assertSession()->fieldValueEquals('edit-title-0-value', 'My Title');
// Response headers
$this->assertSession()->responseHeaderContains('X-Drupal-Cache', 'HIT');Helpers
// Navigate to URL
$this->drupalGet('/path');
$this->drupalGet(Url::fromRoute('my_module.page'));
// Login
$this->drupalLogin($user);
$this->drupalLogout();
// Create content (automatically cleaned up after test)
$node = $this->createNode(['type' => 'article', 'title' => 'Test']);
$user = $this->createUser([], NULL, FALSE, ['mail' => 'test@test.com']);
$term = $this->createTerm($vocabulary);
// Submit form
$this->submitForm(['field_name' => 'value'], 'Submit button label');
// Click link
$this->clickLink('Link text');
// Find element
$page = $this->getSession()->getPage();
$element = $page->find('css', '.my-selector');Running Tests
# Run all DTT tests
ddev exec vendor/bin/phpunit tests/
# Run specific test
ddev exec vendor/bin/phpunit tests/src/ExistingSite/MyFeatureTest.php
# Run with group filter
ddev exec vendor/bin/phpunit tests/ --group my_module
# Verbose output
ddev exec vendor/bin/phpunit tests/ --verboseDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

