Skip to content

Commit

Permalink
Merge branch 'master' into authpdo
Browse files Browse the repository at this point in the history
* master: (152 commits)
  updated jquery to 2.2.4
  fixed interwiki test
  simplified amazon interwiki links. closes #1588
  minor optimization how cell counts are fixed in tables
  Beautify code
  Keep query params during redirect to headpage
  Add sleep(1) to remoteapicore to ensure new other timestap(=rev nr)
  take care of file size change of zero
  refactor duplicate sizechange code into its own function
  always separate a number and a unit by a non-breaking space
  fix an unfortunate line break in one of the tabs of the mediamanager when using Arabic
  added doku_hasTextBeenModified, rename doku_checkSummary
  shortening dokucookie option names for extension manager
  Fix xmlrpc constructor for php7
  translation update
  translation update
  translation update
  add phpdocs
  remote api ackcheck: if user given, but no groups, retrieve groups
  use variable in remoteapicore_test
  ...
  • Loading branch information
splitbrain committed Jun 10, 2016
2 parents 7f89f08 + 3be11e1 commit 3882015
Show file tree
Hide file tree
Showing 389 changed files with 7,498 additions and 6,204 deletions.
2 changes: 1 addition & 1 deletion _test/conf/plugins.local.php
Expand Up @@ -4,5 +4,5 @@
* Auto-generated through plugin/extension manager
*
* NOTE: Plugins will not be added to this file unless there is a need to override a default setting. Plugins are
* enabled by default, unless having a 'disabled' file in their plugin folder.
* enabled by default.
*/
8 changes: 8 additions & 0 deletions _test/core/DokuWikiTest.php
Expand Up @@ -73,7 +73,15 @@ public function setUp() {
}
}
}
// reload some settings
$conf['gzip_output'] &= (strpos($_SERVER['HTTP_ACCEPT_ENCODING'],'gzip') !== false);

