summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-10-19 18:24:57 +0100
committerChristopher Smith <chris@jalakai.co.uk>2013-10-19 18:24:57 +0100
commit4b94edc8e8badb6bcdc25b41f73310a8e323ba92 (patch)
tree135f4f9e4e4b37a18aad5ac23b618a023e4447bf /_test
parent698e7df8c9d5c43a93ed6822efa537158682a700 (diff)
parent9f5b9cf15569babaa90f0d6f3dd58cefd5439bc5 (diff)
downloadrpg-4b94edc8e8badb6bcdc25b41f73310a8e323ba92.tar.gz
rpg-4b94edc8e8badb6bcdc25b41f73310a8e323ba92.tar.bz2
Merge branch 'master' into FS#2867
Diffstat (limited to '_test')
-rw-r--r--_test/bootstrap.php7
-rw-r--r--_test/tests/inc/indexer_indexing.test.php45
2 files changed, 52 insertions, 0 deletions
diff --git a/_test/bootstrap.php b/_test/bootstrap.php
index 732fef9ed..3f59db515 100644
--- a/_test/bootstrap.php
+++ b/_test/bootstrap.php
@@ -68,6 +68,13 @@ $default_server_vars = array(
'REQUEST_TIME' => time(),
);
+// fixup for $_SERVER when run from CLI,
+// some values should be mocked for use by inc/init.php which is called here
+// [ $_SERVER is also mocked in TestRequest::execute() ]
+if (php_sapi_name() == 'cli') {
+ $_SERVER = array_merge($default_server_vars, $_SERVER);
+}
+
// create temp directories
mkdir(TMP_DIR);
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