test

작성자: automattic

PHPUnit 및 Playwright E2E 테스트를 위한 테스트 패턴입니다. 테스트 작성, 테스트 실패 디버깅, 테스트 커버리지 설정 또는 테스트 패턴 구현 시 사용하세요…

npx skills add https://github.com/automattic/wordpress-activitypub --skill test

ActivityPub Testing

This skill provides guidance on writing and running tests for the WordPress ActivityPub plugin.

Quick Reference

For complete testing commands and environment setup, see Testing Reference.

Key Commands

  • PHP: npm run env-test
  • E2E: npm run test:e2e
  • JavaScript: npm run test:unit

PHPUnit Testing

Test Structure

<?php
namespace Activitypub\Tests;

use WP_UnitTestCase;

class Test_Feature extends WP_UnitTestCase {
    public function set_up(): void {
        parent::set_up();
        // Setup
    }

    public function tear_down(): void {
        // Cleanup
        parent::tear_down();
    }

    public function test_functionality() {
        // Test implementation
    }
}

Common Test Patterns

For transformer and handler testing patterns, see Testing Reference - Writing Effective Tests.

For mocking HTTP requests and other utilities, see Testing Reference - Test Utilities.

Test Groups

Use @group annotations:

/**
 * @group activitypub
 * @group federation
 */
public function test_federation_feature() {
    // Test code
}

E2E Testing with Playwright

Basic E2E Test

const { test, expect } = require('@playwright/test');

test('ActivityPub settings page loads', async ({ page }) => {
    await page.goto('/wp-admin/options-general.php?page=activitypub');
    await expect(page.locator('h1')).toContainText('ActivityPub');
});

Testing Federation

test('WebFinger discovery works', async ({ page }) => {
    const response = await page.request.get('/.well-known/webfinger', {
        params: {
            resource: 'acct:admin@localhost:8888'
        }
    });

    expect(response.ok()).toBeTruthy();
    const json = await response.json();
    expect(json.subject).toBe('acct:admin@localhost:8888');
});

Test Data Factories

For creating test data (users, posts, comments), see Testing Reference - Test Utilities.

Coverage Reports

See Testing Reference for detailed coverage generation instructions.

Debugging Tests

Debug Output

// In tests
var_dump( $data );
error_log( print_r( $result, true ) );

// Run with verbose
npm run env-test -- --verbose --debug

Isolating Tests

# Run single test method
npm run env-test -- --filter=test_specific_method

# Stop on first failure
npm run env-test -- --stop-on-failure

automattic의 다른 스킬

testing-js
automattic
자바스크립트 파일의 구문 오류를 확인하기 위한 지침
setup
automattic
dn CLI가 설치 및 구성되었는지 확인합니다. 사용자가 domain-names 플러그인을 처음 설치할 때나 dn 명령어가 CLI 때문에 실패할 때 사용합니다.
studio-cli
automattic
Studio CLI를 사용하여 로컬 WordPress 사이트, 인증 및 미리보기 사이트를 관리하세요. Studio CLI 명령을 실행하거나 관리해야 할 때 이 스킬을 호출하세요.
dn-info
automattic
등록된 도메인의 상세 정보를 dn CLI를 사용하여 조회합니다. 사용자가 만료일, 네임서버, 연락처 등의 도메인 세부 정보를 확인하려 할 때 사용하세요.
qa
automattic
추출된 WXR 콘텐츠를 원본 소스 사이트와 페이지별로 비교합니다. 누락된 텍스트, 제목, 이미지, 링크를 찾아냅니다. WXR을 패치하거나… 수정하여 해결합니다.
add-skill
automattic
a8c-design 플러그인에 새 스킬을 추가합니다. Claude Code 스킬을 구축했으며 이를 공유 Automattic a8c-design 플러그인에 기여하려는 경우 사용합니다 —…
design-foundations
automattic
해방된 사이트에서 일관된 디자인 기반 JSON을 구축합니다 — 근거 추적과 함께 의미론적 색상/타이포그래피/간격 역할을 포함합니다. 부분 스캐폴드를 사용합니다…
wp-phpstan
automattic
WordPress 프로젝트(플러그인/테마/사이트)에서 PHPStan 정적 분석을 설정, 실행 또는 수정할 때 사용: phpstan.neon 설정, 기준선,…