public function testMapReduceQueryWithMultipleMethodsAndQueryArray()
{
$map = 'function() {
for(i = 0; i <= this.options.length; i++) {
emit(this.name, { count: 1 });
}
}';
$reduce = 'function(product, values) {
var total = 0
values.forEach(function(value){
total+= value.count;
});
return {
product: product,
options: total,
test: values
};
}';
$finalize = 'function (key, value) { return value; }';
$qb = $this->getTestQueryBuilder()->map($map)->reduce($reduce)->finalize($finalize)->field('username')->equals('jwage');
$expectedQueryArray = ['username' => 'jwage'];
$expectedMapReduce = ['map' => $map, 'reduce' => $reduce, 'options' => ['finalize' => $finalize], 'out' => ['inline' => true]];
$this->assertEquals(Query::TYPE_MAP_REDUCE, $qb->getType());
$this->assertEquals($expectedQueryArray, $qb->getQueryArray());
$this->assertEquals($expectedMapReduce, $qb->debug('mapReduce'));
}