Mongolid\DataMapper\DataMapperTest::testShouldGetFirstTroughACacheableCursor PHP Method

testShouldGetFirstTroughACacheableCursor() public method

    public function testShouldGetFirstTroughACacheableCursor()
    {
        // Arrange
        $connPool = m::mock(Pool::class);
        $mapper = m::mock(DataMapper::class . '[where]', [$connPool]);
        $query = 123;
        $entity = new stdClass();
        $cursor = m::mock(CacheableCursor::class);
        // Expect
        $mapper->shouldReceive('where')->once()->with($query, [], true)->andReturn($cursor);
        $cursor->shouldReceive('first')->once()->andReturn($entity);
        // Act
        $result = $mapper->first($query, [], true);
        // Assert
        $this->assertEquals($entity, $result);
    }