private function createSampleData()
 {
     foreach ($this->data as $city) {
         $this->documentRepository->create(ES_INDEX, self::TYPE, $city);
     }
     $this->refreshIndex();
 }
 public function testUpdateDocument()
 {
     $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000));
     /** @var CreateUpdateDocumentResponse $createResponse */
     $createResponse = $this->documentRepository->create(ES_INDEX, self::TYPE, $data);
     $this->refreshIndex();
     $data['name'] = 'test3';
     $this->documentRepository->update(ES_INDEX, self::TYPE, $createResponse->getId(), $data);
     /** @var DocumentResponse $getResponse */
     $getResponse = $this->documentRepository->get(ES_INDEX, self::TYPE, $createResponse->getId());
     $storedData = $getResponse->getSource();
     $this->assertSame($data, $storedData);
 }
 public function testUpdate()
 {
     $index = 'myIndex';
     $type = 'myType';
     $return = 'itsMe';
     $className = 'myClassName';
     $id = 'testId';
     $data = array('myValue');
     $request = $this->getMockBuilder('Elastification\\Client\\Request\\V1x\\UpdateDocumentRequest')->disableOriginalConstructor()->getMock();
     $request->expects($this->once())->method('setBody')->with($data);
     $request->expects($this->once())->method('setId')->with($id);
     $this->requestRepositoryFactory->expects($this->once())->method('create')->with($className, $index, $type, $this->serializer)->willReturn($request);
     $this->repositoryClassMap->expects($this->once())->method('getClassName')->with(DocumentRepositoryInterface::UPDATE_DOCUMENT)->willReturn($className);
     $this->client->expects($this->once())->method('send')->willReturn($return);
     $result = $this->documentRepository->update($index, $type, $id, $data);
     $this->assertSame($return, $result);
 }