functional-tests
Installation
SKILL.md
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
- Choose the base class:
WebTestCasefor HTTP,KernelTestCasefor services, plainTestCasefor pure logic. - Call
static::createClient()directly (neverbootKernel()first) and read private services withstatic::getContainer(). - Authenticate with
$client->loginUser($user)instead of replaying the login form. - Assert the response and the DOM:
assertResponseIsSuccessful(),assertResponseRedirects(),assertSelectorTextContains(),assertEmailCount(). - Isolate tests with the DAMADoctrineTestBundle
PHPUnitExtension, plus Foundry reset for fixtures. - Add smoke tests with a data provider and hardcoded URLs.