/** * @param \Riak\Client\ProtoBuf\RpbSearchDoc $doc * * @return array */ protected function docToArray(RpbSearchDoc $doc) { if (!$doc->hasFields()) { return []; } $values = []; foreach ($doc->fields as $pair) { $values[$pair->key][] = $pair->value; } return $values; }
public function testDocToArrayMulti() { $rpbDoc = new RpbSearchDoc(); $rpbDoc->addFields($this->createRpbPair('multi_ss', '1')); $rpbDoc->addFields($this->createRpbPair('multi_ss', '2')); $rpbDoc->addFields($this->createRpbPair('multi_ss', '3')); $result = $this->invokeMethod($this->instance, 'docToArray', [$rpbDoc]); $this->assertArrayHasKey('multi_ss', $result); $this->assertEquals(['1', '2', '3'], $result['multi_ss']); }