public function testCreateDocument()
 {
     $this->createIndex();
     $createDocumentRequest = new CreateDocumentRequest(ES_INDEX, self::TYPE, $this->getSerializer());
     $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000));
     $createDocumentRequest->setBody($data);
     /** @var CreateUpdateDocumentResponse $response */
     $response = $this->getClient()->send($createDocumentRequest);
     $this->assertSame(ES_INDEX, $response->getIndex());
     $this->assertSame(self::TYPE, $response->getType());
     $this->assertSame(1, $response->getVersion());
     $this->assertTrue(strlen($response->getId()) > 5);
     $this->assertTrue($response->created());
 }
Example #2
0
 /**
  * Creates on document for a type
  * If no data is given a random dataset will be created with properties: name, value
  *
  * @param string $type
  * @param null|array|object $data
  *
  * @return string
  */
 protected function createDocument($type, $data = null)
 {
     $createDocumentRequest = new CreateDocumentRequest(ES_INDEX, $type, $this->serializer);
     if (null === $data) {
         $data = array('name' => 'test' . rand(100, 10000), 'value' => 'myTestVal' . rand(100, 10000));
     }
     $createDocumentRequest->setBody($data);
     /** @var CreateUpdateDocumentResponse $response */
     $response = $this->client->send($createDocumentRequest);
     return $response->getId();
 }
 public function testCreateResponse()
 {
     $rawData = 'raw data for testing';
     $response = $this->request->createResponse($rawData, $this->serializer);
     $this->assertInstanceOf(self::RESPONSE_CLASS, $response);
 }