diff options
author | Dominik Eckelmann <deckelmann@gmail.com> | 2012-04-03 15:12:10 +0200 |
---|---|---|
committer | Dominik Eckelmann <deckelmann@gmail.com> | 2012-04-03 15:12:10 +0200 |
commit | 2379bbe75cc912c38cc3c74f8cd06793bbaec83e (patch) | |
tree | 7ce860dd185a61bd48a858dfcea9c00a10c3426f | |
parent | 3abbc5e6e96dd3c5c92561494b0b16adb4c7883d (diff) | |
download | rpg-2379bbe75cc912c38cc3c74f8cd06793bbaec83e.tar.gz rpg-2379bbe75cc912c38cc3c74f8cd06793bbaec83e.tar.bz2 |
transformed search unittest to phpunit
-rw-r--r-- | _testing/unittests/inc/search/data/ns1/ns3/page3.txt | 0 | ||||
-rw-r--r-- | _testing/unittests/inc/search/data/ns1/page1.txt | 0 | ||||
-rw-r--r-- | _testing/unittests/inc/search/data/ns1/page2.txt | 0 | ||||
-rw-r--r-- | _testing/unittests/inc/search/data/ns2/nopage.ext | 0 | ||||
-rw-r--r-- | _testing/unittests/inc/search/data/ns2/page1.txt | 0 | ||||
-rw-r--r-- | _testing/unittests/inc/search/search.test.php | 102 |
6 files changed, 102 insertions, 0 deletions
diff --git a/_testing/unittests/inc/search/data/ns1/ns3/page3.txt b/_testing/unittests/inc/search/data/ns1/ns3/page3.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/_testing/unittests/inc/search/data/ns1/ns3/page3.txt diff --git a/_testing/unittests/inc/search/data/ns1/page1.txt b/_testing/unittests/inc/search/data/ns1/page1.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/_testing/unittests/inc/search/data/ns1/page1.txt diff --git a/_testing/unittests/inc/search/data/ns1/page2.txt b/_testing/unittests/inc/search/data/ns1/page2.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/_testing/unittests/inc/search/data/ns1/page2.txt diff --git a/_testing/unittests/inc/search/data/ns2/nopage.ext b/_testing/unittests/inc/search/data/ns2/nopage.ext new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/_testing/unittests/inc/search/data/ns2/nopage.ext diff --git a/_testing/unittests/inc/search/data/ns2/page1.txt b/_testing/unittests/inc/search/data/ns2/page1.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/_testing/unittests/inc/search/data/ns2/page1.txt diff --git a/_testing/unittests/inc/search/search.test.php b/_testing/unittests/inc/search/search.test.php new file mode 100644 index 000000000..7ed14d476 --- /dev/null +++ b/_testing/unittests/inc/search/search.test.php @@ -0,0 +1,102 @@ +<?php +require_once DOKU_INC.'inc/init.php'; + +class search_test extends PHPUnit_Framework_TestCase { + function strip_index_data($entry) { + $n_entry = array(); + foreach(array('id', 'type', 'level', 'open') as $k) { + $n_entry[$k] = $entry[$k]; + } + return $n_entry; + } + + function test_search_index(){ + $data = array(); + search($data, dirname(__FILE__) . '/data', 'search_index', + array('ns' => 'ns2')); + $this->assertEquals(array_map(array($this, 'strip_index_data'), $data), + array( + array( + 'id' => 'ns1', + 'type' => 'd', + 'level' => 1, + 'open' => false + ), array( + 'id' => 'ns2', + 'type' => 'd', + 'level' => 1, + 'open' => true + ), array( + 'id' => 'ns2:page1', + 'type' => 'f', + 'level' => 2, + 'open' => true, + ), )); + $data = array(); + search($data, dirname(__FILE__) . '/data', 'search_index', + array('ns' => 'ns1/ns3')); + $this->assertEquals(array_map(array($this, 'strip_index_data'), $data), + array( + array( + 'id' => 'ns1', + 'type' => 'd', + 'level' => 1, + 'open' => true, + ), + array( + 'id' => 'ns1:ns3', + 'type' => 'd', + 'level' => 2, + 'open' => true, + ), + array( + 'id' => 'ns1:ns3:page3', + 'type' => 'f', + 'level' => 3, + 'open' => true, + ), + array( + 'id' => 'ns1:page1', + 'type' => 'f', + 'level' => 2, + 'open' => true, + ), + array( + 'id' => 'ns1:page2', + 'type' => 'f', + 'level' => 2, + 'open' => true, + ), + array( + 'id' => 'ns2', + 'type' => 'd', + 'level' => 1, + 'open' => false, + ), )); + $data = array(); + search($data, dirname(__FILE__) . '/data', 'search_index', + array('ns' => 'ns1/ns3', 'nofiles' => true)); + $this->assertEquals(array_map(array($this, 'strip_index_data'), $data), + array( + array( + 'id' => 'ns1', + 'type' => 'd', + 'level' => 1, + 'open' => true, + ), + array( + 'id' => 'ns1:ns3', + 'type' => 'd', + 'level' => 2, + 'open' => true, + ), + array( + 'id' => 'ns2', + 'type' => 'd', + 'level' => 1, + 'open' => false, + ), )); + + } +} +//Setup VIM: ex: et ts=4 : |