diff --git a/tests/RedisSequenceResolverTest.php b/tests/RedisSequenceResolverTest.php index 843e2cc..f318fd9 100644 --- a/tests/RedisSequenceResolverTest.php +++ b/tests/RedisSequenceResolverTest.php @@ -13,7 +13,6 @@ namespace Tests; use Godruoyi\Snowflake\RedisSequenceResolver; -use Godruoyi\Snowflake\Snowflake; use RedisException; class RedisSequenceResolverTest extends TestCase @@ -69,19 +68,17 @@ public function test_real_redis(): void $redis = new \Redis(); $redis->connect($host, $port | 0); - // Sometimes running these tests in parallel on Github may cause unexpected errors, - // so we change to use random here. - $key = (new Snowflake())->getCurrentMillisecond(); + $randomKey = random_int(0, 99999); $redisResolver = new RedisSequenceResolver($redis); - $this->assertEquals(0, $redisResolver->sequence($key)); - $this->assertEquals(1, $redisResolver->sequence($key)); - $this->assertEquals(2, $redisResolver->sequence($key)); - $this->assertEquals(3, $redisResolver->sequence($key)); + $this->assertEquals(0, $redisResolver->sequence($randomKey)); + $this->assertEquals(1, $redisResolver->sequence($randomKey)); + $this->assertEquals(2, $redisResolver->sequence($randomKey)); + $this->assertEquals(3, $redisResolver->sequence($randomKey)); - sleep(10); + sleep(11); - $this->assertEquals(0, $redisResolver->sequence($key)); + $this->assertEquals(0, $redisResolver->sequence($randomKey)); } }