summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAdrian Lang <mail@adrianlang.de>2011-11-10 15:43:15 +0100
committerAdrian Lang <mail@adrianlang.de>2011-11-10 15:43:15 +0100
commit16a774a8a61756df2d8fb813bfbaed98b42e3e65 (patch)
tree3a48d311e74ccbf4017330cef8af00003b0ddb34 /_test
parent662a7b3fcc22d8327026bc1ef161a096683f1580 (diff)
parenta5a71ecfcc1ed6bfca1995b39cd0abe4b8dd9eeb (diff)
downloadrpg-16a774a8a61756df2d8fb813bfbaed98b42e3e65.tar.gz
rpg-16a774a8a61756df2d8fb813bfbaed98b42e3e65.tar.bz2
Merge branch 'master' into stable
Conflicts: doku.php
Diffstat (limited to '_test')
-rw-r--r--_test/cases/inc/auth_password.test.php3
-rw-r--r--_test/cases/inc/pageutils_clean_id.test.php10
-rw-r--r--_test/cases/inc/search/data/ns1/ns3/page3.txt0
-rw-r--r--_test/cases/inc/search/data/ns1/page1.txt0
-rw-r--r--_test/cases/inc/search/data/ns1/page2.txt0
-rw-r--r--_test/cases/inc/search/data/ns2/nopage.ext0
-rw-r--r--_test/cases/inc/search/data/ns2/page1.txt0
-rw-r--r--_test/cases/inc/search/search.test.php102
-rw-r--r--_test/cases/inc/utf8_stripspecials.test.php1
-rw-r--r--_test/cases/lib/exe/js_js_compress.test.php6
-rw-r--r--_test/jslint.js89
11 files changed, 209 insertions, 2 deletions
diff --git a/_test/cases/inc/auth_password.test.php b/_test/cases/inc/auth_password.test.php
index 8646e3226..928552a14 100644
--- a/_test/cases/inc/auth_password.test.php
+++ b/_test/cases/inc/auth_password.test.php
@@ -43,8 +43,7 @@ class auth_password_test extends UnitTestCase {
foreach($this->passes as $method => $hash){
$info = "testing method $method";
$this->signal('failinfo',$info);
-
- $hash = auth_cryptPassword('foo'.$method);
+ $hash = auth_cryptPassword('foo'.$method,$method);
$this->assertTrue(auth_verifyPassword('foo'.$method,$hash));
}
}
diff --git a/_test/cases/inc/pageutils_clean_id.test.php b/_test/cases/inc/pageutils_clean_id.test.php
index 01fa7dc1c..167229c7f 100644
--- a/_test/cases/inc/pageutils_clean_id.test.php
+++ b/_test/cases/inc/pageutils_clean_id.test.php
@@ -35,6 +35,16 @@ class init_clean_id_test extends UnitTestCase {
$tests[] = array('ښ侧化并곦 β',false,'ښ侧化并곦_β');
$tests[] = array('page:page',false,'page:page');
$tests[] = array('page;page',false,'page:page');
+ $tests[] = array('page:page 1.2',false,'page:page_1.2');
+
+ $tests[] = array('page._#!','false','page');
+ $tests[] = array('._#!page','false','page');
+ $tests[] = array('page._#!page','false','page._page');
+ $tests[] = array('ns._#!:page','false','ns:page');
+ $tests[] = array('ns:._#!page','false','ns:page');
+ $tests[] = array('ns._#!ns:page','false','ns._ns:page');
+ $tests[] = array('ns_:page',false,'ns:page');
+ $tests[] = array('page...page','false','page...page');
$conf['useslash'] = 0;
$tests[] = array('page/page',false,'page_page');
diff --git a/_test/cases/inc/search/data/ns1/ns3/page3.txt b/_test/cases/inc/search/data/ns1/ns3/page3.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/_test/cases/inc/search/data/ns1/ns3/page3.txt
diff --git a/_test/cases/inc/search/data/ns1/page1.txt b/_test/cases/inc/search/data/ns1/page1.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/_test/cases/inc/search/data/ns1/page1.txt
diff --git a/_test/cases/inc/search/data/ns1/page2.txt b/_test/cases/inc/search/data/ns1/page2.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/_test/cases/inc/search/data/ns1/page2.txt
diff --git a/_test/cases/inc/search/data/ns2/nopage.ext b/_test/cases/inc/search/data/ns2/nopage.ext
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/_test/cases/inc/search/data/ns2/nopage.ext
diff --git a/_test/cases/inc/search/data/ns2/page1.txt b/_test/cases/inc/search/data/ns2/page1.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/_test/cases/inc/search/data/ns2/page1.txt
diff --git a/_test/cases/inc/search/search.test.php b/_test/cases/inc/search/search.test.php
new file mode 100644
index 000000000..a6f15e9b6
--- /dev/null
+++ b/_test/cases/inc/search/search.test.php
@@ -0,0 +1,102 @@
+<?php
+require_once DOKU_INC.'inc/search.php';
+
+class search_test extends UnitTestCase {
+ 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->assertEqual(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->assertEqual(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->assertEqual(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 :
diff --git a/_test/cases/inc/utf8_stripspecials.test.php b/_test/cases/inc/utf8_stripspecials.test.php
index 85df75fa1..481f47650 100644
--- a/_test/cases/inc/utf8_stripspecials.test.php
+++ b/_test/cases/inc/utf8_stripspecials.test.php
@@ -17,6 +17,7 @@ class utf8_stripspecials extends UnitTestCase {
$tests[] = array('ascii.string','','\._\-:\*','asciistring');
$tests[] = array('ascii.string',' ','\._\-:\*','ascii string');
$tests[] = array('2.1.14',' ','\._\-:\*','2 1 14');
+ $tests[] = array('string with nbsps','_','\*','string_with_nbsps');
foreach($tests as $test){
$this->assertEqual(utf8_stripspecials($test[0],$test[1],$test[2]),$test[3]);
diff --git a/_test/cases/lib/exe/js_js_compress.test.php b/_test/cases/lib/exe/js_js_compress.test.php
index 76b51e5ab..4702d35d3 100644
--- a/_test/cases/lib/exe/js_js_compress.test.php
+++ b/_test/cases/lib/exe/js_js_compress.test.php
@@ -105,6 +105,12 @@ class js_js_compress_test extends UnitTestCase {
}
+ function test_complexminified(){
+ $text = 'if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class=\'test e\'></div><div class=\'test\'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;foo="text/*";bla="*/"';
+
+ $this->assertEqual(js_compress($text),$text);
+ }
+
/**
* Test the files provided with the original JsStrip
*/
diff --git a/_test/jslint.js b/_test/jslint.js
new file mode 100644
index 000000000..730f8d8a8
--- /dev/null
+++ b/_test/jslint.js
@@ -0,0 +1,89 @@
+/**
+ * Copy to a JavaScript console on your DokuWiki instance and execute
+ * Runs JSLint on all our JavaScript files with our settings
+ */
+
+(function () {
+var globals = ['jQuery', 'SIG', 'NS', 'JSINFO', 'LANG', 'DOKU_BASE',
+ 'DOKU_UHC' // FIXME: Should be moved to JSINFO
+ ], files = {
+ 'scripts/behaviour.js': null,
+ //"scripts/compatibility.js": null,
+ "scripts/cookie.js": null,
+ //"scripts/delay.js": null,
+ //"scripts/drag.js": null,
+ "scripts/edit.js": null,
+ "scripts/editor.js": null,
+ "scripts/helpers.js": null,
+ "scripts/hotkeys.js": null,
+ "scripts/index.js": null,
+ "scripts/linkwiz.js": null,
+ "scripts/locktimer.js": null,
+ "scripts/media.js": null,
+ "scripts/page.js": null,
+ "scripts/qsearch.js": null,
+ "scripts/script.js": null,
+ "scripts/textselection.js": null,
+ "scripts/toolbar.js": null,
+ "scripts/tree.js": null //,
+ //"scripts/tw-sack.js": null
+ }, overwrites = {
+ "scripts/script.js": {evil: true},
+ "scripts/media.js": {devel: true, windows: true},
+ "scripts/locktimer.js": {devel: true},
+ "scripts/behaviour.js": {devel: true},
+ "scripts/helpers.js": {windows: true}
+ };
+
+jQuery.ajax({
+ dataType: 'script',
+ type: "GET",
+// url: 'http://jshint.com/jshint.js'
+ url: 'https://raw.github.com/douglascrockford/JSLint/master/jslint.js',
+ success: function () {
+ for (var file in files) {
+ jQuery.ajax({
+ cache: false,
+ async: false,
+ type: "GET",
+ url: DOKU_BASE + 'lib/' + file,
+ dataType: 'text',
+ success: function (res) {
+ files[file] = res;
+ var data = lint(files[file]);
+ jQuery.merge(globals, data.globals);
+ }});
+ }
+
+ for (var file in files) {
+ if (!files[file]) {
+ continue;
+ }
+ // FIXME more fine-grained write access
+ var data = lint('/*global ' + globals.join(':true, ') +
+ ':true*/\n' + files[file], overwrites[file]);
+ console.log(file);
+ jQuery.each(data.errors || [], function (_, val) {
+ if (val === null) {
+ return;
+ }
+ console.error(val.reason + ' (Line ' + (val.line - 1) +
+ ', character ' + val.character + '):\n' +
+ val.evidence);
+ });
+ };
+ }
+});
+
+function lint(txt, overwrite) {
+ JSLINT(txt, jQuery.extend({
+ // These settings are necessary
+ browser: true,
+
+ // Things we probably should learn someday
+ sloppy: true, white: true, eqeq: true, nomen: true,
+ plusplus: true, regexp: true
+ }, overwrite));
+ return JSLINT.data();
+}
+})();