Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0747e04

Browse files
authored
docs: document Faker reproducibility (#860)
1 parent 22c3c47 commit 0747e04

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

docs/index.rst

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,8 +565,7 @@ random data for your factories:
565565

566566
.. note::
567567

568-
You can customize Faker's `locale <https://fakerphp.org/#localization>`_ and random
569-
`seed <https://fakerphp.org/#seeding-the-generator>`_:
568+
You can customize Faker's `locale <https://fakerphp.org/#localization>`_:
570569

571570
.. code-block:: yaml
572571
@@ -575,7 +574,6 @@ random data for your factories:
575574
zenstruck_foundry:
576575
faker:
577576
locale: fr_FR # set the locale
578-
seed: 5678 # set the random number generator seed
579577
580578
.. note::
581579

@@ -598,6 +596,29 @@ random data for your factories:
598596
faker:
599597
service: my_faker # service id for your own instance of Faker\Generator
600598
599+
Reproducibility
600+
...............
601+
602+
Foundry sets a different random seed for each PHPUnit run. This means that Faker will generate different data on each run.
603+
If you're using Foundry's `PHPUnit Extension`_, it will automatically display the seed used for each test run.
604+
605+
You can also freeze the seed, by using the environment variable ``FOUNDRY_FAKER_SEED``:
606+
607+
.. code-block:: terminal
608+
609+
$ FOUNDRY_FAKER_SEED=1234 vendor/bin/phpunit
610+
611+
................................... 35 / 35 (100%)
612+
613+
Faker seed: 1234
614+
615+
Time: 00:00.047, Memory: 48.50 MB
616+
617+
.. versionadded:: 2.4
618+
619+
Support for ``FOUNDRY_FAKER_SEED`` was added in 2.4.
620+
621+
601622
Hooks
602623
~~~~~
603624

@@ -2491,9 +2512,6 @@ Full Default Bundle Configuration
24912512
# Change the default faker locale.
24922513
locale: null # Example: fr_FR
24932514
2494-
# Random number generator seed to produce the same fake values every run
2495-
seed: null # Example: '1234'
2496-
24972515
# Customize the faker service.
24982516
service: null # Example: my_faker
24992517

0 commit comments

Comments
 (0)