From tdd-wordpress
Executes WordPress quality checks using PHPStan (phpstan-wordpress), WPCS, and PHPUnit on Bedrock projects. Supplies WP_UnitTestCase helpers, unit/integration test guidance for hooks and REST APIs, and standards for level 6+ and 90%+ coverage.
npx claudepluginhub morodomi/tdd-skills --plugin tdd-wordpressThis skill is limited to using the following tools:
WordPress/Bedrock プロジェクト固有の品質チェックツール。
Guides WordPress testing strategy using PHPUnit and WP_UnitTestCase, with test categories, coverage targets, and AAA patterns. Use for writing tests, infrastructure setup, or coverage review.
Writes PHPUnit tests for PHP projects: unit tests, assertions, mocks, stubs, data providers, exception testing, TDD workflows. Supports WooCommerce via WC_Unit_Test_Case.
Guides WooCommerce development workflow: run PHP/JS tests with pnpm, linting, code quality checks, and fixes. Useful for testing, style issues, and dev cycle in WooCommerce projects.
Share bugs, ideas, or general feedback.
WordPress/Bedrock プロジェクト固有の品質チェックツール。
汎用PHPツールは tdd-php 参照。
| ツール | コマンド | 用途 |
|---|---|---|
| PHPStan | ./vendor/bin/phpstan analyse | 静的解析(phpstan-wordpress) |
| WPCS | ./vendor/bin/phpcs --standard=WordPress | コーディング規約 |
| PHPUnit | ./vendor/bin/phpunit | テスト実行 |
| ヘルパー | 用途 |
|---|---|
$this->factory()->user->create() | ユーザー作成 |
$this->factory()->post->create() | 投稿作成 |
$this->go_to($url) | URL遷移シミュレート |
wp_set_current_user($id) | 現在ユーザー設定 |
| カテゴリ | 対象 | 例 |
|---|---|---|
| Unit | 単一クラス、フック不使用 | Helper, Utility |
| Integration | WordPress環境依存 | Hook, REST API, CPT |
tests/
├── unit/ # 単体テスト(WP不要)
│ └── HelperTest.php
└── integration/ # 統合テスト(WP必要)
├── HookTest.php
└── RestApiTest.php
class HookTest extends WP_UnitTestCase
{
public function test_filter_modifies_content(): void
{
add_filter('the_content', 'my_content_filter');
$result = apply_filters('the_content', 'Hello');
$this->assertStringContainsString('Modified', $result);
}
}
class RestApiTest extends WP_UnitTestCase
{
public function test_get_items(): void
{
$admin = $this->factory()->user->create(['role' => 'administrator']);
wp_set_current_user($admin);
$request = new WP_REST_Request('GET', '/wp/v2/posts');
$response = rest_do_request($request);
$this->assertEquals(200, $response->get_status());
}
}
| 項目 | 目標 |
|---|---|
| PHPStan Level | 6+(phpstan-wordpress) |
| カバレッジ | 90%+ |
| WPCS | エラー0 |