diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2013-11-19 21:26:50 +0100 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2013-11-19 21:26:50 +0100 |
commit | 703aeaef1a43b07dc5497dba72c98151466396cc (patch) | |
tree | 1e18a6b3fc3c28156c2e56f8a3d515b8dd6a9cf9 /_test/tests/inc/indexer_indexing.test.php | |
parent | 33c3b3817b00aa9384760813643fac0e33daaaff (diff) | |
parent | 14b3007921f7b66fc9e3621b861a3c83e7e9093c (diff) | |
download | rpg-703aeaef1a43b07dc5497dba72c98151466396cc.tar.gz rpg-703aeaef1a43b07dc5497dba72c98151466396cc.tar.bz2 |
Merge remote-tracking branch 'origin/master' into diff_navigation
Diffstat (limited to '_test/tests/inc/indexer_indexing.test.php')
-rw-r--r-- | _test/tests/inc/indexer_indexing.test.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/_test/tests/inc/indexer_indexing.test.php b/_test/tests/inc/indexer_indexing.test.php new file mode 100644 index 000000000..628e82e00 --- /dev/null +++ b/_test/tests/inc/indexer_indexing.test.php @@ -0,0 +1,45 @@ +<?php +/** + * Tests the indexing functionality of the indexer + * + * @author Michael Hamann <michael@content-space.de> + */ +class indexer_indexing_test extends DokuWikiTest { + public function setUp() { + parent::setUp(); + saveWikiText('testpage', 'Foo bar baz.', 'Test initialization'); + saveWikiText('notfound', 'Foon barn bazn.', 'Test initialization'); + idx_addPage('testpage'); + idx_addPage('notfound'); + } + + public function test_words() { + $indexer = idx_get_indexer(); + $query = array('baz', 'foo'); + $this->assertEquals(array('baz' => array('testpage' => 1), 'foo' => array('testpage' => 1)), $indexer->lookup($query)); + } + + public function test_numerically_identical_words() { + $indexer = idx_get_indexer(); + $indexer->addPageWords('testpage', '0x1 002'); + $indexer->addPageWords('notfound', '0x2'); + $query = array('001', '002'); + $this->assertEquals(array('001' => array(), '002' => array('testpage' => 1)), $indexer->lookup($query)); + } + + public function test_meta() { + $indexer = idx_get_indexer(); + $indexer->addMetaKeys('testpage', 'testkey', 'testvalue'); + $indexer->addMetaKeys('notfound', 'testkey', 'notvalue'); + $query = 'testvalue'; + $this->assertEquals(array('testpage'), $indexer->lookupKey('testkey', $query)); + } + + public function test_numerically_identical_meta_values() { + $indexer = idx_get_indexer(); + $indexer->addMetaKeys('testpage', 'numkey', array('0001', '01')); + $indexer->addMetaKeys('notfound', 'numkey', array('00001', '000001')); + $query = array('001', '01'); + $this->assertEquals(array('001' => array(), '01' => array('testpage')), $indexer->lookupKey('numkey', $query)); + } +}
\ No newline at end of file |