Mongolid\Cursor\CursorTest::testShouldGetCurrent PHP Method

testShouldGetCurrent() public method

    public function testShouldGetCurrent()
    {
        // Arrange
        $collection = m::mock(Collection::class);
        $driverCursor = m::mock(IteratorIterator::class);
        $converter = m::mock(Converter::class . '[toDomainTypes]');
        $cursor = $this->getCursor(null, $collection, 'find', [[]], $driverCursor);
        // Act
        Ioc::instance(Converter::class, $converter);
        $converter->shouldReceive('toDomainTypes')->once()->with(['name' => 'John Doe'])->passthru();
        $driverCursor->shouldReceive('current')->once()->andReturn(['name' => 'John Doe']);
        // Assert
        $entity = $cursor->current();
        $this->assertInstanceOf(stdClass::class, $entity);
        $this->assertAttributeEquals('John Doe', 'name', $entity);
    }