| Conditions | 2 |
| Paths | 4 |
| Total Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function testFailField(): void |
||
| 36 | { |
||
| 37 | $fail = new FailProcessor('custom error fail message'); |
||
| 38 | $json = new JsonProcessor('name'); |
||
| 39 | |||
| 40 | $pipeline = $this->_createPipeline('my_custom_pipeline', 'pipeline for Fail'); |
||
| 41 | $pipeline->addProcessor($json)->addProcessor($fail)->create(); |
||
| 42 | |||
| 43 | $index = $this->_createIndex(); |
||
| 44 | |||
| 45 | // Add document to normal index |
||
| 46 | $doc1 = new Document(null, ['name' => '']); |
||
| 47 | |||
| 48 | $bulk = new Bulk($index->getClient()); |
||
| 49 | $bulk->setIndex($index); |
||
| 50 | |||
| 51 | $bulk->addDocument($doc1); |
||
| 52 | $bulk->setRequestParam('pipeline', 'my_custom_pipeline'); |
||
| 53 | |||
| 54 | try { |
||
| 55 | $bulk->send(); |
||
| 56 | $index->refresh(); |
||
| 57 | $this->fail('test should raise an exception!'); |
||
| 58 | } catch (\Exception $e) { |
||
| 59 | $this->assertStringContainsString('custom error fail message', $e->getMessage()); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | } |
||
| 63 |