DominionEnterprises\Mongo\QueueTest::resetStuck PHP Method

resetStuck() public method

public resetStuck ( )
    public function resetStuck()
    {
        $messageOne = ['key' => 0];
        $messageTwo = ['key' => 1];
        $this->queue->send($messageOne);
        $this->queue->send($messageTwo);
        //sets to running
        $this->collection->updateOne(['payload.key' => 0], ['$set' => ['running' => true, 'resetTimestamp' => new \MongoDB\BSON\UTCDateTime((int) (microtime(true) * 1000))]]);
        $this->collection->updateOne(['payload.key' => 1], ['$set' => ['running' => true, 'resetTimestamp' => new \MongoDB\BSON\UTCDateTime((int) (microtime(true) * 1000))]]);
        $this->assertSame(2, $this->collection->count(['running' => true]));
        //sets resetTimestamp on messageOne
        $this->queue->get($messageOne, 0, 0);
        //resets and gets messageOne
        $this->assertNotNull($this->queue->get($messageOne, PHP_INT_MAX, 0));
        $this->assertSame(1, $this->collection->count(['running' => false]));
    }