Commit 8420a00d authored by Anton Smirnov's avatar Anton Smirnov
Browse files

Test for zero increment

parent b94c3931
Loading
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -279,4 +279,18 @@ class SequenceUlidTest extends TestCase
            }
        }
    }

    public function testNoZeroIncrement(): void
    {
        // since ulid is the only sequence with random increment, test that it is never zero
        $clock = StaticClock::fromTimestamp(1701394201);
        $randomizer = new Randomizer(new FixedSequenceEngine("\0"));

        $seq = SequenceFactory::ulid(false, $clock, $randomizer);

        self::assertEquals('01HGHFYED80000000000000000', $seq->next()->toString());
        self::assertEquals('01HGHFYED80000000000000001', $seq->next()->toString()); // +1
        self::assertEquals('01HGHFYED80000000000000002', $seq->next()->toString()); // +1
        self::assertEquals('01HGHFYED80000000000000003', $seq->next()->toString()); // +1
    }
}