public function testBuildIntIndex()
 {
     $builder = IndexMapReduce::builder($this->namespace)->withNamespace($this->namespace)->withIndexInt('index-name')->withMatchValue(10)->withTimeout(100)->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\\IndexMapReduce', $command);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Input\\IndexInput', $spec->getInput());
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Input\\Index\\MatchCriteria', $spec->getInput()->getCriteria());
     $this->assertEquals('index-name_int', $spec->getInput()->getIndexName());
     $this->assertSame($this->namespace, $spec->getInput()->getNamespace());
     $this->assertEquals(10, $spec->getInput()->getCriteria()->getValue());
     $this->assertEquals(100, $spec->getTimeout());
     $this->assertCount(2, $spec->getPhases());
     $phases = $spec->getPhases();
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Phase\\MapPhase', $phases[0]);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Phase\\ReducePhase', $phases[1]);
 }
 public function testIndexMapReduceKeepMap()
 {
     $map = $this->createMapFunction();
     $command = IndexMapReduce::builder()->withMapPhase($map, null, true)->withNamespace($this->namespace)->withIndexBin('tags')->withMatchValue('odd')->build();
     $result = $this->client->execute($command);
     $this->assertInstanceOf('Riak\\Client\\Command\\MapReduce\\Response\\IndexMapReduceResponse', $result);
     $phaseZeroResults = $result->getResultForPhase(0);
     $allResults = $result->getResultsFromAllPhases();
     $expected = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99];
     $this->assertInternalType('array', $phaseZeroResults);
     $this->assertCount(50, $phaseZeroResults);
     sort($phaseZeroResults);
     sort($allResults);
     $this->assertEquals($expected, $phaseZeroResults);
     $this->assertEquals($expected, $allResults);
 }