From drupal-boost
Drupal code quality and testing with PHPStan, Drupal Check, PHP CodeSniffer (Drupal coding standards), PHPUnit (unit/kernel/functional/browser tests), Nightwatch.js, and Rector. Use when writing tests, checking code quality, or setting up CI quality gates.
npx claudepluginhub abderrahimghazali/drupal-boostThis skill is limited to using the following tools:
- Location: `tests/src/Unit/`
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
tests/src/Unit/Drupal\Tests\UnitTestCase$this->createMock() or Prophecynamespace Drupal\Tests\MODULE_NAME\Unit;
use Drupal\Tests\UnitTestCase;
class MyServiceTest extends UnitTestCase {
public function testSomething(): void {
$mock = $this->createMock(SomeInterface::class);
$mock->method('getValue')->willReturn('test');
$service = new MyService($mock);
$this->assertEquals('expected', $service->process());
}
}
tests/src/Kernel/Drupal\KernelTests\KernelTestBasenamespace Drupal\Tests\MODULE_NAME\Kernel;
use Drupal\KernelTests\KernelTestBase;
class MyServiceKernelTest extends KernelTestBase {
protected static $modules = ['system', 'user', 'node', 'MODULE_NAME'];
protected function setUp(): void {
parent::setUp();
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installConfig(['system', 'MODULE_NAME']);
}
public function testServiceIntegration(): void {
$service = $this->container->get('MODULE_NAME.my_service');
$this->assertNotNull($service);
}
}
tests/src/Functional/Drupal\Tests\BrowserTestBasenamespace Drupal\Tests\MODULE_NAME\Functional;
use Drupal\Tests\BrowserTestBase;
class MyPageTest extends BrowserTestBase {
protected static $modules = ['MODULE_NAME'];
protected $defaultTheme = 'stark';
public function testPageAccess(): void {
$user = $this->drupalCreateUser(['access content']);
$this->drupalLogin($user);
$this->drupalGet('/my-page');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Expected text');
}
}
# Single test file
ddev exec ./vendor/bin/phpunit -c web/core web/modules/custom/MODULE/tests/src/Unit/MyTest.php
# By group
ddev exec ./vendor/bin/phpunit -c web/core --group MODULE_NAME
# By test type directory
ddev exec ./vendor/bin/phpunit -c web/core web/modules/custom/MODULE/tests/src/Kernel/
# With filter
ddev exec ./vendor/bin/phpunit -c web/core --filter testMethodName
# Run analysis
ddev exec ./vendor/bin/phpstan analyse web/modules/custom/MODULE --level=6
# Generate baseline (accept existing issues)
ddev exec ./vendor/bin/phpstan analyse web/modules/custom/MODULE --generate-baseline
# With Drupal extension (phpstan.neon)
includes:
- vendor/mglaman/phpstan-drupal/extension.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
parameters:
level: 6
paths:
- web/modules/custom
drupal:
drupal_root: web
# Check
ddev exec ./vendor/bin/phpcs --standard=Drupal,DrupalPractice web/modules/custom/MODULE
# Auto-fix
ddev exec ./vendor/bin/phpcbf --standard=Drupal,DrupalPractice web/modules/custom/MODULE
# Preview changes
ddev exec ./vendor/bin/rector process web/modules/custom/MODULE --dry-run
# Apply changes
ddev exec ./vendor/bin/rector process web/modules/custom/MODULE
protected $defaultTheme = 'stark'; in Functional tests$modules array with ALL required modulessetUp() for Kernel tests->accessCheck(TRUE) in test entity queries tooRead reference files for details:
reference/phpunit-patterns.md for test patternsreference/phpstan-config.md for PHPStan setupreference/rector-rules.md for Rector configuration