1<?php 2 3/** 4 * Tests for document indexing by elasticsearch plugin 5 * 6 * @group plugin_elasticsearch_docindex 7 * @group plugin_elasticsearch 8 * @group plugins 9 */ 10class docindex_elasticsearch_test extends DokuWikiTest 11{ 12 protected $pluginsEnabled = ['elasticsearch']; 13 14 /** 15 * @var \helper_plugin_elasticsearch_docparser 16 */ 17 protected $docparser; 18 19 public function setUp(): void 20 { 21 parent::setUp(); 22 io_saveFile(DOKU_CONF . 'elasticsearch.conf', file_get_contents(__DIR__ . '/../conf/elasticsearch.conf.example')); 23 $this->docparser = new \helper_plugin_elasticsearch_docparser(); 24 } 25 26 /** 27 * Provides test data 28 * 29 * @return array 30 */ 31 public function filesData() 32 { 33 return [ 34 [ 35 __DIR__ . '/documents/test.docx', 36 [ 37 'title' => 'test.docx', 38 'content' => 'Elastic test .docx 39 40Test file in .docx format', 41 'mime' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 42 'ext' => 'docx', 43 'language' => 'en', 44 'created' => '2020-01-27T12:40:04Z' 45 ] 46 ], 47 ]; 48 } 49 50 /** 51 * Tika parsing of .docx files 52 * 53 * @dataProvider filesData 54 * @param $file 55 * @param $expected 56 */ 57 public function testDocx($file, $expected) 58 { 59 $this->assertEquals($expected, $this->docparser->parse($file)); 60 } 61} 62