@@ -398,13 +398,16 @@ of the UUID parameters::
398398 }
399399 }
400400
401- MockUuidFactory
402- ===============
401+ Testing UUIDs
402+ ~~~~~~~~~~~~~
403403
404- The:class: `Symfony\\ Component\\ Uid\\ Factory\\ MockUuidFactory ` class allows you to
405- control the UUIDs generated during your tests, making them predictable and reproducible.
404+ Many UUID versions include random or time-dependent parts, which makes them
405+ hard to use in tests. The:class: `Symfony\\ Component\\ Uid\\ Factory\\ MockUuidFactory `
406+ class allows you to control the UUIDs generated during your tests, making them
407+ predictable and reproducible.
406408
407- Suppose you have a service that generates a UUID for each new user::
409+ First, make sure that your service generates UUID values using the
410+ :class: `Symfony\\ Component\\ Uid\\ Factory\\ UuidFactory `::
408411
409412 use Symfony\Component\Uid\Factory\UuidFactory;
410413 use Symfony\Component\Uid\Uuid;
@@ -422,15 +425,16 @@ Suppose you have a service that generates a UUID for each new user::
422425 }
423426 }
424427
425- In your tests, you can use ``MockUuidFactory `` to inject predictable UUIDs and verify the expected behavior::
428+ Then, in your tests, you can use ``MockUuidFactory `` to define a sequence of the
429+ UUIDs that will be returned each time you generate one::
426430
427431 use PHPUnit\Framework\TestCase;
428432 use Symfony\Component\Uid\Factory\MockUuidFactory;
429433 use Symfony\Component\Uid\UuidV4;
430434
431435 class UserServiceTest extends TestCase
432436 {
433- public functiontestCreateUserIdReturnsExpectedUuid()
437+ public functiontestCreateUserId(): void
434438 {
435439 $factory = new MockUuidFactory([
436440 UuidV4::fromString('11111111-1111-4111-8111-111111111111'),
@@ -444,15 +448,14 @@ In your tests, you can use ``MockUuidFactory`` to inject predictable UUIDs and v
444448 }
445449 }
446450
447- .. warning ::
448-
449- `` MockUuidFactory `` is intended for use intests only and should never be used in production .
451+ In addition to the `` create() `` method, the `` MockUuidFactory `` also works for
452+ the `` randomBased() ``, `` timeBased() ``, and `` nameBased() `` methods. You can even
453+ mix different UUID versions inthe same sequence .
450454
451455..note ::
452456
453- - Supports the:method: `Symfony\\ Component\\ Uid\\ Factory\\ MockUuidFactory::create `,:method: `Symfony\\ Component\\ Uid\\ Factory\\ MockUuidFactory::randomBased `,:method: `Symfony\\ Component\\ Uid\\ Factory\\ MockUuidFactory::timeBased `, and:method: `Symfony\\ Component\\ Uid\\ Factory\\ MockUuidFactory::nameBased ` methods.
454- - You can mix different UUID versions in the same sequence.
455- - Throws an exception if the sequence is exhausted or the type does not match.
457+ ``MockUuidFactory `` throws an exception if the sequence is exhausted or the
458+ available UUID types don't match the requested type.
456459
457460.. _ulid :
458461