From a8dba4523d2ecd09dd69a68a36673eaf5c009c57 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 19 Oct 2013 16:09:15 +0200 Subject: Fix FS#2854: Treat numerically different keys as different --- _test/tests/inc/indexer_indexing.test.php | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 _test/tests/inc/indexer_indexing.test.php (limited to '_test/tests/inc/indexer_indexing.test.php') diff --git a/_test/tests/inc/indexer_indexing.test.php b/_test/tests/inc/indexer_indexing.test.php new file mode 100644 index 000000000..8600cf156 --- /dev/null +++ b/_test/tests/inc/indexer_indexing.test.php @@ -0,0 +1,45 @@ + + */ +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('notfound' => 1), '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 -- cgit v1.2.3 From 9f5b9cf15569babaa90f0d6f3dd58cefd5439bc5 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sat, 19 Oct 2013 17:10:43 +0200 Subject: Fix the indexer indexing test case (changed the data but not the result) --- _test/tests/inc/indexer_indexing.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test/tests/inc/indexer_indexing.test.php') diff --git a/_test/tests/inc/indexer_indexing.test.php b/_test/tests/inc/indexer_indexing.test.php index 8600cf156..628e82e00 100644 --- a/_test/tests/inc/indexer_indexing.test.php +++ b/_test/tests/inc/indexer_indexing.test.php @@ -24,7 +24,7 @@ class indexer_indexing_test extends DokuWikiTest { $indexer->addPageWords('testpage', '0x1 002'); $indexer->addPageWords('notfound', '0x2'); $query = array('001', '002'); - $this->assertEquals(array('001' => array('notfound' => 1), '002' => array('testpage' => 1)), $indexer->lookup($query)); + $this->assertEquals(array('001' => array(), '002' => array('testpage' => 1)), $indexer->lookup($query)); } public function test_meta() { -- cgit v1.2.3