Skip to content

Commit ed55ea4

Browse files
docs: updates CHANGELOG
1 parent 7c2d80d commit ed55ea4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to `request-factories` will be documented in this file.
44

5+
## 2.4.0 - 2022-09-13
6+
7+
- Added support for lazily resolving model factories [#24](https://github.com/worksome/request-factories/pull/24)
8+
- Closures, nested request factories and model factories now work in infinitely nested arrays [#24](https://github.com/worksome/request-factories/pull/24)
9+
510
## 2.3.0 - 2022-09-01
611

712
- Added a handy `RequestFactory::image` method as a shortcut for `$factory->file()->image('name.png')` [#23](https://github.com/worksome/request-factories/pull/23)

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@ Now, when the `SignupRequestFactory` is created, it will resolve the `AddressReq
342342
and fill the `address` property with all fields contained in the `AddressRequestFactory` definition.
343343
Pretty cool hey?
344344

345+
Request factories work hand in hand with model factories too. Imagine that you want to pass a `User` ID
346+
to your form request, but you need to create the user in the database in order to do so. It's as simple
347+
as instantiating the `UserFactory` in your request factory definition:
348+
349+
```php
350+
class StoreMovieController extends RequestFactory
351+
{
352+
public function definition(): array
353+
{
354+
return [
355+
'name' => 'My Cool Movie'
356+
'owner_id' => User::factory(),
357+
];
358+
}
359+
}
360+
```
361+
362+
Because the `UserFactory` isn't created until compile time, we avoid any unexpected models being persisted to your test database
363+
when you manually override the `owner_id` field.
364+
345365
### Using factories without form requests
346366

347367
Not every controller in your app requires a backing form request. Thankfully, we also support faking a generic request:

0 commit comments

Comments
 (0)