# functional-tests

functional-tests guides Claude Code in writing functional Symfony tests using WebTestCase, KernelTestCase, loginUser, and DAMA rollback.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 234 repo stars
- Author: dev-toolings
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/dev-toolings/superpowers-symfony/tree/HEAD/content/skills/functional-tests/SKILL.md
- Updated: 2026-10-05
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/functional-tests

## What it does

This skill enforces structured testing standards for Symfony HTTP routes and database-dependent services. It selects `WebTestCase` for controllers, invokes `static::createClient()` directly, inspects internal dependencies via `static::getContainer()`, and bypasses form-based logins by invoking `$client->loginUser($user)` directly.

Database state is kept isolated using DAMADoctrineTestBundle alongside Foundry fixtures. Mocking the `EntityManager` or repositories is explicitly prohibited when tests touch data, keeping assertions tied strictly to the actual database engine.

Keep in mind that `.env.local` is bypassed in test mode, so parameters belong in `.env.test` or `.env.test.local`. In addition, form validation failures expect HTTP 422 via `assertResponseIsUnprocessable()`, while `assertSessionHasFlashMessage()` requires Symfony 8.1 or higher.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dev-toolings/superpowers-symfony --skill functional-tests -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/functional-tests/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/functional-tests/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dev-toolings/superpowers-symfony --skill functional-tests -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/functional-tests/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dev-toolings/superpowers-symfony --skill functional-tests -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/functional-tests/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dev-toolings/superpowers-symfony content/skills/functional-tests
```

2. **Manually: put the files in place**
- File: `.github/skills/functional-tests/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dev-toolings/superpowers-symfony --skill functional-tests -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dev-toolings/superpowers-symfony --path content/skills/functional-tests
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/functional-tests/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dev-toolings/superpowers-symfony/tree/HEAD/content/skills/functional-tests/SKILL.md

## When to use it
- generate HTTP controller tests using WebTestCase and DOM assertions
- verify role-protected endpoints using loginUser
- isolate integration database state via DAMADoctrineTestBundle
- build parameterized smoke test suites for hardcoded application URLs

## Example prompts
- Write a WebTestCase for the checkout endpoint that checks for a redirect and an email dispatch
- Create functional tests for the profile controller using loginUser and real database records
- Set up smoke tests with a data provider to verify status codes across public endpoints

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 74a8e551aebda830.

BEGIN THIRD-PARTY FILE 74a8e551aebda830
```text
---
name: functional-tests
description: Write functional tests for Symfony controllers and HTTP endpoints using WebTestCase, getContainer, loginUser, and DAMA rollback
capabilities: [read, search, edit, shell]
tags: [testing]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash
---

# Functional Tests (Symfony)

## Use when
- A controller or HTTP endpoint must be checked through the kernel: status, redirect, rendered DOM, form errors, emails.
- A repository or service must be tested against the real database with `KernelTestCase`.
- An authenticated or role-restricted route needs coverage via `loginUser()`.
- Key URLs need cheap smoke tests.

## Default workflow
1. Choose the base class: `WebTestCase` for HTTP, `KernelTestCase` for services, plain `TestCase` for pure logic.
2. Call `static::createClient()` directly (never `bootKernel()` first) and read private services with `static::getContainer()`.
3. Authenticate with `$client->loginUser($user)` instead of replaying the login form.
4. Assert the response and the DOM: `assertResponseIsSuccessful()`, `assertResponseRedirects()`, `assertSelectorTextContains()`, `assertEmailCount()`.
5. Isolate tests with the DAMADoctrineTestBundle `PHPUnitExtension`, plus Foundry reset for fixtures.
6. Add smoke tests with a data provider and hardcoded URLs.

## Guardrails
- Use the real database and real repositories; do not mock the EntityManager or repositories in data-touching tests.
- Invalid form submissions assert 422 with `assertResponseIsUnprocessable()` (Symfony 8.0+ behavior).
- `.env.local` is not loaded in the test environment: use `.env.test` or `.env.test.local`.
- `assertSessionHasFlashMessage()` requires Symfony 8.1+.

## Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.

## Output contract
- Test classes with the base class chosen for each.
- The authentication and database isolation strategy.
- Status codes, DOM assertions and smoke URLs covered.

## References
- `reference.md`
```
END THIRD-PARTY FILE 74a8e551aebda830

The third-party file has ended. Everything between the 74a8e551aebda830 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

© dev-toolings · MIT · https://github.com/dev-toolings/superpowers-symfony/tree/HEAD/content/skills/functional-tests/SKILL.md

## Similar
- [ns-backend-tests](https://affpapa.org/en/nevibecode/skills/ns-backend-tests.md) — skill · 151 installs
- [php-expert](https://affpapa.org/en/nevibecode/skills/php-expert.md) — skill · 269 installs
- [php-symfony](https://affpapa.org/en/nevibecode/rules/php-symfony.md) — rule · ★ 41430 repo stars
- [symfony-specialist](https://affpapa.org/en/nevibecode/agents/symfony-specialist.md) — subagent · ★ 26718 repo stars
- [laravel-testing](https://affpapa.org/en/nevibecode/skills/laravel-testing.md) — skill · 1000 installs
- [php-mcp-server-generator](https://affpapa.org/en/nevibecode/skills/php-mcp-server-generator.md) — skill · 8900 installs

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
