Update dependencies
Composer: Laravel 13.43, Octane 2.25, Fortify 1.43 and Pest 5.3.7, with the packages they bring (70 in all). This fixes the advisories in Laravel and the Symfony components. npm: Vite 8.3.8 with Rolldown 1.2.19, Playwright 1.65.1 and chokidar 6. The asset build, CI and the dev container use Node.js 26. The dev image also has git for Composer. Both audits are clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
# Factories and Test Data
|
||||
# Factories and test data
|
||||
|
||||
## Each Test Makes Its Own Data
|
||||
## Each test makes its own data
|
||||
|
||||
Create mutable records inside the test that uses them. This keeps setup visible and lets each test select its factory state.
|
||||
Create mutable records inside the test that uses them. The setup then stays visible, and each test can select its factory state.
|
||||
|
||||
Use `beforeEach()` only for configuration that applies to every test in the file. Do not create records in it.
|
||||
|
||||
## Record Construction
|
||||
## Record construction
|
||||
|
||||
- Use `create()` if the test needs the record in the database.
|
||||
- Use `make()` only if the test does not need the database. Examples include rendering a notification and testing a value object's behavior.
|
||||
- Use a named factory state instead of a raw attribute. `User::factory()->unverified()->create()` gives the state meaning; `create(['email_verified_at' => null])` gives only its value.
|
||||
- Use a named factory state instead of a raw attribute. `User::factory()->unverified()->create()` gives the state meaning. `create(['email_verified_at' => null])` gives only its value.
|
||||
- Use `for()` or the relationship helper of the project to declare the owner of a record.
|
||||
- Use `recycle()` if several records must share one parent record.
|
||||
- Use `sequence()` if several records need different attributes.
|
||||
- If several records must share one parent record, use `recycle()`.
|
||||
- If several records need different attributes, use `sequence()`.
|
||||
|
||||
```php
|
||||
$organization = Organization::factory()->onPlan(BillingPlan::PRO)->create();
|
||||
@@ -51,6 +51,6 @@ Use parameterized tests for:
|
||||
- input values that are invalid in the same way
|
||||
- input and output value pairs
|
||||
|
||||
Write separate tests if the cases need a different setup, a different behavior, or different assertions. One test function with a branch in the body is two tests in one function.
|
||||
If the cases need a different setup, a different behavior, or different assertions, write separate tests. One test function with a branch in the body is two tests in one function.
|
||||
|
||||
Give each dataset case a name that states the difference. A failure then identifies the case without requiring you to count positions.
|
||||
|
||||
Reference in New Issue
Block a user