sequence->isAvailable()) { $this->markTestSkipped('Sequence ID generator ' . get_class($this->sequence) . 'is’nt available. Skip'); } $nb = 1000; $ids = []; $server = 42; for ($i = 0; $i < $nb; ++$i) { $time = explode('.', (string)microtime(true)); $seconds = (int)$time[0]; $milliseconds = str_pad(substr($time[1] ?? '0', 0, 3), 3, '0'); $id = $this->sequence->nextId($server, $seconds, (int)$milliseconds); $ids[] = sprintf('%d_%s_%d', $seconds, $milliseconds, $id); usleep(100); } // Is it unique? $this->assertCount($nb, array_unique($ids)); // Is it sequential? $sortedIds = $ids; natsort($sortedIds); $this->assertSame($sortedIds, $ids); } }