public function mapOpAssertions(MapOp $op) { $this->assertInstanceOf('Basho\\Riak\\Api\\Pb\\Message\\MapOp', $op); $this->assertEquals(5, $op->getUpdatesCount()); $this->assertEquals(1, $op->getRemovesCount()); foreach ($op->getUpdates() as $update) { switch (DataType::mapFieldToCompKey($update->getField())) { case 'roster_set': $this->setOpAssertions($update->getSetOp()); break; case 'clinch_playoffs_flag': $this->assertEquals(FlagOp::DISABLE, $update->getFlagOp()); break; case 'win_counter': $this->counterOpAssertions($update->getCounterOp()); break; case 'name_register': $this->assertEquals('Buffalo Sabres', $update->getRegisterOp()); break; case 'farm_team_map': $this->assertInstanceOf('Basho\\Riak\\Api\\Pb\\Message\\MapOp', $update->getMapOp()); $this->assertEquals(2, $update->getMapOp()->getUpdatesCount()); $this->assertEquals(0, $update->getMapOp()->getRemovesCount()); break; default: $this->assertTrue(false); } } foreach ($op->getRemoves() as $remove) { $this->assertContains(DataType::mapFieldToCompKey($remove), static::MAP_REMOVES); } }
/** * @param array $updates * @param array $removes * @return Pb\Message\DtUpdateReq * @throws Exception */ protected function buildMapUpdateMessage(array $updates = [], array $removes = []) { $message = $this->buildDataTypeMessage(); $message->setOp(Api\Pb\Translator\DataType::buildMapOp($updates, $removes, true)); return $message; }