acc-testing-knowledge

Testing knowledge base for PHP 8.5 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

16 stars

Best use case

acc-testing-knowledge is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Testing knowledge base for PHP 8.5 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

Teams using acc-testing-knowledge should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/acc-testing-knowledge/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/testing-security/acc-testing-knowledge/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/acc-testing-knowledge/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How acc-testing-knowledge Compares

Feature / Agentacc-testing-knowledgeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Testing knowledge base for PHP 8.5 projects. Provides testing pyramid, AAA pattern, naming conventions, isolation principles, DDD testing guidelines, and PHPUnit patterns.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Testing Knowledge Base

Quick reference for PHP testing patterns, principles, and best practices.

## Testing Pyramid

```
        /\
       /  \     Functional (10%)
      /────\    - E2E, browser tests
     /      \   - Slow, fragile
    /────────\  Integration (20%)
   /          \ - DB, HTTP, queues
  /────────────\Unit (70%)
 /              \- Fast, isolated
/________________\- Business logic
```

**Rule:** 70% unit, 20% integration, 10% functional. Invert the pyramid = slow, brittle test suite.

## AAA Pattern (Arrange-Act-Assert)

```php
public function test_order_calculates_total_with_discount(): void
{
    // Arrange — set up test data
    $order = new Order(OrderId::generate());
    $order->addItem(new Product('Book', Money::EUR(100)));
    $discount = new PercentageDiscount(10);

    // Act — execute the behavior
    $total = $order->calculateTotal($discount);

    // Assert — verify the outcome
    self::assertEquals(Money::EUR(90), $total);
}
```

**Rules:**
- One blank line between sections
- Single Act per test
- Assert behavior, not implementation

## Naming Conventions

### PHPUnit Style

```
test_{method}_{scenario}_{expected}
```

| Example | Method | Scenario | Expected |
|---------|--------|----------|----------|
| `test_calculate_total_with_discount_returns_reduced_amount` | calculateTotal | with discount | returns reduced amount |
| `test_confirm_when_already_shipped_throws_exception` | confirm | when already shipped | throws exception |
| `test_email_with_invalid_format_fails_validation` | Email (VO) | with invalid format | fails validation |

### Pest Style

```php
it('calculates total with discount applied')
it('throws exception when confirming shipped order')
it('fails validation for invalid email format')
```

## Test Isolation Principles

### DO

- [ ] Fresh fixtures per test
- [ ] Independent test execution (any order)
- [ ] Teardown cleans all state
- [ ] Use in-memory implementations

### DON'T

- [ ] Shared mutable state between tests
- [ ] Tests depending on execution order
- [ ] Global variables or singletons
- [ ] Real external services in unit tests

## Quick Quality Checklist

| Rule | Check |
|------|-------|
| One test = one behavior | Single assertion group |
| Test is documentation | Name reads as specification |
| No logic in tests | No if/for/while |
| Fast execution | <100ms per unit test |
| Mock interfaces only | Never mock VO, Entity, final |
| ≤3 mocks per test | More = design smell |
| Behavior over implementation | Test WHAT, not HOW |

## DDD Component Testing

| Component | Test Focus | Mocks Allowed |
|-----------|------------|---------------|
| **Value Object** | Validation, equality, immutability | None |
| **Entity** | State transitions, business rules | None |
| **Aggregate** | Invariants, consistency, events | None |
| **Domain Service** | Business logic spanning aggregates | Repository (Fake) |
| **Application Service** | Orchestration, transactions | Repository, EventDispatcher |
| **Repository** | CRUD operations | Database (SQLite) |

## PHP 8.5 Test Patterns

### Unit Test Template

```php
<?php

declare(strict_types=1);

namespace Tests\Unit\Domain;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

#[Group('unit')]
#[CoversClass(Email::class)]
final class EmailTest extends TestCase
{
    public function test_creates_valid_email(): void
    {
        $email = new Email('user@example.com');

        self::assertSame('user@example.com', $email->value);
    }

    public function test_throws_for_invalid_format(): void
    {
        $this->expectException(InvalidArgumentException::class);

        new Email('invalid');
    }
}
```

### Integration Test Template

```php
<?php

declare(strict_types=1);

namespace Tests\Integration\Infrastructure;

use PHPUnit\Framework\Attributes\Group;
use Tests\DatabaseTestCase;

#[Group('integration')]
final class DoctrineOrderRepositoryTest extends DatabaseTestCase
{
    private OrderRepositoryInterface $repository;

    protected function setUp(): void
    {
        parent::setUp();
        $this->repository = $this->getContainer()->get(OrderRepositoryInterface::class);
    }

    public function test_saves_and_retrieves_order(): void
    {
        // Arrange
        $order = OrderMother::pending();

        // Act
        $this->repository->save($order);
        $found = $this->repository->findById($order->id());

        // Assert
        self::assertNotNull($found);
        self::assertTrue($order->id()->equals($found->id()));
    }
}
```