if($conf['compression'] == 'bz2' && !DOKU_HAS_BZIP) {
$conf['compression'] = 'gz';
}
if($conf['compression'] == 'gz' && !DOKU_HAS_GZIP) {
$conf['compression'] = 0;
}
// make real paths and check them
init_paths();
init_files();
Expand Down
6 changes: 5 additions & 1 deletion _test/tests/inc/common_pageinfo.test.php
Expand Up @@ -128,14 +128,18 @@ function test_rev(){
$filename = $conf['datadir'].'/wiki/syntax.txt';
$rev = filemtime($filename);
$REV = $rev - 100;
$ext = '.txt';
if($conf['compression']) { //compression in $info['filepath'] determined by wikiFN depends also on if the page exist
$ext .= "." . $conf['compression']; //.gz or .bz2
}

$info = $this->_get_expected_pageinfo();
$info['id'] = 'wiki:syntax';
$info['namespace'] = 'wiki';
$info['meta'] = p_get_metadata($ID);
$info['rev'] = $REV;
$info['currentrev'] = $rev;
$info['filepath'] = str_replace('pages','attic',substr($filename,0,-3).$REV.'.txt.gz');
$info['filepath'] = str_replace('pages','attic',substr($filename,0,-3).$REV.$ext);

$this->assertEquals($info, pageinfo());
$this->assertEquals($rev-100, $REV);
Expand Down
262 changes: 260 additions & 2 deletions _test/tests/inc/common_saveWikiText.test.php
Expand Up @@ -23,6 +23,7 @@ function test_savesequence() {
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('first save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_CREATE, $revinfo['type']);
$this->assertEquals(10, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

Expand All @@ -36,7 +37,7 @@ function test_savesequence() {
$this->assertEquals(1, count($revisions));

// update the page with new text
saveWikiText($page, 'teststring2', 'third save', false);
saveWikiText($page, 'teststring2long', 'third save', false);
clearstatcache(false, $file);
$newmod = filemtime($file);
$this->assertNotEquals($lastmod, $newmod);
Expand All @@ -48,11 +49,12 @@ function test_savesequence() {
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('third save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(5, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

// add a minor edit (unauthenticated)
saveWikiText($page, 'teststring3', 'fourth save', true);
saveWikiText($page, 'teststring3long', 'fourth save', true);
clearstatcache(false, $file);
$newmod = filemtime($file);
$this->assertNotEquals($lastmod, $newmod);
Expand All @@ -64,6 +66,7 @@ function test_savesequence() {
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('fourth save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(0, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

Expand All @@ -81,6 +84,7 @@ function test_savesequence() {
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('fifth save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_MINOR_EDIT, $revinfo['type']);
$this->assertEquals(-4, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

Expand All @@ -95,6 +99,7 @@ function test_savesequence() {
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('sixth save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_DELETE, $revinfo['type']);
$this->assertEquals(-11, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

Expand All @@ -114,6 +119,7 @@ function test_savesequence() {
$this->assertEquals('seventh save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_REVERT, $revinfo['type']);
$this->assertEquals($REV, $revinfo['extra']);
$this->assertEquals(11, $revinfo['sizechange']);
$REV = '';

sleep(1); // wait for new revision ID
Expand All @@ -136,10 +142,262 @@ function test_savesequence() {
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('eigth save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(0, $revinfo['sizechange']);

$revinfo = $pagelog->getRevisionInfo($revisions[1]);
$this->assertEquals('external edit', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(0, $revinfo['sizechange']);

}

/**
* Execute a whole bunch of saves on the same page and check the results
*/
function test_savesequencedeleteexternalrevision() {
$page = 'page2';
$file = wikiFN($page);

// create the page
$this->assertFileNotExists($file);
saveWikiText($page, 'teststring', 'first save', false);
$this->assertFileExists($file);
$lastmod = filemtime($file);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(1, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('first save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_CREATE, $revinfo['type']);
$this->assertEquals(10, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

// delete
saveWikiText($page, '', 'second save', false);
clearstatcache(false, $file);
$this->assertFileNotExists($file);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(2, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('second save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_DELETE, $revinfo['type']);
$this->assertEquals(-10, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

// create external edit
file_put_contents($file, 'teststring5');

sleep(1); // wait for new revision ID

// save on top of external edit
saveWikiText($page, 'teststring6', 'third save', false);
clearstatcache(false, $file);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(4, count($revisions)); // two more revisions now!
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('third save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(0, $revinfo['sizechange']);

$revinfo = $pagelog->getRevisionInfo($revisions[1]);
$this->assertEquals('external edit', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(11, $revinfo['sizechange']);

}

/**
* Execute a whole bunch of saves on the same page and check the results
*/
function test_saveexternalasfirst() {
$page = 'page3';
$file = wikiFN($page);

// create the page
$this->assertFileNotExists($file);

// create external edit
file_put_contents($file, 'teststring');

sleep(1); // wait for new revision ID

// save on top of external edit
saveWikiText($page, 'teststring6', 'first save', false);
clearstatcache(false, $file);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(2, count($revisions)); // two more revisions now!
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('first save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(1, $revinfo['sizechange']);

$revinfo = $pagelog->getRevisionInfo($revisions[1]);
$this->assertEquals('external edit', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(10, $revinfo['sizechange']);

}

/**
* Execute a whole bunch of saves on the same page and check the results
*/
function test_savesequenceexternaldeleteedit() {
$page = 'page4';
$file = wikiFN($page);

// create the page
$this->assertFileNotExists($file);
saveWikiText($page, 'teststring', 'first save', false);
$this->assertFileExists($file);
$lastmod = filemtime($file);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(1, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('first save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_CREATE, $revinfo['type']);
$this->assertEquals(10, $revinfo['sizechange']);

sleep(1); // wait for new revision ID


// create external delete
unlink($file);
clearstatcache(false, $file);

sleep(1); // wait for new revision ID

// save on top of external delete. save is seen as creation
saveWikiText($page, 'teststring6', 'second save', false);
clearstatcache(false, $file);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(2, count($revisions)); // one more revisions now!
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('second save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_CREATE, $revinfo['type']);
$this->assertEquals(11, $revinfo['sizechange']);

$revinfo = $pagelog->getRevisionInfo($revisions[1]);
$this->assertEquals('first save', $revinfo['sum']);

}

/**
* Execute a whole bunch of saves on the same page and check the results
*/
function test_savesequencerevert() {
global $REV;

$page = 'page5';
$file = wikiFN($page);

// create the page
$this->assertFileNotExists($file);
saveWikiText($page, 'teststring', 'first save', false);
$this->assertFileExists($file);
$lastmod = filemtime($file);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(1, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('first save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_CREATE, $revinfo['type']);
$this->assertEquals(10, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

// save with same content should be ignored
saveWikiText($page, 'teststring', 'second save', false);
clearstatcache(false, $file);
$this->assertEquals($lastmod, filemtime($file));

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(1, count($revisions));

// update the page with new text
saveWikiText($page, 'teststring2long', 'third save', false);
clearstatcache(false, $file);
$newmod = filemtime($file);
$this->assertNotEquals($lastmod, $newmod);
$lastmod = $newmod;
$revertrev = $newmod;

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(2, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('third save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(5, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

// add a minor edit (unauthenticated)
saveWikiText($page, 'teststring3long', 'fourth save', true);
clearstatcache(false, $file);
$newmod = filemtime($file);
$this->assertNotEquals($lastmod, $newmod);
$lastmod = $newmod;

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(3, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('fourth save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_EDIT, $revinfo['type']);
$this->assertEquals(0, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

// add a minor edit (authenticated)
$_SERVER['REMOTE_USER'] = 'user';
saveWikiText($page, 'teststring4', 'fifth save', true);
clearstatcache(false, $file);
$newmod = filemtime($file);
$this->assertNotEquals($lastmod, $newmod);
$lastmod = $newmod;

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(4, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('fifth save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_MINOR_EDIT, $revinfo['type']);
$this->assertEquals(-4, $revinfo['sizechange']);

sleep(1); // wait for new revision ID

// restore
$REV = $revertrev;
saveWikiText($page, 'teststring2long', 'sixth save', true);
clearstatcache(false, $file);
$this->assertFileExists($file);
$newmod = filemtime($file);
$this->assertNotEquals($lastmod, $newmod);

$pagelog = new PageChangeLog($page);
$revisions = $pagelog->getRevisions(-1, 200);
$this->assertEquals(5, count($revisions));
$revinfo = $pagelog->getRevisionInfo($revisions[0]);
$this->assertEquals('sixth save', $revinfo['sum']);
$this->assertEquals(DOKU_CHANGE_TYPE_REVERT, $revinfo['type']);
$this->assertEquals($REV, $revinfo['extra']);
$this->assertEquals(4, $revinfo['sizechange']);
$REV = '';
}

}

0 comments on commit 3882015

Please sign in to comment.