Skip to content

Commit

Permalink
Merge branch 'master' into new_css.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gamma committed Dec 22, 2014
2 parents de4634e + 8da2ebf commit fc30ac3
Show file tree
Hide file tree
Showing 307 changed files with 5,217 additions and 1,213 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Expand Up @@ -4,14 +4,13 @@ php:
- "5.5"
- "5.4"
- "5.3"
# PHP 5.6 is not yet released, allow failures
matrix:
allow_failures:
- php: "5.6"
notifications:
irc:
channels:
- "chat.freenode.net#dokuwiki"
on_success: change
on_failure: change
script: cd _test && phpunit --verbose --stderr
install:
- wget https://phar.phpunit.de/phpunit-4.3.5.phar -O _test/phpunit
- chmod 755 _test/phpunit
script: cd _test && ./phpunit --verbose --stderr
2 changes: 0 additions & 2 deletions _test/core/TestRequest.php
Expand Up @@ -45,8 +45,6 @@ public function setPost($key, $value) { $this->post[$key] = $value; }
*/
public function execute($uri='/doku.php') {
global $INPUT;
global $ID;
global $INFO;

// save old environment
$server = $_SERVER;
Expand Down
Binary file added _test/data/media/wiki/kind_zu_katze.ogv
Binary file not shown.
Binary file added _test/data/media/wiki/kind_zu_katze.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _test/data/media/wiki/kind_zu_katze.webm
Binary file not shown.
127 changes: 127 additions & 0 deletions _test/tests/inc/changelog_getlastrevisionat.test.php
@@ -0,0 +1,127 @@
<?php

/**
* Tests for requesting revisioninfo of a revision of a page with getRevisionInfo()
*
* This class uses the files:
* - data/pages/mailinglist.txt
* - data/meta/mailinglist.changes
*/
class changelog_getlastrevisionat_test extends DokuWikiTest {

private $pageid = 'mailinglist';

function setup() {
parent::setup();
global $cache_revinfo;
$cache =& $cache_revinfo;
if(isset($cache['nonexist'])) {
unset($cache['nonexist']);
}
if(isset($cache['mailinglist'])) {
unset($cache['mailinglist']);
}
}


/**
* no nonexist.changes meta file available
*/
function test_changemetadatanotexists() {
$rev = 1362525899;
$id = 'nonexist';
$revsexpected = false;

$pagelog = new PageChangeLog($id, $chunk_size = 8192);
$revs = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($revsexpected, $revs);
}

/**
* start at exact current revision of mailinglist page
*
*/
function test_startatexactcurrentrev() {
$rev = 1385051947;
$revsexpected = '';

//set a known timestamp
touch(wikiFN($this->pageid), $rev);

$pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
$revs = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($revsexpected, $revs);

}

/**
* test a future revision
*
*/
function test_futurerev() {
$rev = 1385051947;
$revsexpected = '';

//set a known timestamp
touch(wikiFN($this->pageid), $rev);

$rev +=1;

$pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
$revs = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($revsexpected, $revs);

}

/**
* start at exact last revision of mailinglist page
*
*/
function test_exactlastrev() {
$rev = 1360110636;
$revsexpected = 1360110636;

$pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
$revs = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($revsexpected, $revs);
}


/**
* Request not existing revision
*
*/
function test_olderrev() {
$rev = 1;
$revexpected = false;

$pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
$revfound = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($revexpected, $revfound);
}

/**
* Start at non existing revision somewhere between existing revisions
*/
function test_notexistingrev() {
$rev = 1362525890;
$revexpected = 1362525359;

$pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
$revfound = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($revexpected, $revfound);
}

/**
* request nonexisting page
*
*/
function test_notexistingpage() {
$rev = 1385051947;
$currentexpected = false;

$pagelog = new PageChangeLog('nonexistingpage', $chunk_size = 8192);
$current = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($currentexpected, $current);
}
}
11 changes: 11 additions & 0 deletions _test/tests/inc/common_ml.test.php
Expand Up @@ -146,4 +146,15 @@ function test_ml_imgresize_array_external() {
$this->assertEquals($expect, ml($id, $args));

}

function test_ml_empty_rev() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;

$args = array('a' => 'b', 'c' => 'd', 'rev' => '');

$expect = DOKU_BASE . $this->script . '?a=b&amp;c=d&amp;media=some:img.jpg';
$this->assertEquals($expect, ml('some:img.jpg', $args));
}
}
11 changes: 11 additions & 0 deletions _test/tests/inc/common_wl.test.php
Expand Up @@ -142,6 +142,17 @@ function test_wl_useslash_rewrite2() {
$expect = DOKU_BASE . DOKU_SCRIPT . '/some/one?a=b&c=d';
$this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&'));
}

