1<?php 2/** 3 * Tests the indexing functionality of the indexer 4 * 5 * @author Michael Hamann <michael@content-space.de> 6 */ 7class indexer_indexing_test extends DokuWikiTest { 8 public function setUp() { 9 parent::setUp(); 10 saveWikiText('testpage', 'Foo bar baz.', 'Test initialization'); 11 saveWikiText('notfound', 'Foon barn bazn.', 'Test initialization'); 12 idx_addPage('testpage'); 13 idx_addPage('notfound'); 14 } 15 16 public function test_words() { 17 $indexer = idx_get_indexer(); 18 $query = array('baz', 'foo'); 19 $this->assertEquals(array('baz' => array('testpage' => 1), 'foo' => array('testpage' => 1)), $indexer->lookup($query)); 20 } 21 22 public function test_numerically_identical_words() { 23 $indexer = idx_get_indexer(); 24 $indexer->addPageWords('testpage', '0x1 002'); 25 $indexer->addPageWords('notfound', '0x2'); 26 $query = array('001', '002'); 27 $this->assertEquals(array('001' => array('notfound' => 1), '002' => array('testpage' => 1)), $indexer->lookup($query)); 28 } 29 30 public function test_meta() { 31 $indexer = idx_get_indexer(); 32 $indexer->addMetaKeys('testpage', 'testkey', 'testvalue'); 33 $indexer->addMetaKeys('notfound', 'testkey', 'notvalue'); 34 $query = 'testvalue'; 35 $this->assertEquals(array('testpage'), $indexer->lookupKey('testkey', $query)); 36 } 37 38 public function test_numerically_identical_meta_values() { 39 $indexer = idx_get_indexer(); 40 $indexer->addMetaKeys('testpage', 'numkey', array('0001', '01')); 41 $indexer->addMetaKeys('notfound', 'numkey', array('00001', '000001')); 42 $query = array('001', '01'); 43 $this->assertEquals(array('001' => array(), '01' => array('testpage')), $indexer->lookupKey('numkey', $query)); 44 } 45}