Mongolid\Cursor\CursorTest::testShouldWrapMongoDriverCursorWithIteratoriterator PHP Method

testShouldWrapMongoDriverCursorWithIteratoriterator() public method

    public function testShouldWrapMongoDriverCursorWithIteratoriterator()
    {
        // Arrange
        $collection = m::mock(Collection::class);
        $converter = m::mock(Converter::class);
        $cursor = $this->getCursor(null, $collection, 'find', [['bacon' => true]]);
        $driverCursor = m::mock(Traversable::class);
        $driverIterator = m::mock(Iterator::class);
        // Act
        Ioc::instance(Converter::class, $converter);
        $converter->shouldReceive('toMongoTypes')->once()->with([['bacon' => true]])->passthru();
        $collection->shouldReceive('find')->once()->with(['bacon' => true])->andReturn($driverCursor);
        $driverCursor->shouldReceive('getIterator')->andReturn($driverIterator);
        // Because when creating an IteratorIterator with the driverCursor
        // this methods will be called once to initialize the iterable object.
        $driverIterator->shouldReceive('rewind', 'valid', 'current', 'key')->once()->andReturn(true);
        // Assert
        $result = $this->callProtected($cursor, 'getCursor');
        $this->assertInstanceOf(IteratorIterator::class, $result);
    }