function test_wl_empty_rev() {
global $conf;
$conf['useslash'] = 0;
$conf['userewrite'] = 0;

$args = array('a' => 'b', 'c' => 'd', 'rev' => '');

$expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&amp;a=b&amp;c=d';
$this->assertEquals($expect, wl('some:', $args));
}



Expand Down
81 changes: 81 additions & 0 deletions _test/tests/inc/init_checkssl.test.php
@@ -0,0 +1,81 @@
<?php

class init_checkssl_test extends DokuWikiTest {

/**
* Running behind an SSL proxy, HTTP between server and proxy
* HTTPS not set
* HTTP_X_FORWARDED_PROTO
* set to https
*/
function test1() {
$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';

$this->assertEquals(is_ssl(), true);
}

/**
* Running behind a plain HTTP proxy, HTTP between server and proxy
* HTTPS not set
* HTTP_X_FORWARDED_PROTO set to http
*/
function test2() {
$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'http';

$this->assertEquals(is_ssl(), false);
}

/**
* Running behind an SSL proxy, HTTP between server and proxy
* HTTPS set to off,
* HTTP_X_FORWARDED_PROTO set to https
*/
function test3() {
$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
$_SERVER['HTTPS'] = 'off';

$this->assertEquals(is_ssl(), true);
}

/**
* Not running behind a proxy, HTTPS server
* HTTPS set to on,
* HTTP_X_FORWARDED_PROTO not set
*/
function test4() {
$_SERVER['HTTPS'] = 'on';

$this->assertEquals(is_ssl(), true);
}

/**
* Not running behind a proxy, plain HTTP server
* HTTPS not set
* HTTP_X_FORWARDED_PROTO not set
*/
function test5() {
$this->assertEquals(is_ssl(), false);
}

/**
* Not running behind a proxy, plain HTTP server
* HTTPS set to off
* HTTP_X_FORWARDED_PROTO not set
*/
function test6() {
$_SERVER['HTTPS'] = 'off';
$this->assertEquals(is_ssl(), false);
}

/**
* Running behind an SSL proxy, SSL between proxy and HTTP server
* HTTPS set to on,
* HTTP_X_FORWARDED_PROTO set to https
*/
function test7() {
$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
$_SERVER['HTTPS'] = 'on';

$this->assertEquals(is_ssl(), true);
}
}
50 changes: 50 additions & 0 deletions _test/tests/inc/input.test.php
Expand Up @@ -14,8 +14,58 @@ class input_test extends DokuWikiTest {
'empty' => '',
'emptya' => array(),
'do' => array('save' => 'Speichern'),

);

/**
* custom filter function
*
* @param $string
* @return mixed
*/
public function myfilter($string) {
$string = str_replace('foo', 'bar', $string);
$string = str_replace('baz', '', $string);
return $string;
}

public function test_filter() {
$_GET = array(
'foo' => 'foo',
'zstring'=> "foo\0bar",
'znull' => "\0",
'zint' => '42'."\0".'42',
'zintbaz'=> "baz42",
);
$_POST = $_GET;
$_REQUEST = $_GET;
$INPUT = new Input();

$filter = array($this,'myfilter');

$this->assertNotSame('foobar', $INPUT->str('zstring'));
$this->assertSame('foobar', $INPUT->filter()->str('zstring'));
$this->assertSame('bar', $INPUT->filter($filter)->str('foo'));
$this->assertSame('bar', $INPUT->filter()->str('znull', 'bar', true));
$this->assertNotSame('foobar', $INPUT->str('zstring')); // make sure original input is unmodified

$this->assertNotSame('foobar', $INPUT->get->str('zstring'));
$this->assertSame('foobar', $INPUT->get->filter()->str('zstring'));
$this->assertSame('bar', $INPUT->get->filter($filter)->str('foo'));
$this->assertSame('bar', $INPUT->get->filter()->str('znull', 'bar', true));
$this->assertNotSame('foobar', $INPUT->get->str('zstring')); // make sure original input is unmodified

$this->assertNotSame(4242, $INPUT->int('zint'));
$this->assertSame(4242, $INPUT->filter()->int('zint'));
$this->assertSame(42, $INPUT->filter($filter)->int('zintbaz'));
$this->assertSame(42, $INPUT->filter()->str('znull', 42, true));

$this->assertSame(true, $INPUT->bool('znull'));
$this->assertSame(false, $INPUT->filter()->bool('znull'));

$this->assertSame('foobar', $INPUT->filter()->valid('zstring', array('foobar', 'bang')));
}

public function test_str() {
$_REQUEST = $this->data;
$_POST = $this->data;
Expand Down
2 changes: 1 addition & 1 deletion _test/tests/inc/parser/parser_footnote.test.php
Expand Up @@ -303,7 +303,7 @@ function testFootnoteList() {
array('nest', array ( array (
array('footnote_open',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listitem_open',array(1,Doku_Handler_List::NODE)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
Expand Down

0 comments on commit fc30ac3

Please sign in to comment.