summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
Diffstat (limited to '_test')
-rw-r--r--_test/core/DokuWikiTest.php2
-rw-r--r--_test/phpunit.xml4
-rw-r--r--_test/tests/inc/httpclient_http_proxy.test.php20
-rw-r--r--_test/tests/inc/httpclient_https.test.php1
-rw-r--r--_test/tests/inc/httpclient_https_proxy.test.php15
-rw-r--r--_test/tests/inc/indexer_pid.test.php18
-rw-r--r--_test/tests/inc/search/search.test.php19
7 files changed, 79 insertions, 0 deletions
diff --git a/_test/core/DokuWikiTest.php b/_test/core/DokuWikiTest.php
index b9e151456..91eb5293b 100644
--- a/_test/core/DokuWikiTest.php
+++ b/_test/core/DokuWikiTest.php
@@ -30,6 +30,8 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
// remove any leftovers from the last run
if(is_dir(DOKU_TMP_DATA)){
+ // clear indexer data and cache
+ idx_get_indexer()->clear();
TestUtils::rdelete(DOKU_TMP_DATA);
}
diff --git a/_test/phpunit.xml b/_test/phpunit.xml
index 13676f207..fc7dd8be0 100644
--- a/_test/phpunit.xml
+++ b/_test/phpunit.xml
@@ -10,6 +10,9 @@
<testsuite name="Plugin Tests">
<directory suffix=".test.php">../lib/plugins/*/_test</directory>
</testsuite>
+ <testsuite name="Template Tests">
+ <directory suffix=".test.php">../lib/tpl/*/_test</directory>
+ </testsuite>
</testsuites>
<filter>
@@ -19,6 +22,7 @@
<directory suffix=".php">../_cs/</directory>
<directory suffix=".php">../_test/</directory>
<directory suffix=".php">../lib/plugins/*/_test/</directory>
+ <directory suffix=".php">../lib/tpl/*/_test/</directory>
</exclude>
</whitelist>
</filter>
diff --git a/_test/tests/inc/httpclient_http_proxy.test.php b/_test/tests/inc/httpclient_http_proxy.test.php
new file mode 100644
index 000000000..faa7a4280
--- /dev/null
+++ b/_test/tests/inc/httpclient_http_proxy.test.php
@@ -0,0 +1,20 @@
+<?php
+
+class httpclient_http_proxy_test extends DokuWikiTest {
+ protected $url = 'http://www.dokuwiki.org/README';
+
+ /**
+ * @group internet
+ */
+ function test_simpleget(){
+ $http = new HTTPClient();
+ // proxy provided by Andrwe Lord Weber <dokuwiki@andrwe.org>
+ $http->proxy_host = 'proxy.andrwe.org';
+ $http->proxy_port = 8080;
+
+ $data = $http->get($this->url);
+ $this->assertFalse($data === false, 'HTTP response');
+ $this->assertTrue(strpos($data,'DokuWiki') !== false, 'response content');
+ }
+
+} \ No newline at end of file
diff --git a/_test/tests/inc/httpclient_https.test.php b/_test/tests/inc/httpclient_https.test.php
index 26a0f86db..955d467ec 100644
--- a/_test/tests/inc/httpclient_https.test.php
+++ b/_test/tests/inc/httpclient_https.test.php
@@ -1,4 +1,5 @@
<?php
+require_once dirname(__FILE__).'/httpclient_http.test.php';
class httpclient_https_test extends httpclient_http_test {
protected $server = 'https://httpbin.org/';
diff --git a/_test/tests/inc/httpclient_https_proxy.test.php b/_test/tests/inc/httpclient_https_proxy.test.php
new file mode 100644
index 000000000..aca3b3be2
--- /dev/null
+++ b/_test/tests/inc/httpclient_https_proxy.test.php
@@ -0,0 +1,15 @@
+<?php
+require_once dirname(__FILE__).'/httpclient_http_proxy.test.php';
+
+class httpclient_https_proxy_test extends httpclient_http_proxy_test {
+ protected $url = 'https://www.dokuwiki.org/README';
+
+ public function setUp(){
+ // skip tests when this PHP has no SSL support
+ $transports = stream_get_transports();
+ if(!in_array('ssl',$transports)){
+ $this->markTestSkipped('No SSL support available.');
+ }
+ parent::setUp();
+ }
+} \ No newline at end of file
diff --git a/_test/tests/inc/indexer_pid.test.php b/_test/tests/inc/indexer_pid.test.php
new file mode 100644
index 000000000..8c58b1abd
--- /dev/null
+++ b/_test/tests/inc/indexer_pid.test.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Tests the pid functions of the indexer.
+ *
+ * @author Michael Hamann <michael@content-space.de>
+ */
+class indexer_pid_test extends DokuWikiTest {
+ function test_pid() {
+ $indexer = idx_get_indexer();
+ $syntaxPID = $indexer->getPID('wiki:syntax');
+ $this->assertEquals('wiki:syntax', $indexer->getPageFromPID($syntaxPID), 'getPageFromPID(getPID(\'wiki:syntax\')) != \'wiki:syntax\'');
+ $dokuwikiPID = $indexer->getPID('wiki:dokuwiki');
+ $this->assertEquals('wiki:syntax', $indexer->getPageFromPID($syntaxPID), 'getPageFromPID(getPID(\'wiki:syntax\')) != \'wiki:syntax\' after getting the PID for wiki:dokuwiki');
+ $this->assertEquals($syntaxPID, $indexer->getPID('wiki:syntax'), 'getPID(\'wiki:syntax\') didn\'t returned different PIDs when called twice');
+ $this->assertNotEquals($syntaxPID, $dokuwikiPID, 'Same PID returned for different pages');
+ $this->assertTrue(is_numeric($syntaxPID) && is_numeric($dokuwikiPID), 'PIDs are not numeric');
+ }
+}
diff --git a/_test/tests/inc/search/search.test.php b/_test/tests/inc/search/search.test.php
index 33cc80e74..9c854a661 100644
--- a/_test/tests/inc/search/search.test.php
+++ b/_test/tests/inc/search/search.test.php
@@ -1,6 +1,7 @@
<?php
class search_test extends DokuWikiTest {
+
function strip_index_data($entry) {
$n_entry = array();
foreach(array('id', 'type', 'level', 'open') as $k) {
@@ -9,6 +10,24 @@ class search_test extends DokuWikiTest {
return $n_entry;
}
+ function test_search_allpages(){
+ $data = array();
+
+ //depth is 0 hence we should recurse endlesly
+ search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 0), 'ns1');
+ $this->assertEquals(3, count($data));
+
+ //depth is 1 and we start too deep to expect results
+ $data = array();
+ search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 1), 'ns1/ns3');
+ $this->assertEquals(0, count($data));
+
+ //depth is 1 so I should get only pages from ns1
+ $data = array();
+ search($data, dirname(__FILE__) . '/data', 'search_allpages', array('depth' => 1), 'ns1');
+ $this->assertEquals(2, count($data));
+ }
+
function test_search_index(){
$data = array();
search($data, dirname(__FILE__) . '/data', 'search_index',