Conditions | 1 |
Paths | 1 |
Total Lines | 33 |
Lines | 33 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
34 | View Code Duplication | public function testDotExpanderField(): void |
|
|
|||
35 | { |
||
36 | $dotExpander = new DotExpanderProcessor('foo.bar'); |
||
37 | |||
38 | $pipeline = $this->_createPipeline('my_custom_pipeline', 'pipeline for DotExpander'); |
||
39 | $pipeline->addProcessor($dotExpander)->create(); |
||
40 | |||
41 | $index = $this->_createIndex(); |
||
42 | |||
43 | // Add document to normal index |
||
44 | $doc1 = new Document(null, ['foo.bar' => 'value']); |
||
45 | |||
46 | $bulk = new Bulk($index->getClient()); |
||
47 | $bulk->setIndex($index); |
||
48 | |||
49 | $bulk->addDocument($doc1); |
||
50 | $bulk->setRequestParam('pipeline', 'my_custom_pipeline'); |
||
51 | |||
52 | $bulk->send(); |
||
53 | $index->refresh(); |
||
54 | |||
55 | $result = $index->search('*'); |
||
56 | |||
57 | $this->assertCount(1, $result->getResults()); |
||
58 | |||
59 | $expect = [ |
||
60 | 'foo' => [ |
||
61 | 'bar' => 'value', |
||
62 | ], |
||
63 | ]; |
||
64 | $results = $result->getResults(); |
||
65 | $this->assertEquals($expect, ($results[0]->getHit())['_source']); |
||
66 | } |
||
67 | } |
||
68 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.