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 testCreate() { $index = 'myIndex'; $type = 'myType'; $return = 'itsMe'; $data = array('test'); $className = 'myClassName'; $request = $this->getMockBuilder('Elastification\\Client\\Request\\RequestInterface')->disableOriginalConstructor()->getMock(); $request->expects($this->once())->method('setBody')->with($data); $this->requestRepositoryFactory->expects($this->once())->method('create')->with($className, $index, $type, $this->serializer)->willReturn($request); $this->repositoryClassMap->expects($this->once())->method('getClassName')->with(DocumentRepositoryInterface::CREATE_DOCUMENT)->willReturn($className); $this->client->expects($this->once())->method('send')->willReturn($return); $result = $this->documentRepository->create($index, $type, $data); $this->assertSame($return, $result); }