agentleFS
gerard-labsgerard-labs/superpowers-api-platform/skills/functional-tests/SKILL.md

functional-tests

Skill2 starsChanged 6 months agoMITView on GitHub

Write Symfony functional tests for non-API HTTP endpoints (server-rendered pages, form submissions, redirects, auth flows) with `WebTestCase` + `BrowserKit` + `DomCrawler` + Foundry — drives RED-GREEN-REFACTOR TDD on controllers, asserts response codes / redirects / form errors / CSRF, exercises authenticated and anonymous clients, integrates with DAMA Doctrine test bundle for transaction rollback per test, and uses ParaTest for parallel execution. Distinct from `gerard:api-platform-tests` (which targets REST / JSON-LD via `ApiTestCase`). Trigger on "WebTestCase", "test a controller", "test a form submission", "redirect after POST", "test CSRF", "convert bug report into a failing test", or "functional test for server-rendered page".

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    CSRF on by default: If a form omits CSRF in the test, the test should fail.

    line 33

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Functional tests (Symfony — non-API)

Use when

  • Writing functional tests for server-rendered controllers (Twig pages, form submissions, admin areas).
  • Converting a bug report into a failing test (RED-GREEN-REFACTOR).
  • Exercising authentication flows (login form, redirects, access-denied).
  • Asserting form validation errors, CSRF, redirects, flash messages.

For REST / JSON-LD endpoints exposed by API Platform, use gerard:api-platform-tests instead — it covers ApiTestCase, schema assertions, JSON-LD pagination shape, JWT clients, etc.

Default workflow

  1. RED: write a failing functional test that captures the target behavior.
  2. GREEN: implement the smallest controller / form change that makes the test green.
  3. REFACTOR: clean up controller and template while the test stays green.
  4. Broaden coverage to authorization (anonymous / forbidden / authorized) and error paths.

Guardrails

  • Assert observable behavior, not internal state. Status codes, redirects, rendered content, flash messages — not service internals.
  • Deterministic fixtures. Foundry factories or ResetDatabase / DAMA transaction rollback per test.
  • No order coupling. Each test starts from a clean state.
  • CSRF on by default. If a form omits CSRF in the test, the test should fail.
  • Real templates render — don't mock the renderer in functional tests; the goal is the full HTTP stack.

Progressive disclosure

  • SKILL.md covers posture and rules.
  • reference.md carries the full patterns: WebTestCase skeleton, login helpers, form submission, redirect assertions, flash messages, CSRF, DAMA setup, scenario-based naming, ParaTest invocation.

Output contract

  • A tests/Functional/<Area>/<Feature>Test.php extending WebTestCase.
  • Tests covering happy path + anonymous + forbidden + invalid form paths.
  • DAMA / ResetDatabase guarantees test isolation.

References

  • reference.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.