/** * @group functional */ public function testErrorRequest() { $index = $this->_createIndex(); $type = $index->getType('bulk_test'); $client = $index->getClient(); $documents = array($type->createDocument(1, array('name' => 'Mister Fantastic')), $type->createDocument(2, array('name' => 'Invisible Woman')), $type->createDocument(2, array('name' => 'The Human Torch'))); $documents[2]->setOpType(Document::OP_TYPE_CREATE); $bulk = new Bulk($client); $bulk->addDocuments($documents); try { $bulk->send(); $bulk->fail('3rd document create should produce error'); } catch (ResponseException $e) { $this->assertContains('DocumentAlreadyExists', $e->getMessage()); $failures = $e->getFailures(); $this->assertInternalType('array', $failures); $this->assertArrayHasKey(0, $failures); $this->assertContains('DocumentAlreadyExists', $failures[0]); } }