Skip to content

Commit

Permalink
Merge branch 'master' into tablethead
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris--S committed Mar 12, 2014
2 parents 57a6f99 + 069942a commit 4e60057
Show file tree
Hide file tree
Showing 738 changed files with 15,889 additions and 11,040 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text eol=lf

*.png binary
*.gif binary
*.ico binary
*.xcf binary
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/conf/lang/*
/conf/plugin_lang/*
/conf/plugins.local.*
/conf/tpl/*
.htaccess
*.swp
*.bak
Expand All @@ -26,30 +27,32 @@
/data/media_attic/*
/data/meta/*
/data/pages/*
/data/tmp/*
!/data/pages/wiki/dokuwiki.txt
!/data/pages/wiki/syntax.txt
!/data/pages/wiki/welcome.txt
/data/tmp/*
/lib/tpl/*
!/lib/tpl/default
!/lib/tpl/dokuwiki
!/lib/tpl/index.php
/lib/plugins/*
!/lib/plugins/acl
!/lib/plugins/authad
!/lib/plugins/authldap
!/lib/plugins/authmysql
!/lib/plugins/authpgsql
!/lib/plugins/authplain
!/lib/plugins/acl
!/lib/plugins/config
!/lib/plugins/extension
!/lib/plugins/info
!/lib/plugins/plugin
!/lib/plugins/popularity
!/lib/plugins/revert
!/lib/plugins/safefnrecode
!/lib/plugins/testing
!/lib/plugins/usermanager
!/lib/plugins/action.php
!/lib/plugins/admin.php
!/lib/plugins/auth.php
!/lib/plugins/index.html
!/lib/plugins/remote.php
!/lib/plugins/syntax.php
lib/images/*/local/*
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: php
php:
- "5.5"
- "5.4"
- "5.3"
notifications:
irc:
channels:
- "chat.freenode.net#dokuwiki"
on_success: change
on_failure: change
script: cd _test && phpunit --verbose --stderr
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ at http://www.dokuwiki.org/
For Installation Instructions see
http://www.dokuwiki.org/install

DokuWiki - 2004-2013 (c) Andreas Gohr <[email protected]>
DokuWiki - 2004-2014 (c) Andreas Gohr <[email protected]>
and the DokuWiki Community
See COPYING and file headers for license info

10 changes: 9 additions & 1 deletion _test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
define('SIMPLE_TEST', true);

// basic behaviours
error_reporting(E_ALL);
define('DOKU_E_LEVEL',E_ALL ^ E_NOTICE);
error_reporting(DOKU_E_LEVEL);
set_time_limit(0);
ini_set('memory_limit','2048M');

Expand Down Expand Up @@ -68,6 +69,13 @@
'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);

Expand Down
3 changes: 3 additions & 0 deletions _test/core/DokuWikiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,8 @@ public function setUp() {
// reload language
$local = $conf['lang'];
trigger_event('INIT_LANG_LOAD', $local, 'init_lang', true);

global $INPUT;
$INPUT = new Input();
}
}
9 changes: 8 additions & 1 deletion _test/core/TestRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ public function setPost($key, $value) { $this->post[$key] = $value; }
* @return TestResponse the resulting output of the request
*/
public function execute($uri='/doku.php') {
global $INPUT;
global $ID;
global $INFO;

// save old environment
$server = $_SERVER;
$session = $_SESSION;
$get = $_GET;
$post = $_POST;
$request = $_REQUEST;

$input = $INPUT;

// prepare the right URI
$this->setUri($uri);

Expand All @@ -74,6 +79,7 @@ public function execute($uri='/doku.php') {
// now execute dokuwiki and grep the output
header_remove();
ob_start('ob_start_callback');
$INPUT = new Input();
include(DOKU_INC.$this->script);
ob_end_flush();

Expand All @@ -89,6 +95,7 @@ public function execute($uri='/doku.php') {
$_GET = $get;
$_POST = $post;
$_REQUEST = $request;
$INPUT = $input;

return $response;
}
Expand Down
47 changes: 47 additions & 0 deletions _test/tests/general/general_languagelint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

class general_languagelint_test extends DokuWikiTest {


function test_core() {
$this->checkFiles(glob(DOKU_INC.'inc/lang/*/*.php'));
}

function test_plugins() {
$this->checkFiles(glob(DOKU_INC.'lib/plugins/*/lang/*/*.php'));
}

/**
* Run checks over the given PHP language files
*
* @param $files
*/
private function checkFiles($files){
foreach($files as $file){
// try to load the file
include $file;
// check it defines an array
$this->assertTrue(is_array($lang), $file);
unset($lang);

$this->checkUgly($file);
}
}

/**
* Checks if the file contains any ugly things like leading whitespace, BOM or trailing
* PHP closing mark
*
* @param $file
* @throws Exception
*/
private function checkUgly($file){
$content = rtrim(file_get_contents($file));
if(substr($content,0,5) != '<?php')
throw new Exception("$file does not start with '<?php' - check for BOM");

if(substr($content,-2) == '?>')
throw new Exception("$file ends with '?>' - remove it!");
}

}
130 changes: 130 additions & 0 deletions _test/tests/inc/auth_loadacl.test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
/**
* auth_loadACL carries out the user & group substitutions
*
* @author Chris Smith <[email protected]>
*/

class auth_loadacl_test extends DokuWikiTest {

function setUp() {
global $USERINFO;
parent::setUp();
$_SERVER['REMOTE_USER'] = 'testuser';
$USERINFO['grps'] = array('foo','bar');
}

function tearDown() {
parent::tearDown();
}

function auth_loadACL_testwrapper($acls) {
global $config_cascade;
$acl_file = $config_cascade['acl']['default'];

$config_cascade['acl']['default'] .= '.test';
file_put_contents($config_cascade['acl']['default'],$acls);

$result = auth_loadACL();

unlink($config_cascade['acl']['default']);
$config_cascade['acl']['default'] = $acl_file;

return $result;
}

function test_simple() {
$acls = <<<ACL
* @ALL 2
ACL;
$expect = array("*\t@ALL 2");
$this->assertEquals($expect, $this->auth_loadACL_testwrapper($acls));
}

function test_user_substitution() {
$acls = <<<ACL
%USER% %USER% 2
ACL;
$expect = array(
"testuser\ttestuser 2",
);
$this->assertEquals($expect, $this->auth_loadACL_testwrapper($acls));
}

function test_group_substitution() {
$acls = <<<ACL
%GROUP% %GROUP% 2
ACL;
$expect = array(
"foo\t@foo 2",
"bar\t@bar 2",
);
$this->assertEquals($expect, $this->auth_loadACL_testwrapper($acls));
}

function test_both_substitution() {
$acls = <<<ACL
%GROUP%:%USER% %USER% 2
%GROUP%:%USER% %GROUP% 2
ACL;
$expect = array(
"foo:testuser\ttestuser 2",
"bar:testuser\ttestuser 2",
"foo:testuser\t@foo 2",
"bar:testuser\t@bar 2",
);
$this->assertEquals($expect, $this->auth_loadACL_testwrapper($acls));
}

// put it all together - read the standard acl provided with the test suite
function test_standardtestacls(){
$expect = array(
"*\t@ALL 8",
"private:*\t@ALL 0",
"users:*\t@ALL 1",
"users:testuser:*\ttestuser 16",
"groups:*\t@ALL 1",
"groups:foo:*\t@foo 16",
"groups:bar:*\t@bar 16",
);
$this->assertEquals($expect, auth_loadACL());
}

// FS#2867, '\s' in php regular expressions may match non-space characters utf8 strings
// this is due to locale setting on the server, which may match bytes '\xA0' and '\x85'
// these two bytes are present in valid multi-byte UTF-8 characters.
// this test will use one, 'ठ' (DEVANAGARI LETTER TTHA, e0 a4 a0). There are many others.
function test_FS2867() {
global $USERINFO;

$old_locale = setlocale(LC_ALL, '0');
setlocale(LC_ALL, "English_United States.1252"); // should only succeed on windows systems
setlocale(LC_ALL, "en_US.UTF-8"); // should succeed on other systems

// no point continuing with this test if \s doesn't match A0
if (!preg_match('/\s/',"\xa0")) {
setlocale(LC_ALL, $old_locale);
$this->markTestSkipped('Unable to change locale.');
}

$_SERVER['REMOTE_USER'] = 'utfठ8';
$USERINFO['grps'] = array('utfठ16','utfठa');

$acls = <<<ACL
%GROUP%:%USER% %USER% 2
%GROUP%:* %GROUP% 4
devangariठttha @ALL 2
ACL;
$expect = array(
"utfठ16:utfठ8\tutfठ8 2",
"utfठa:utfठ8\tutfठ8 2",
"utfठ16:*\t@utfठ16 4",
"utfठa:*\t@utfठa 4",
"devangariठttha\t@ALL 2",
);
$this->assertEquals($expect, $this->auth_loadACL_testwrapper($acls));
setlocale(LC_ALL, $old_locale);
}
}

//Setup VIM: ex: et ts=4 :
28 changes: 28 additions & 0 deletions _test/tests/inc/auth_nameencode.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ function test_quote(){
$this->assertEquals(auth_nameencode($in),$out);
}

function test_apostrophe(){
$in = 'hey\'you';
$out = 'hey%27you';
$this->assertEquals(auth_nameencode($in),$out);
}

function test_backslash(){
$in = 'hey\\you';
$out = 'hey%5cyou';
$this->assertEquals(auth_nameencode($in),$out);
}

function test_complex(){
$in = 'hey $ you !$%! foo ';
$out = 'hey%20%24%20you%20%21%24%25%21%20foo%20';
Expand All @@ -42,6 +54,22 @@ function test_groupskipoff(){
$out = '%40hey%24you';
$this->assertEquals(auth_nameencode($in),$out);
}

// include a two byte utf8 character which shouldn't be encoded
function test_hebrew(){
$in = 'nun-נ8';
$expect = 'nun%2dנ8';

$this->assertEquals($expect, auth_nameencode($in));
}

// include a three byte utf8 character which shouldn't be encoded
function test_devanagiri(){
$in = 'ut-fठ8';
$expect = 'ut%2dfठ8';

$this->assertEquals($expect, auth_nameencode($in));
}
}

//Setup VIM: ex: et ts=4 :
10 changes: 5 additions & 5 deletions _test/tests/inc/common_basicinfo.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function setup(){

function _get_info() {
global $USERINFO;
$info = array (
'isadmin' => true,
$info = array (
'isadmin' => true,
'ismanager' => true,
'userinfo' => $USERINFO,
'perm' => 255,
'namespace' => false,
'userinfo' => $USERINFO,
'perm' => 255,
'namespace' => false,
'ismobile' => false,
'client' => 'testuser',
);
Expand Down
10 changes: 5 additions & 5 deletions _test/tests/inc/common_mediainfo.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function setup(){

function _get_info() {
global $USERINFO;
$info = array (
'isadmin' => true,
$info = array (
'isadmin' => true,
'ismanager' => true,
'userinfo' => $USERINFO,
'perm' => 255,
'namespace' => false,
'userinfo' => $USERINFO,
'perm' => 255,
'namespace' => false,
'ismobile' => false,
'client' => 'testuser',
);
Expand Down
Loading

0 comments on commit 4e60057

Please sign in to comment.