Mongolid\Cursor\CursorTest::testShouldReturnAllResults PHP Method

testShouldReturnAllResults() public method

    public function testShouldReturnAllResults()
    {
        // Arrange
        $collection = m::mock(Collection::class);
        $driverCursor = m::mock(IteratorIterator::class);
        $cursor = $this->getCursor(null, $collection, 'find', [[]], $driverCursor);
        // Act
        $driverCursor->shouldReceive('rewind', 'valid', 'key')->andReturn(true, true, false);
        $driverCursor->shouldReceive('next')->andReturn(true, false);
        $driverCursor->shouldReceive('current')->twice()->andReturn(['name' => 'bob', 'occupation' => 'coder'], ['name' => 'jef', 'occupation' => 'tester']);
        $result = $cursor->all();
        // Assert
        $this->assertEquals([(object) ['name' => 'bob', 'occupation' => 'coder'], (object) ['name' => 'jef', 'occupation' => 'tester']], $result);
    }