public function testSetIdException() { $id = ''; try { $this->request->setId($id); } catch (RequestException $exception) { $this->assertSame('Id can not be empty', $exception->getMessage()); return; } $this->fail(); }
public function testUpdateDocument() { $this->createIndex(); $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000)); $id = $this->createDocument(self::TYPE, $data); $this->refreshIndex(); $updateDocumentRequest = new UpdateDocumentRequest(ES_INDEX, self::TYPE, $this->getSerializer()); $updateDocumentRequest->setId($id); $data['name'] = 'testName'; $updateDocumentRequest->setBody($data); /** @var CreateUpdateDocumentResponse $updateDocumentResponse */ $updateDocumentResponse = $this->getClient()->send($updateDocumentRequest); $this->assertSame(ES_INDEX, $updateDocumentResponse->getIndex()); $this->assertSame(self::TYPE, $updateDocumentResponse->getType()); $this->assertSame(2, $updateDocumentResponse->getVersion()); $this->assertSame($id, $updateDocumentResponse->getId()); $this->assertTrue($updateDocumentResponse->isOk()); }