laravel-testing
Installation
SKILL.md
Laravel Testing
Use this when writing, changing, or running tests in a Laravel codebase.
Test-Database Safety — Non-Negotiable
- Tests must run against disposable storage or a dedicated test database whose name clearly contains
test(e.g.app_test,myapp_testing). Never run tests against staging, production, demo, or any shared operational database. - Verify
phpunit.xml/.env.testingpoints at a test-only connection before running the suite for the first time in a new environment. Sqlite in-memory (:memory:) is the safest default for fast feature/unit tests when the app doesn't rely on database-specific SQL. - If a test requires a real MySQL/PostgreSQL instance (e.g. testing vendor-specific SQL), the connection's database name must still contain
test— do not pointDB_DATABASEat a copy of production data to "make tests realistic." - Never seed a test run from a staging/production backup. Build realistic data with factories/seeders instead (see below).
- This rule overrides convenience. A fast local hack that points tests at a real environment is not an acceptable shortcut, even temporarily.