Mongolid\Util\SequenceServiceTest::testShouldGetNextValue PHP Method

testShouldGetNextValue() public method

public testShouldGetNextValue ( $sequenceName, $currentValue, $expectation )
    public function testShouldGetNextValue($sequenceName, $currentValue, $expectation)
    {
        // Arrange
        $connPool = m::mock(Pool::class);
        $sequenceService = m::mock(SequenceService::class . '[rawCollection]', [$connPool]);
        $sequenceService->shouldAllowMockingProtectedMethods();
        $rawCollection = m::mock(Collection::class);
        // Act
        $sequenceService->shouldReceive('rawCollection')->once()->andReturn($rawCollection);
        $rawCollection->shouldReceive('findOneAndUpdate')->once()->with(['_id' => $sequenceName], ['$inc' => ['seq' => 1]], ['upsert' => true])->andReturn($currentValue ? (object) ['seq' => $currentValue] : null);
        // Assertion
        $this->assertEquals($expectation, $sequenceService->getNextValue($sequenceName));
    }