Mongolid\ActiveRecordTest::testShouldGetWithWhereQuery PHP Method

testShouldGetWithWhereQuery() public method

    public function testShouldGetWithWhereQuery()
    {
        // Arrage
        $entity = m::mock(ActiveRecord::class . '[getDataMapper]');
        $this->setProtected($entity, 'collection', 'mongolid');
        $query = ['foo' => 'bar'];
        $projection = ['some', 'fields'];
        $dataMapper = m::mock();
        $cursor = m::mock();
        // Act
        Ioc::instance(get_class($entity), $entity);
        $entity->shouldReceive('getDataMapper')->andReturn($dataMapper);
        $dataMapper->shouldReceive('where')->once()->with($query, $projection, true)->andReturn($cursor);
        // Assert
        $this->assertEquals($cursor, $entity->where($query, $projection, true));
    }