Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into overridablelangstrings
Browse files Browse the repository at this point in the history
Conflicts:
	inc/plugin.php
  • Loading branch information
Klap-in committed Sep 28, 2014
2 parents 7341158 + da95727 commit b79379f
Show file tree
Hide file tree
Showing 400 changed files with 24,391 additions and 17,458 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Expand Up @@ -4,3 +4,11 @@
*.gif binary
*.ico binary
*.xcf binary

.gitattributes export-ignore
.gitignore export-ignore
.editorconfig export-ignore
.travis.yml export-ignore
_test export-ignore
_cs export-ignore
lib/plugins/testing export-ignore
5 changes: 5 additions & 0 deletions .travis.yml
@@ -1,8 +1,13 @@
language: php
php:
- "5.6"
- "5.5"
- "5.4"
- "5.3"
# PHP 5.6 is not yet released, allow failures
matrix:
allow_failures:
- php: "5.6"
notifications:
irc:
channels:
Expand Down
10 changes: 8 additions & 2 deletions _test/tests/inc/cache_use.test.php
Expand Up @@ -18,14 +18,20 @@ function setUp() {
$conf['cachetime'] = 0; // ensure the value is not -1, which disables caching

saveWikiText($ID, 'Content', 'Created');
// set the modification time a second in the past in order to ensure that the cache is newer than the page
touch($file, time()-1);

$this->cache = new cache_renderer($ID, $file, 'xhtml');
$this->cache->storeCache('Test');

// set the modification times explicitly (overcome Issue #694)
$time = time();
touch($file, $time-1);
touch($this->cache->cache, $time);
}

function test_use() {
$this->markTestSkipped('Disabled until Ticket #694 has been fixed');
return;

$this->assertTrue($this->cache->useCache());
}

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

class cli_options extends DokuWikiTest {

function test_simpleshort() {
$options = new DokuCLI_Options();
$options->registerOption('exclude', 'exclude files', 'x', 'file');

$options->args = array('-x', 'foo', 'bang');
$options->parseOptions();

$this->assertEquals('foo', $options->getOpt('exclude'));
$this->assertEquals(array('bang'), $options->args);
$this->assertFalse($options->getOpt('nothing'));
}

function test_simplelong1() {
$options = new DokuCLI_Options();
$options->registerOption('exclude', 'exclude files', 'x', 'file');

$options->args = array('--exclude', 'foo', 'bang');
$options->parseOptions();

$this->assertEquals('foo', $options->getOpt('exclude'));
$this->assertEquals(array('bang'), $options->args);
$this->assertFalse($options->getOpt('nothing'));
}

function test_simplelong2() {
$options = new DokuCLI_Options();
$options->registerOption('exclude', 'exclude files', 'x', 'file');

$options->args = array('--exclude=foo', 'bang');
$options->parseOptions();

$this->assertEquals('foo', $options->getOpt('exclude'));
$this->assertEquals(array('bang'), $options->args);
$this->assertFalse($options->getOpt('nothing'));
}

function test_complex() {
$options = new DokuCLI_Options();

$options->registerOption('plugins', 'run on plugins only', 'p');
$options->registerCommand('status', 'display status info');
$options->registerOption('long', 'display long lines', 'l', false, 'status');

$options->args = array('-p', 'status', '--long', 'foo');
$options->parseOptions();

$this->assertEquals('status', $options->getCmd());
$this->assertTrue($options->getOpt('plugins'));
$this->assertTrue($options->getOpt('long'));
$this->assertEquals(array('foo'), $options->args);
}
}
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
15 changes: 15 additions & 0 deletions _test/tests/lib/exe/css_css_compress.test.php
Expand Up @@ -53,6 +53,21 @@ function test_slcom5(){
$this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text));
}

function test_slcom6(){
$text = '#foo {
background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented
}';
$this->assertEquals('#foo{background-image:url(//foo.bar/baz.jpg);}', css_compress($text));
}

function test_slcom7(){
$text = '#foo a[href ^="https://"], #foo a[href ^=\'https://\'] {
background-image: url(//foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is \'all\' "commented"
}';
$this->assertEquals('#foo a[href ^="https://"],#foo a[href ^=\'https://\']{background-image:url(//foo.bar/baz.jpg);}', css_compress($text));
}


function test_hack(){
$text = '/* Mac IE will not see this and continue with inline-block */
/* \\*/
Expand Down

0 comments on commit b79379f

Please sign in to comment.