summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
Diffstat (limited to '_test')
-rw-r--r--_test/bootstrap.php7
-rw-r--r--_test/conf/acl.auth.php6
-rw-r--r--_test/core/DokuWikiTest.php20
-rw-r--r--_test/core/TestRequest.php75
-rw-r--r--_test/tests/conf/title.test.php19
-rw-r--r--_test/tests/inc/auth_aclcheck.test.php27
-rw-r--r--_test/tests/inc/common_cleanText.test.php6
-rw-r--r--_test/tests/inc/events_nested.test.php36
-rw-r--r--_test/tests/inc/httpclient_http.test.php15
-rw-r--r--_test/tests/inc/input.test.php216
-rw-r--r--_test/tests/inc/pageutils_findnearest.test.php40
-rw-r--r--_test/tests/inc/template_sidebar.test.php40
-rw-r--r--_test/tests/lib/exe/js_js_compress.test.php6
-rw-r--r--_test/tests/test/basic.test.php83
14 files changed, 585 insertions, 11 deletions
diff --git a/_test/bootstrap.php b/_test/bootstrap.php
index 6c3d6aaa8..58ad6a0d7 100644
--- a/_test/bootstrap.php
+++ b/_test/bootstrap.php
@@ -82,7 +82,12 @@ if (getenv('PRESERVE_TMP') != 'true') {
// populate default dirs
TestUtils::rcopy(TMP_DIR, DOKU_INC.'/conf');
TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/conf');
-TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data');
+mkdir(DOKU_TMP_DATA);
+foreach(array(
+ 'attic', 'cache', 'index', 'locks', 'media',
+ 'media_attic', 'media_meta', 'meta', 'pages', 'tmp') as $dir){
+ mkdir(DOKU_TMP_DATA.'/'.$dir);
+}
// disable all non-default plugins by default
$dh = dir(DOKU_INC.'lib/plugins/');
diff --git a/_test/conf/acl.auth.php b/_test/conf/acl.auth.php
index 14344d778..8a1b01f23 100644
--- a/_test/conf/acl.auth.php
+++ b/_test/conf/acl.auth.php
@@ -19,3 +19,9 @@
# delete 16
* @ALL 8
+
+# for testing wildcards:
+users:* @ALL 1
+users:%USER%:* %USER% 16
+groups:* @ALL 1
+groups:%GROUP%:* %GROUP% 16
diff --git a/_test/core/DokuWikiTest.php b/_test/core/DokuWikiTest.php
index e47c06329..e51f1eeb1 100644
--- a/_test/core/DokuWikiTest.php
+++ b/_test/core/DokuWikiTest.php
@@ -19,6 +19,25 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
protected $pluginsDisabled = array();
/**
+ * Setup the data directory
+ *
+ * This is ran before each test class
+ */
+ public static function setUpBeforeClass() {
+ // just to be safe not to delete something undefined later
+ if(!defined('TMP_DIR')) die('no temporary directory');
+ if(!defined('DOKU_TMP_DATA')) die('no temporary data directory');
+
+ // remove any leftovers from the last run
+ if(is_dir(DOKU_TMP_DATA)){
+ TestUtils::rdelete(DOKU_TMP_DATA);
+ }
+
+ // populate default dirs
+ TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/../data/');
+ }
+
+ /**
* Reset the DokuWiki environment before each test run. Makes sure loaded config,
* language and plugins are correct.
*
@@ -26,6 +45,7 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
* @return void
*/
public function setUp() {
+
// reload config
global $conf, $config_cascade;
$conf = array();
diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php
index fa3ddec90..172821576 100644
--- a/_test/core/TestRequest.php
+++ b/_test/core/TestRequest.php
@@ -36,9 +36,10 @@ class TestRequest {
/**
* Executes the request
*
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
* @return TestResponse the resulting output of the request
*/
- public function execute() {
+ public function execute($uri='/doku.php') {
// save old environment
$server = $_SERVER;
$session = $_SESSION;
@@ -46,6 +47,14 @@ class TestRequest {
$post = $_POST;
$request = $_REQUEST;
+ // prepare the right URI
+ $this->setUri($uri);
+
+ // import all defined globals into the function scope
+ foreach(array_keys($GLOBALS) as $glb){
+ global $$glb;
+ }
+
// fake environment
global $default_server_vars;
$_SERVER = array_merge($default_server_vars, $this->server);
@@ -79,4 +88,68 @@ class TestRequest {
return $response;
}
+
+ /**
+ * Set the virtual URI the request works against
+ *
+ * This parses the given URI and sets any contained GET variables
+ * but will not overwrite any previously set ones (eg. set via setGet()).
+ *
+ * It initializes the $_SERVER['REQUEST_URI'] and $_SERVER['QUERY_STRING']
+ * with all set GET variables.
+ *
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
+ * @todo make this work with other end points
+ */
+ protected function setUri($uri){
+ if(substr($uri,0,9) != '/doku.php'){
+ throw new Exception("only '/doku.php' is supported currently");
+ }
+
+ $params = array();
+ list($uri, $query) = explode('?',$uri,2);
+ if($query) parse_str($query, $params);
+
+ $this->get = array_merge($params, $this->get);
+ if(count($this->get)){
+ $query = '?'.http_build_query($this->get, '', '&');
+ $query = str_replace(
+ array('%3A', '%5B', '%5D'),
+ array(':', '[', ']'),
+ $query
+ );
+ $uri = $uri.$query;
+ }
+
+ $this->setServer('QUERY_STRING', $query);
+ $this->setServer('REQUEST_URI', $uri);
+ }
+
+ /**
+ * Simulate a POST request with the given variables
+ *
+ * @param array $post all the POST parameters to use
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
+ * @param return TestResponse
+ */
+ public function post($post=array(), $uri='/doku.php') {
+ $this->post = array_merge($this->post, $post);
+ $this->setServer('REQUEST_METHOD', 'POST');
+ return $this->execute($uri);
+ }
+
+ /**
+ * Simulate a GET request with the given variables
+ *
+ * @param array $GET all the POST parameters to use
+ * @param string $url end URL to simulate, needs to start with /doku.php currently
+ * @param return TestResponse
+ */
+ public function get($get=array(), $uri='/doku.php') {
+ $this->get = array_merge($this->get, $get);
+ $this->setServer('REQUEST_METHOD', 'GET');
+ return $this->execute($uri);
+ }
+
+
}
diff --git a/_test/tests/conf/title.test.php b/_test/tests/conf/title.test.php
new file mode 100644
index 000000000..7cae040e7
--- /dev/null
+++ b/_test/tests/conf/title.test.php
@@ -0,0 +1,19 @@
+<?php
+
+class conf_title_test extends DokuWikiTest {
+
+ function testTitle() {
+ global $conf;
+
+ $request = new TestRequest();
+ $response = $request->get();
+ $content = $response->queryHTML('title');
+ $this->assertTrue(strpos($content,$conf['title']) > 0);
+
+ $conf['title'] = 'Foo';
+ $request = new TestRequest();
+ $response = $request->get();
+ $content = $response->queryHTML('title');
+ $this->assertTrue(strpos($content,'Foo') > 0);
+ }
+}
diff --git a/_test/tests/inc/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php
index ea48ec6a5..991f82da7 100644
--- a/_test/tests/inc/auth_aclcheck.test.php
+++ b/_test/tests/inc/auth_aclcheck.test.php
@@ -235,6 +235,33 @@ class auth_acl_test extends DokuWikiTest {
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','roots')), AUTH_ADMIN);
}
+ function test_wildcards(){
+ global $conf;
+ global $AUTH_ACL;
+ global $USERINFO;
+ $conf['useacl'] = 1;
+
+ $_SERVER['REMOTE_USER'] = 'john';
+ $USERINFO['grps'] = array('test','töst','foo bar');
+ $AUTH_ACL = auth_loadACL(); // default test file
+
+ // default setting
+ $this->assertEquals(AUTH_UPLOAD, auth_aclcheck('page', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+
+ // user namespace
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('users:john:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('users:john:foo', 'schmock', array()));
+
+ // group namespace
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:test:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('groups:test:foo', 'schmock', array()));
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:toest:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('groups:toest:foo', 'schmock', array()));
+ $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:foo_bar:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps']));
+ $this->assertEquals(AUTH_READ, auth_aclcheck('groups:foo_bar:foo', 'schmock', array()));
+
+ }
+
}
//Setup VIM: ex: et ts=4 :
diff --git a/_test/tests/inc/common_cleanText.test.php b/_test/tests/inc/common_cleanText.test.php
index 00e70d4c7..9d4494332 100644
--- a/_test/tests/inc/common_cleanText.test.php
+++ b/_test/tests/inc/common_cleanText.test.php
@@ -3,11 +3,7 @@
class common_cleanText_test extends DokuWikiTest {
function test_unix(){
- $unix = 'one
- two
-
- three';
-
+ $unix = "one\n two\n\n three";
$this->assertEquals($unix,cleanText($unix));
}
diff --git a/_test/tests/inc/events_nested.test.php b/_test/tests/inc/events_nested.test.php
new file mode 100644
index 000000000..fe5e395bb
--- /dev/null
+++ b/_test/tests/inc/events_nested.test.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * This tests if event handlers can trigger the same event again.
+ * This is used by plugins that modify cache handling and use metadata
+ * for checking cache validity which triggers another cache use event.
+ */
+class events_nested_test extends DokuWikiTest {
+ function test_nested_events() {
+ global $EVENT_HANDLER;
+ $firstcount = 0;
+ $secondcount = 0;
+
+ $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null,
+ function() use (&$firstcount) {
+ $firstcount++;
+ if ($firstcount == 1) {
+ $param = array();
+ trigger_event('NESTED_EVENT', $param);
+ }
+ }
+ );
+
+ $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null,
+ function() use (&$secondcount) {
+ $secondcount++;
+ }
+ );
+
+ $param = array();
+ trigger_event('NESTED_EVENT', $param);
+
+ $this->assertEquals(2, $firstcount);
+ $this->assertEquals(2, $secondcount);
+ }
+}
diff --git a/_test/tests/inc/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php
index 9cae3736a..9959a1f06 100644
--- a/_test/tests/inc/httpclient_http.test.php
+++ b/_test/tests/inc/httpclient_http.test.php
@@ -124,6 +124,11 @@ class httpclient_http_test extends DokuWikiTest {
$http->max_bodysize = 250;
$data = $http->get($this->server.'/stream/30');
$this->assertTrue($data === false, 'HTTP response');
+ $http->max_bodysize_abort = false;
+ $data = $http->get($this->server.'/stream/30');
+ $this->assertFalse($data === false, 'HTTP response');
+ /* should read no more than max_bodysize+1 */
+ $this->assertLessThanOrEqual(251,strlen($data));
}
/**
@@ -176,5 +181,15 @@ class httpclient_http_test extends DokuWikiTest {
$this->assertArrayHasKey('foo',$http->resp_headers);
$this->assertEquals('bar',$http->resp_headers['foo']);
}
+
+ /**
+ * @group internet
+ */
+ function test_chunked(){
+ $http = new HTTPClient();
+ $data = $http->get('http://whoopdedo.org/cgi-bin/chunked/2550');
+ $this->assertFalse($data === false, 'HTTP response');
+ $this->assertEquals(2550,strlen($data));
+ }
}
//Setup VIM: ex: et ts=4 :
diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php
new file mode 100644
index 000000000..761b7ddbc
--- /dev/null
+++ b/_test/tests/inc/input.test.php
@@ -0,0 +1,216 @@
+<?php
+
+/**
+ * Tests for the Input class
+ */
+class input_test extends DokuWikiTest {
+
+ private $data = array(
+ 'array' => array('foo', 'bar'),
+ 'string' => 'foo',
+ 'int' => '17',
+ 'zero' => '0',
+ 'one' => '1',
+ 'empty' => '',
+ 'emptya' => array()
+ );
+
+ public function test_str() {
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $_GET['get'] = 1;
+ $_POST['post'] = 1;
+ $INPUT = new Input();
+
+ $this->assertSame('foo', $INPUT->str('string'));
+ $this->assertSame('', $INPUT->str('none'));
+ $this->assertSame('', $INPUT->str('empty'));
+ $this->assertSame('foo', $INPUT->str('none', 'foo'));
+ $this->assertSame('', $INPUT->str('empty', 'foo'));
+ $this->assertSame('foo', $INPUT->str('empty', 'foo', true));
+
+ $this->assertSame(false, $INPUT->str('get', false));
+ $this->assertSame(false, $INPUT->str('post', false));
+
+ $this->assertSame('foo', $INPUT->post->str('string'));
+ $this->assertSame('', $INPUT->post->str('none'));
+ $this->assertSame('', $INPUT->post->str('empty'));
+ $this->assertSame('foo', $INPUT->post->str('none', 'foo'));
+ $this->assertSame('', $INPUT->post->str('empty', 'foo'));
+ $this->assertSame('foo', $INPUT->post->str('empty', 'foo', true));
+
+ $this->assertSame(false, $INPUT->post->str('get', false));
+ $this->assertSame('1', $INPUT->post->str('post', false));
+
+ $this->assertSame('foo', $INPUT->get->str('string'));
+ $this->assertSame('', $INPUT->get->str('none'));
+ $this->assertSame('', $INPUT->get->str('empty'));
+ $this->assertSame('foo', $INPUT->get->str('none', 'foo'));
+ $this->assertSame('', $INPUT->get->str('empty', 'foo'));
+ $this->assertSame('foo', $INPUT->get->str('empty', 'foo', true));
+
+ $this->assertSame(false, $INPUT->get->str('post', false));
+ $this->assertSame('1', $INPUT->get->str('get', false));
+
+ $this->assertSame('', $INPUT->str('array'));
+ }
+
+ public function test_int() {
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $_GET['get'] = 1;
+ $_POST['post'] = 1;
+ $INPUT = new Input();
+
+ $this->assertSame(17, $INPUT->int('int'));
+ $this->assertSame(0, $INPUT->int('none'));
+ $this->assertSame(0, $INPUT->int('empty'));
+ $this->assertSame(42, $INPUT->int('none', 42));
+ $this->assertSame(0, $INPUT->int('zero', 42));
+ $this->assertSame(42, $INPUT->int('zero', 42, true));
+
+ $this->assertSame(false, $INPUT->int('get', false));
+ $this->assertSame(false, $INPUT->int('post', false));
+
+ $this->assertSame(17, $INPUT->post->int('int'));
+ $this->assertSame(0, $INPUT->post->int('none'));
+ $this->assertSame(0, $INPUT->post->int('empty'));
+ $this->assertSame(42, $INPUT->post->int('none', 42));
+ $this->assertSame(0, $INPUT->post->int('zero', 42));
+ $this->assertSame(42, $INPUT->post->int('zero', 42, true));
+
+ $this->assertSame(false, $INPUT->post->int('get', false));
+ $this->assertSame(1, $INPUT->post->int('post', false));
+
+ $this->assertSame(17, $INPUT->post->int('int'));
+ $this->assertSame(0, $INPUT->post->int('none'));
+ $this->assertSame(0, $INPUT->post->int('empty'));
+ $this->assertSame(42, $INPUT->post->int('none', 42));
+ $this->assertSame(0, $INPUT->post->int('zero', 42));
+ $this->assertSame(42, $INPUT->post->int('zero', 42, true));
+
+ $this->assertSame(false, $INPUT->get->int('post', false));
+ $this->assertSame(1, $INPUT->get->int('get', false));
+
+ $this->assertSame(0, $INPUT->int('array'));
+
+ $this->assertSame(0, $INPUT->int('zero', -1));
+ $this->assertSame(-1, $INPUT->int('empty', -1));
+ $this->assertSame(-1, $INPUT->int('zero', -1, true));
+ $this->assertSame(-1, $INPUT->int('empty', -1, true));
+ }
+
+ public function test_arr() {
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $_GET['get'] = array(1, 2);
+ $_POST['post'] = array(1, 2);
+ $INPUT = new Input();
+
+ $this->assertSame(array('foo', 'bar'), $INPUT->arr('array'));
+ $this->assertSame(array(), $INPUT->arr('none'));
+ $this->assertSame(array(), $INPUT->arr('empty'));
+ $this->assertSame(array(1, 2), $INPUT->arr('none', array(1, 2)));
+ $this->assertSame(array(), $INPUT->arr('emptya', array(1, 2)));
+ $this->assertSame(array(1, 2), $INPUT->arr('emptya', array(1, 2), true));
+
+ $this->assertSame(false, $INPUT->arr('get', false));
+ $this->assertSame(false, $INPUT->arr('post', false));
+
+ $this->assertSame(array('foo', 'bar'), $INPUT->post->arr('array'));
+ $this->assertSame(array(), $INPUT->post->arr('none'));
+ $this->assertSame(array(), $INPUT->post->arr('empty'));
+ $this->assertSame(array(1, 2), $INPUT->post->arr('none', array(1, 2)));
+ $this->assertSame(array(), $INPUT->post->arr('emptya', array(1, 2)));
+ $this->assertSame(array(1, 2), $INPUT->post->arr('emptya', array(1, 2), true));
+
+ $this->assertSame(false, $INPUT->post->arr('get', false));
+ $this->assertSame(array(1, 2), $INPUT->post->arr('post', false));
+
+ $this->assertSame(array('foo', 'bar'), $INPUT->get->arr('array'));
+ $this->assertSame(array(), $INPUT->get->arr('none'));
+ $this->assertSame(array(), $INPUT->get->arr('empty'));
+ $this->assertSame(array(1, 2), $INPUT->get->arr('none', array(1, 2)));
+ $this->assertSame(array(), $INPUT->get->arr('emptya', array(1, 2)));
+ $this->assertSame(array(1, 2), $INPUT->get->arr('emptya', array(1, 2), true));
+
+ $this->assertSame(array(1, 2), $INPUT->get->arr('get', false));
+ $this->assertSame(false, $INPUT->get->arr('post', false));
+ }
+
+ public function test_bool() {
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $_GET['get'] = '1';
+ $_POST['post'] = '1';
+ $INPUT = new Input();
+
+ $this->assertSame(true, $INPUT->bool('one'));
+ $this->assertSame(false, $INPUT->bool('zero'));
+
+ $this->assertSame(false, $INPUT->bool('get'));
+ $this->assertSame(false, $INPUT->bool('post'));
+
+ $this->assertSame(true, $INPUT->post->bool('one'));
+ $this->assertSame(false, $INPUT->post->bool('zero'));
+
+ $this->assertSame(false, $INPUT->post->bool('get'));
+ $this->assertSame(true, $INPUT->post->bool('post'));
+
+ $this->assertSame(false, $INPUT->bool('zero', -1));
+ $this->assertSame(-1, $INPUT->bool('empty', -1));
+ $this->assertSame(-1, $INPUT->bool('zero', -1, true));
+ $this->assertSame(-1, $INPUT->bool('empty', -1, true));
+ }
+
+ public function test_remove() {
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $INPUT = new Input();
+
+ $INPUT->remove('string');
+ $this->assertNull($_REQUEST['string']);
+ $this->assertNull($_POST['string']);
+ $this->assertNull($_GET['string']);
+
+ $INPUT->post->remove('int');
+ $this->assertNull($_POST['int']);
+ $this->assertEquals(17, $_GET['int']);
+ $this->assertEquals(17, $_REQUEST['int']);
+ }
+
+ public function test_set(){
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $INPUT = new Input();
+
+ $INPUT->set('test','foo');
+ $this->assertEquals('foo',$_REQUEST['test']);
+ $this->assertNull($_POST['test']);
+ $this->assertNull($_GET['test']);
+
+ $INPUT->get->set('test2','foo');
+ $this->assertEquals('foo',$_GET['test2']);
+ $this->assertEquals('foo',$_REQUEST['test2']);
+ $this->assertNull($_POST['test']);
+ }
+
+ public function test_ref(){
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $INPUT = new Input();
+
+ $test = &$INPUT->ref('string');
+ $this->assertEquals('foo',$test);
+ $_REQUEST['string'] = 'bla';
+ $this->assertEquals('bla',$test);
+ }
+
+}
diff --git a/_test/tests/inc/pageutils_findnearest.test.php b/_test/tests/inc/pageutils_findnearest.test.php
new file mode 100644
index 000000000..e129b5e58
--- /dev/null
+++ b/_test/tests/inc/pageutils_findnearest.test.php
@@ -0,0 +1,40 @@
+<?php
+
+class pageutils_findnearest_test extends DokuWikiTest {
+ function testNoSidebar() {
+ global $ID;
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals(false, $sidebar);
+ }
+
+ function testExistingSidebars() {
+ global $ID;
+
+ saveWikiText('sidebar', 'topsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('sidebar', $sidebar);
+
+ $ID = 'foo';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('sidebar', $sidebar);
+
+ saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('foo:bar:sidebar', $sidebar);
+
+ $ID = 'foo:bar:test';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('foo:bar:sidebar', $sidebar);
+
+ $ID = 'foo';
+ $sidebar = page_findnearest('sidebar');
+ $this->assertEquals('sidebar', $sidebar);
+ }
+
+}
diff --git a/_test/tests/inc/template_sidebar.test.php b/_test/tests/inc/template_sidebar.test.php
new file mode 100644
index 000000000..56153894a
--- /dev/null
+++ b/_test/tests/inc/template_sidebar.test.php
@@ -0,0 +1,40 @@
+<?php
+
+class template_sidebar_test extends DokuWikiTest {
+ function testNoSidebar() {
+ global $ID;
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertEquals('',$sidebar);
+ }
+
+ function testExistingSidebars() {
+ global $ID;
+
+ saveWikiText('sidebar', 'topsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+
+ $ID = 'foo';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+
+ saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', '');
+
+ $ID = 'foo:bar:baz:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
+
+ $ID = 'foo:bar:test';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
+
+ $ID = 'foo';
+ $sidebar = tpl_sidebar(false);
+ $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
+ }
+
+}
diff --git a/_test/tests/lib/exe/js_js_compress.test.php b/_test/tests/lib/exe/js_js_compress.test.php
index aa8d82933..49f93cc54 100644
--- a/_test/tests/lib/exe/js_js_compress.test.php
+++ b/_test/tests/lib/exe/js_js_compress.test.php
@@ -111,12 +111,10 @@ class js_js_compress_test extends DokuWikiTest {
}
function test_multilinestring(){
- $text = 'var foo = "this is a \\
-multiline string";';
+ $text = 'var foo = "this is a \\'."\n".'multiline string";';
$this->assertEquals('var foo="this is a multiline string";',js_compress($text));
- $text = "var foo = 'this is a \\
-multiline string';";
+ $text = "var foo = 'this is a \\\nmultiline string';";
$this->assertEquals("var foo='this is a multiline string';",js_compress($text));
}
diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php
index b4926d2ba..a0ea48a3a 100644
--- a/_test/tests/test/basic.test.php
+++ b/_test/tests/test/basic.test.php
@@ -19,4 +19,87 @@ class InttestsBasicTest extends DokuWikiTest {
'DokuWiki was not a word in the output'
);
}
+
+ function testPost() {
+ $request = new TestRequest();
+
+ $input = array(
+ 'string' => 'A string',
+ 'array' => array(1, 2, 3),
+ 'id' => 'wiki:dokuwiki'
+ );
+
+ $response = $request->post($input);
+
+ // server var check
+ $this->assertEquals('POST',$request->getServer('REQUEST_METHOD'));
+ $this->assertEquals('',$request->getServer('QUERY_STRING'));
+ $this->assertEquals('/doku.php',$request->getServer('REQUEST_URI'));
+
+ // variable setup check
+ $this->assertEquals('A string', $request->getPost('string'));
+ $this->assertEquals(array(1, 2, 3), $request->getPost('array'));
+ $this->assertEquals('wiki:dokuwiki', $request->getPost('id'));
+
+ // output check
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ }
+
+ function testPostGet() {
+ $request = new TestRequest();
+
+ $input = array(
+ 'string' => 'A string',
+ 'array' => array(1, 2, 3),
+ );
+
+ $response = $request->post($input,'/doku.php?id=wiki:dokuwiki');
+
+ // server var check
+ $this->assertEquals('POST',$request->getServer('REQUEST_METHOD'));
+ $this->assertEquals('?id=wiki:dokuwiki',$request->getServer('QUERY_STRING'));
+ $this->assertEquals('/doku.php?id=wiki:dokuwiki',$request->getServer('REQUEST_URI'));
+
+ // variable setup check
+ $this->assertEquals('A string', $request->getPost('string'));
+ $this->assertEquals(array(1, 2, 3), $request->getPost('array'));
+ $this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
+
+ // output check
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ }
+
+ function testGet() {
+ $request = new TestRequest();
+
+ $input = array(
+ 'string' => 'A string',
+ 'array' => array(1, 2, 3),
+ 'test' => 'bar'
+ );
+
+ $response = $request->get($input,'/doku.php?id=wiki:dokuwiki&test=foo');
+
+ // server var check
+ $this->assertEquals('GET',$request->getServer('REQUEST_METHOD'));
+ $this->assertEquals(
+ '?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3',
+ $request->getServer('QUERY_STRING')
+ );
+ $this->assertEquals(
+ '/doku.php?id=wiki:dokuwiki&test=bar&string=A+string&array[0]=1&array[1]=2&array[2]=3',
+ $request->getServer('REQUEST_URI')
+ );
+
+ // variable setup check
+ $this->assertEquals('A string', $request->getGet('string'));
+ $this->assertEquals(array(1, 2, 3), $request->getGet('array'));
+ $this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
+ $this->assertEquals('bar', $request->getGet('test'));
+
+ // output check
+ $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0);
+ }
+
+
}