public function testAll()
{
$query = new Query();
$query->from('yiitest', 'user');
$results = $query->all($this->getConnection());
$this->assertEquals(4, count($results));
$result = reset($results);
$this->assertEquals(3, count($result['_source']));
$this->assertArrayHasKey('status', $result['_source']);
$this->assertArrayHasKey('email', $result['_source']);
$this->assertArrayHasKey('name', $result['_source']);
$this->assertArrayHasKey('_id', $result);
$query = new Query();
$query->from('yiitest', 'user');
$results = $query->where(['name' => 'user1'])->all($this->getConnection());
$this->assertEquals(1, count($results));
$result = reset($results);
$this->assertEquals(3, count($result['_source']));
$this->assertArrayHasKey('status', $result['_source']);
$this->assertArrayHasKey('email', $result['_source']);
$this->assertArrayHasKey('name', $result['_source']);
$this->assertArrayHasKey('_id', $result);
$this->assertEquals(1, $result['_id']);
// indexBy
$query = new Query();
$query->from('yiitest', 'user');
$results = $query->indexBy('name')->all($this->getConnection());
$this->assertEquals(4, count($results));
ksort($results);
$this->assertEquals(['user1', 'user2', 'user3', 'user4'], array_keys($results));
}