@@ -134,7 +134,7 @@ class Post
134
134
* @ORM\Column(type="text", nullable=true)
135
135
*/
136
136
private $body;
137
-
137
+
138
138
/**
139
139
* @ORM\Column(type="datetime")
140
140
*/
@@ -397,7 +397,7 @@ $posts = PostFactory::new(['title' => 'Post A'])
397
397
'body' => 'Post Body...',
398
398
399
399
// CategoryFactory will be used to create a new Category for each Post
400
- 'category' => CategoryFactory::new(['name' => 'php']),
400
+ 'category' => CategoryFactory::new(['name' => 'php']),
401
401
])
402
402
->withAttributes([
403
403
// Proxies are automatically converted to their wrapped object
@@ -481,7 +481,7 @@ PostFactory::new()
481
481
// $object is the persisted Post object
482
482
// $attributes contains the attributes used to instantiate the object and any extras
483
483
})
484
-
484
+
485
485
// multiple events are allowed
486
486
->beforeInstantiate(function($attributes) { return $attributes; })
487
487
->afterInstantiate(function() {})
@@ -524,7 +524,7 @@ final class PostFactory extends ModelFactory
524
524
return new Post(); // custom instantiation for this factory
525
525
})
526
526
->afterPersist(function () {}) // default event for this factory
527
- ;
527
+ ;
528
528
}
529
529
}
530
530
```
@@ -662,7 +662,7 @@ protected function getDefaults(): array
662
662
'post' => PostFactory::new()->published(),
663
663
664
664
// NOT RECOMMENDED - will potentially result in extra unintended Posts
665
- 'post' => PostFactory::createOne(),
665
+ 'post' => PostFactory::createOne(),
666
666
'post' => PostFactory::new()->published()->create(),
667
667
];
668
668
}
@@ -964,7 +964,7 @@ Foundry allows each individual test to fully follow the [AAA](https://www.thephi
964
964
("Arrange", "Act", "Assert") testing pattern. You create your fixtures using "factories" at the beginning of each test.
965
965
You only create fixtures that are applicable for the test. Additionally, these fixtures are created with only the
966
966
attributes required for the test - attributes that are not applicable are filled with random data. The created fixture
967
- objects are wrapped in a "proxy" that helps with pre and post assertions.
967
+ objects are wrapped in a "proxy" that helps with pre and post assertions.
968
968
969
969
Let's look at an example:
970
970
@@ -978,7 +978,7 @@ public function test_can_post_a_comment(): void
978
978
'slug' => 'post-a' // This test only requires the slug field - all other fields are random data
979
979
])
980
980
;
981
-
981
+
982
982
// 1a. "Pre-Assertions"
983
983
$this->assertCount(0, $post->getComments());
984
984
@@ -1038,7 +1038,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1038
1038
class MyTest extends WebTestCase
1039
1039
{
1040
1040
use ResetDatabase, Factories;
1041
-
1041
+
1042
1042
// ...
1043
1043
}
1044
1044
```
@@ -1370,7 +1370,7 @@ these tests to be unnecessarily slow. You can improve the speed by reducing the
1370
1370
class UserFactory extends ModelFactory
1371
1371
{
1372
1372
public const DEFAULT_PASSWORD = '1234'; // the password used to create the pre-encoded version below
1373
-
1373
+
1374
1374
protected function getDefaults(): array
1375
1375
{
1376
1376
return [
@@ -1412,7 +1412,7 @@ class MyUnitTest extends TestCase
1412
1412
}
1413
1413
```
1414
1414
1415
- ** NOTE** : [ Factories as Services] ( #factories-as-services ) and [ Stories as Services] ( #stories-as-services ) with required
1415
+ ** NOTE** : [ Factories as Services] ( #factories-as-services ) and [ Stories as Services] ( #stories-as-services ) with required
1416
1416
constructor arguments are not usable in non-Kernel tests. The container is not available to resolve their dependencies.
1417
1417
The easiest work-around is to make the test an instance of ` Symfony\Bundle\FrameworkBundle\Test\KernelTestCase ` so the
1418
1418
container is available.
0 commit comments