malkusch\lock\mutex\RedisMutexTest::testSeedRandom PHP Method

testSeedRandom() public method

Tests seeding produces different tokens for each process.
public testSeedRandom ( )
    public function testSeedRandom()
    {
        $mutex = $this->buildRedisMutex(1);
        $mutex->seedRandom();
        $tokens = [];
        $processManager = new ProcessManager();
        for ($i = 0; $i < 2; $i++) {
            $processManager->fork(function () {
                $mutex = $this->buildRedisMutex(1);
                $mutex->expects($this->any())->method("evalScript")->willReturn(true);
                $token = null;
                $mutex->expects($this->any())->method("add")->willReturnCallback(function ($redisAPI, $key, $value, $expire) use(&$token) {
                    $token = "{$value}";
                    return true;
                });
                $mutex->synchronized(function () {
                });
                return $token;
            })->then(function (Fork $fork) use(&$tokens) {
                $this->assertArrayNotHasKey($fork->getResult(), $tokens);
                $tokens[$fork->getResult()] = $fork->getResult();
            });
        }
    }