This document defines the testing strategy used by the Symfony UX Starter Kit.
The goal is to ensure:
All tests must follow these conventions.
Mandatory tools:
Optional future additions:
The starter kit contains:
Purpose:
Validate application behavior through HTTP requests.
Examples:
Location:
tests/Functional/
Purpose:
Validate isolated PHP logic.
Location:
tests/Unit/
All functional tests must inherit from a shared abstract class.
Location:
tests/AbstractWebTestCase.php
Purpose:
Centralize common utilities.
Examples:
Good:
final class HomeControllerTest extends AbstractWebTestCase
{
public function testHomePageIsAccessible(): void
{
}
}
Bad:
final class HomeControllerTest extends WebTestCase
{
}
Always use the shared base class.
Tests must never depend on:
Tests must prepare their own data.
"zenstruck/foundry" is already available, use only Factories and Stories to create fixtures
Never use anything else for fixtures
doctrine/doctrine-fixtures-bundle is forbidden
Fixtures should be reusable.
Fixtures must remain generic.
Examples:
Admin User
Regular User
Avoid business fixtures in the starter.
Bad:
CustomerFixture
InvoiceFixture
ProductFixture
Expected helper:
protected function refreshDatabase(): void
Purpose:
Reset database state between tests.
Implementation may vary depending on future tooling.
Good:
testHomePageIsAccessible()
testAuthenticatedUserCanAccessAccount()
testAnonymousUserIsRedirectedToLogin()
Bad:
test1()
testPage()
testAccount()
Names should describe behavior.
Assertions should be explicit.
Good:
self::assertResponseIsSuccessful();
self::assertSelectorTextContains(
'h1',
'Home'
);
Bad:
self::assertTrue(true);
Reusable components should be tested when behavior exists.
Examples:
Live Components
Twig Components
Simple presentation-only components do not necessarily require dedicated tests.
Live Components must be tested.
Verify:
Forms should validate:
Upload features should verify:
Avoid raw SQL assertions when possible.
Prefer:
$userRepository->find(...)
or:
self::assertCount(...)
Mock only external dependencies.
Examples:
Avoid mocking Doctrine entities.
Avoid mocking repositories without justification.
Arrange:
// Arrange
Act:
// Act
Assert:
// Assert
Pattern should be preferred.
A test must never depend on:
Each test must be executable independently.
The following command must succeed:
make test
before merging any change.
Before considering a feature complete:
Testing quality is mandatory.
No feature is complete without tests.
How can I help you explore Laravel packages today?