File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 22
33use DirectoryTree \Dummy \Tests \Fixtures \FactoryClassStub ;
44use DirectoryTree \Dummy \Tests \Fixtures \FactoryStub ;
5+ use DirectoryTree \Dummy \Tests \Fixtures \FactoryWithConfigurationStub ;
56use DirectoryTree \Dummy \Tests \Fixtures \FactoryWithCustomClassStub ;
67use DirectoryTree \Dummy \Tests \Fixtures \FactoryWithStateStub ;
78use Illuminate \Support \Collection ;
119120 expect ($ instance ->name )->toBe ('Admin ' );
120121 expect ($ instance ->email )->toBe ('admin@example.com ' );
121122});
123+
124+ it ('can use after making callbacks ' , function () {
125+ $ instance = FactoryWithConfigurationStub::new ()->make ();
126+
127+ expect ($ instance ->name )->toBe ('Custom ' );
128+ });
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace DirectoryTree \Dummy \Tests \Fixtures ;
4+
5+ use DirectoryTree \Dummy \Factory ;
6+ use Illuminate \Support \Fluent ;
7+
8+ class FactoryWithConfigurationStub extends Factory
9+ {
10+ protected function definition (): array
11+ {
12+ return [
13+ 'name ' => $ this ->faker ->name (),
14+ 'email ' => $ this ->faker ->email (),
15+ ];
16+ }
17+
18+ protected function configure (): static
19+ {
20+ return $ this ->afterMaking (function (Fluent $ fluent ) {
21+ $ fluent ->name = 'Custom ' ;
22+ });
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments