Testing Pyramid logo

Testing Pyramid

Community
fatonh
testing-pyramid

Use when writing tests for a Symfony app — unit, integration (Kernel), and functional (WebTestCase) tests, the test database, fixtures/factories (Foundry), and what to mock. Use when the task mentions test, PHPUnit, WebTestCase, KernelTestCase, fixtures, or coverage.

Overview

Publisherfatonh
Repositorysymfony-skills
Skill nametesting-pyramid
Stars
36
Forks
3
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by fatonh on GitHub. Read the source before you install it.

Installation

Install the Testing Pyramid AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/fatonh/symfony-skills/tree/main/skills/testing-pyramid
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fatonh/symfony-skills.git /tmp/symfony-skills
mkdir -p .claude/skills
cp -r /tmp/symfony-skills/skills/testing-pyramid .claude/skills/testing-pyramid
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Testing Pyramid in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Testing Pyramid on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Testing Pyramid is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Testing Pyramid (Symfony + PHPUnit)

The shape

        ╱╲        Functional (few)   — WebTestCase: real HTTP kernel, real DB, full stack
       ╱──╲       Integration (some) — KernelTestCase: container + DB, no HTTP
      ╱────╲      Unit (many)        — plain PHPUnit: pure PHP, no container, no DB
     ╱──────╲

Most tests are fast unit tests of domain logic. A smaller layer of integration tests covers wiring + persistence. A thin top layer of functional tests covers the critical user-facing flows end-to-end. Don't invert it — a suite that's all WebTestCase is slow and brittle.

Unit tests — domain logic, no framework

Test value objects, aggregates, and services with their collaborators mocked. No container, no DB, milliseconds each.

php
final class OrderTest extends TestCase
{
    public function test_confirming_an_empty_order_is_rejected(): void
    {
        $order = Order::place();

        $this->expectException(\DomainException::class);
        $order->confirm();                       // invariant: can't confirm empty
    }

    public function test_adding_a_line_to_a_confirmed_order_is_rejected(): void
    {
        $order = Order::place();
        $order->addItem(Uuid::v7(), 2);
        $order->confirm();

        $this->expectException(\DomainException::class);
        $order->addItem(Uuid::v7(), 1);
    }
}

Mock only what you own and inject (ports/repositories). Don't mock value objects or the framework.

php
// ✅ mock the repository PORT
$orders = $this->createMock(OrderRepository::class);
$orders->method('ofId')->willReturn($existingOrder);
$service = new CancelOrderHandler($orders);

Integration tests — wiring + persistence

KernelTestCase boots the container; pull real services and hit a real (test) database. Use it to verify repository queries, Doctrine mapping, and service wiring.

php
final class OrderRepositoryTest extends KernelTestCase
{
    private EntityManagerInterface $em;
    private OrderRepository $repo;

    protected function setUp(): void
    {
        self::bootKernel();
        $this->em = self::getContainer()->get(EntityManagerInterface::class);
        $this->repo = self::getContainer()->get(OrderRepository::class);
    }

    public function test_find_active_by_customer_returns_only_active(): void
    {
        OrderFactory::createOne(['customerEmail' => 'a@x.io', 'status' => OrderStatus::Active]);
        OrderFactory::createOne(['customerEmail' => 'a@x.io', 'status' => OrderStatus::Cancelled]);

        $result = $this->repo->findActiveByCustomer('a@x.io');

        self::assertCount(1, $result);
    }
}

Functional tests — the real HTTP stack

WebTestCase sends a real request through the kernel. Reserve it for critical flows and contract checks (status codes, problem+json shape, auth).

php
final class CreateOrderTest extends WebTestCase
{
    public function test_post_orders_returns_201_with_location(): void
    {
        $client = static::createClient();

        $client->request('POST', '/api/orders', server: [
            'CONTENT_TYPE' => 'application/json',
        ], content: json_encode([
            'customerEmail' => 'buyer@example.com',
            'items' => [['productId' => Uuid::v7()->toRfc4122(), 'quantity' => 2]],
        ]));

        self::assertResponseStatusCodeSame(201);
        self::assertResponseHasHeader('Location');
    }

    public function test_invalid_payload_returns_422_problem_json(): void
    {
        $client = static::createClient();
        $client->request('POST', '/api/orders', content: json_encode(['customerEmail' => 'not-an-email']));

        self::assertResponseStatusCodeSame(422);
        self::assertResponseHeaderSame('Content-Type', 'application/problem+json');
    }
}

The test database

  • A separate DB for test (.env.test / DATABASE_URL); never run tests against dev/prod data.
  • Reset state between tests with DAMA\DoctrineTestBundle (wraps each test in a transaction and rolls back) — far faster than truncating.
  • Build schema from migrations in CI so tests catch migration drift.
bash
php bin/console --env=test doctrine:database:create
php bin/console --env=test doctrine:migrations:migrate --no-interaction

Fixtures via factories (Foundry / Zenstruck)

Prefer zenstruck/foundry factories over static fixture files — readable, overridable per test, no shared mutable state.

php
final class OrderFactory extends PersistentProxyObjectFactory
{
    public static function class(): string { return Order::class; }

    protected function defaults(): array
    {
        return [
            'customerEmail' => self::faker()->email(),
            'status' => OrderStatus::Pending,
        ];
    }
}

// In a test
$order = OrderFactory::createOne(['status' => OrderStatus::Active]);
OrderFactory::createMany(5);

Conventions

  • Name tests by behavior: test_confirming_an_empty_order_is_rejected, not testConfirm.
  • Arrange / Act / Assert structure; one logical assertion target per test.
  • Don't assert on private internals — test observable behavior.
  • Keep functional tests few and focused on contracts; push logic coverage down to unit tests.
  • No network calls in tests — mock HTTP clients (MockHttpClient).

Gotchas

  • Agent writes everything as WebTestCase — invert back to a pyramid: most logic in fast unit tests.
  • Agent mocks the entity / value object under test — only mock injected ports/collaborators.
  • Agent hits dev/prod DB or shares state across tests — use a test DB + DAMA transaction rollback.
  • Agent builds the test schema with schema:update — run migrations so tests catch drift.
  • Agent makes real HTTP/API calls in tests — use MockHttpClient.
  • Agent writes brittle assertions on serialized internals — assert status codes, headers, and visible fields.
  • Agent uses static SQL fixture dumps — use Foundry factories for readable, isolated data.
  • Agent forgets to assert the application/problem+json content type on error-path tests.

Frequently asked questions

What does the Testing Pyramid AI skill do?

Use when writing tests for a Symfony app — unit, integration (Kernel), and functional (WebTestCase) tests, the test database, fixtures/factories (Foundry), and what to mock. Use when the task mentions test, PHPUnit, WebTestCase, KernelTestCase, fixtures, or coverage.

Why use Testing Pyramid on TypingMind?

Because you install it once and use it with any model. Testing Pyramid is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Testing Pyramid in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/fatonh/symfony-skills/tree/main/skills/testing-pyramid. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Testing Pyramid?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Testing Pyramid?

As many as you like. As long as a model supports skills, you can use Testing Pyramid with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Testing Pyramid AI skill free?

Yes. It is published on GitHub by fatonh under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