## Test Doubles Quick Reference

| Type | Purpose | When to Use |
|------|---------|-------------|
| **Stub** | Returns canned answers | External API responses |
| **Mock** | Verifies interactions | Event publishing |
| **Fake** | Working implementation | InMemory repository |
| **Spy** | Records calls | Logging, notifications |

### Decision Matrix

```
Need to verify a call was made?
├── Yes → Mock or Spy
└── No → Need real behavior?
    ├── Yes → Fake
    └── No → Stub
```

## Common Test Smells

| Smell | Detection | Fix |
|-------|-----------|-----|
| Logic in Test | `if`, `for`, `while` in test | Extract to helper or parameterize |
| Mock Overuse | >3 mocks | Refactor design, use Fakes |
| Mystery Guest | External files, hidden data | Inline test data or use Builder |
| Eager Test | Tests multiple behaviors | Split into separate tests |
| Fragile Test | Breaks on refactor | Test behavior, not implementation |

## References

For detailed information, load these reference files:

- `references/unit-testing.md` — Unit test patterns and examples
- `references/integration-testing.md` — Integration test setup and patterns
- `references/ddd-testing.md` — Testing DDD components (VO, Entity, Aggregate, Service)

Related Skills

aspire-integration-testing

16
from diegosouzapw/awesome-omni-skill

Write integration tests using .NET Aspire's testing facilities with xUnit. Covers test fixtures, distributed application setup, endpoint discovery, and patterns for testing ASP.NET Core apps with real dependencies.

ark-dashboard-testing

16
from diegosouzapw/awesome-omni-skill

Test Ark Dashboard with Playwright and create PRs with screenshots. Use when testing dashboard UI, taking screenshots for PRs, or reviewing dashboard changes.

api-security-testing

16
from diegosouzapw/awesome-omni-skill

API security testing workflow for REST and GraphQL APIs covering authentication, authorization, rate limiting, input validation, and security best practices.

android-e2e-testing-setup

16
from diegosouzapw/awesome-omni-skill

Setup UI Automator 2.4 smoke test for validating app launches (works with debug and release builds)

accessibility-testing

16
from diegosouzapw/awesome-omni-skill

WCAG compliance testing and accessibility quality assurance workflows for iOS apps. Use when validating accessibility labels, testing VoiceOver compatibility, checking contrast ratios, or ensuring WCAG 2.1 compliance. Covers accessibility tree analysis, semantic validation, and automated accessibility testing patterns.

acc-psr-overview-knowledge

16
from diegosouzapw/awesome-omni-skill

PHP Standards Recommendations (PSR) overview knowledge base. Provides comprehensive reference for all accepted PSRs including PSR-1,3,4,6,7,11,12,13,14,15,16,17,18,20. Use for PSR selection decisions and compliance audits.

acc-psr-coding-style-knowledge

16
from diegosouzapw/awesome-omni-skill

PSR-1 and PSR-12 coding standards knowledge base for PHP 8.5 projects. Provides quick reference for basic coding standard and extended coding style with detection patterns, examples, and antipattern identification. Use for code style audits and compliance reviews.

ab-testing

16
from diegosouzapw/awesome-omni-skill

Use when designing experiments for subject lines, offers, cadences, or journeys.

ab-testing-statistician

16
from diegosouzapw/awesome-omni-skill

Expert in statistical analysis for blind A/B and ABX audio testing. Validates randomization, calculates statistical significance, and ensures proper experimental design. Use when implementing A/B test features or analyzing test results.

a-b-testing

16
from diegosouzapw/awesome-omni-skill

The science of learning through controlled experimentation. A/B testing isn't about picking winners—it's about building a culture of validated learning and reducing the cost of being wrong. This skill covers experiment design, statistical rigor, feature flagging, analysis, and building experimentation into product development. The best experimenters know that every test, positive or negative, teaches something valuable. Use when "a/b test, experiment, hypothesis, statistical significance, sample size, feature flag, variant, control, treatment, p-value, conversion rate, test winner, split test, experimentation, testing, statistics, feature-flags, hypothesis, growth, optimization, learning, validation" mentioned.

web-testing

16
from diegosouzapw/awesome-omni-skill

Playwright automation, Chrome DevTools debugging, and browser interaction testing. Use for E2E/unit tests, capturing screenshots, inspecting network/console logs, or validating user flows in web applications.

qa-testing-mobile

16
from diegosouzapw/awesome-omni-skill

Mobile app testing strategy and execution for iOS and Android (native + cross-platform): choose automation frameworks, define device matrix, control flakes, validate performance/reliability/accessibility, and set CI + release gates. Use when you need a mobile QA plan, device lab/CI setup, or guidance on XCUITest/Espresso/Appium/Detox/Maestro/Flutter testing.