public function testBuildCommand()
 {
     $filters = KeyFilters::filter()->startsWith('2005');
     $builder = BucketMapReduce::builder($this->namespace, KeyFilters::filter())->withNamespace($this->namespace)->withKeyFilter($filters)->withLinkPhase('bucket-name', 'link')->withMapPhase(new ErlangFunction('module', 'map_func1'))->withReducePhase(new ErlangFunction('module', 'red_func1'));
     $command = $builder->build();
     $spec = $command->getSpecification();
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Specification', $spec);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\BucketMapReduce', $command);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Input\\BucketInput', $spec->getInput());
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\KeyFilters', $spec->getInput()->getFilters());
     $this->assertSame($this->namespace, $spec->getInput()->getNamespace());
     $this->assertSame($filters, $spec->getInput()->getFilters());
     $this->assertCount(3, $spec->getPhases());
 }
 public function testIndexMapReduceMatch()
 {
     $map = $this->createMapFunction();
     $filter = KeyFilters::filter()->between('10', '19', false);
     $reduce = new ErlangFunction('riak_kv_mapreduce', 'reduce_sum');
     $command = BucketMapReduce::builder()->withMapPhase($map, null, false)->withReducePhase($reduce, null, true)->withNamespace($this->namespace)->withKeyFilter($filter)->build();
     $result = $this->client->execute($command);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Response\\BucketMapReduceResponse', $result);
     $iterator = $result->getIterator();
     $values = iterator_to_array($iterator);
     $this->assertCount(1, $values);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Response\\MapReduceEntry', $values[0]);
     $this->assertEquals([116], $values[0]->getResponse());
     $this->assertEquals(1, $values[0]->getPhase());
 }