Skip to content

Commit 9602bdd

Browse files
committed
Fix test to use a random string as ID
#1525
1 parent 129d704 commit 9602bdd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/Tests/Functional/Ticket/GH1525Test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
use Doctrine\Common\Collections\ArrayCollection;
88
use Doctrine\Common\Collections\Collection;
9-
use Doctrine\ODM\MongoDB\Id\UuidGenerator;
109
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
1110
use Doctrine\ODM\MongoDB\Tests\BaseTestCase;
1211

12+
use function bin2hex;
13+
use function random_bytes;
14+
1315
class GH1525Test extends BaseTestCase
1416
{
1517
public function testEmbedCloneTwoFlushesPerDocument(): void
@@ -46,12 +48,11 @@ public function testEmbedCloneTwoFlushesPerDocument(): void
4648

4749
public function testEmbedCloneWithIdStrategyNoneOnParentAndEarlyPersist(): void
4850
{
49-
$uuidGen = new UuidGenerator();
5051
$embedded = new GH1525Embedded('embedded');
5152

5253
$count = 2;
5354
for ($i = 0; $i < $count; ++$i) {
54-
$parent = new GH1525DocumentIdStrategyNone($uuidGen->generateV4(), 'test' . $i);
55+
$parent = new GH1525DocumentIdStrategyNone(bin2hex(random_bytes(6)), 'test' . $i);
5556
$this->dm->persist($parent);
5657
$parent->embedded = $embedded;
5758
$this->dm->flush();
@@ -71,12 +72,11 @@ public function testEmbedCloneWithIdStrategyNoneOnParentAndEarlyPersist(): void
7172

7273
public function testEmbedCloneWithIdStrategyNoneOnParentAndLatePersist(): void
7374
{
74-
$uuidGen = new UuidGenerator();
7575
$embedded = new GH1525Embedded('embedded');
7676

7777
$count = 2;
7878
for ($i = 0; $i < $count; ++$i) {
79-
$parent = new GH1525DocumentIdStrategyNone($uuidGen->generateV4(), 'test' . $i);
79+
$parent = new GH1525DocumentIdStrategyNone(bin2hex(random_bytes(6)), 'test' . $i);
8080
$parent->embedded = $embedded;
8181
$this->dm->persist($parent);
8282
$this->dm->flush();

0 commit comments

Comments
 (0)