Skip to content

Commit bfd7147

Browse files
authored
tests: eliminate PK collision (#22)
1 parent 15421c1 commit bfd7147

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

tests/Fixtures/Blog/PrimaryKey.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace ShipMonkTests\DoctrineEntityPreloader\Fixtures\Blog;
44

55
use function base64_encode;
6-
use function random_int;
76

87
class PrimaryKey
98
{
109

1110
public const DOCTRINE_TYPE_NAME = 'primary_key';
12-
public const LENGTH_BYTES = 4;
11+
12+
private static int $autoIncrement = 0;
1313

1414
private int $data;
1515

@@ -20,10 +20,7 @@ public function __construct(int $data)
2020

2121
public static function new(): self
2222
{
23-
$bits = self::LENGTH_BYTES * 8;
24-
$maxValue = (1 << $bits) - 1;
25-
26-
return new self(random_int(0, $maxValue));
23+
return new self(self::$autoIncrement++);
2724
}
2825

2926
public function getData(): int

tests/Fixtures/Blog/Type/PrimaryKeyBinaryType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getSQLDeclaration(
5656
): string
5757
{
5858
return $platform->getBinaryTypeDeclarationSQL([
59-
'length' => PrimaryKey::LENGTH_BYTES,
59+
'length' => 4,
6060
'fixed' => true,
6161
]);
6262
}

0 commit comments

Comments
 (0)