Skip to content

Commit

Permalink
Merge branch 'stable' into old-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
bug committed Apr 22, 2018
2 parents ca9c643 + 95e31f5 commit e093d61
Show file tree
Hide file tree
Showing 544 changed files with 58,724 additions and 52,022 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Expand Up @@ -18,6 +18,11 @@
*.DS_Store
*.iml
.idea/
# Eclipse IDE
.buildpath
.project
.settings/
# DokuWiki
/data/attic/*
/data/cache/*
/data/index/*
Expand Down Expand Up @@ -72,3 +77,7 @@ vendor/*/*/docs/*
vendor/*/*/contrib/*
vendor/splitbrain/php-archive/apigen.neon
vendor/splitbrain/php-archive/generate-api.sh
vendor/paragonie/random_compat/build-phar.sh
vendor/paragonie/random_compat/dist/*
vendor/paragonie/random_compat/other/*
vendor/simplepie/simplepie/db.sql
32 changes: 27 additions & 5 deletions .travis.yml
@@ -1,29 +1,51 @@
language: php
sudo: false
php:
- "7.1"
- "7.0"
- "5.6"
- "5.5"
- "5.4"
- "5.3"
- "hhvm"

env:
- DISABLE_FUNCTIONS=
- DISABLE_FUNCTIONS="gzopen"
matrix:
fast_finish: true
include:
- php: hhvm
sudo: true
dist: trusty
group: edge # until the next update
addons:
apt:
packages:
- mysql-server-5.6
- mysql-client-core-5.6
- mysql-client-5.6
services:
- mysql
- postgresql
env: DISABLE_FUNCTIONS=
allow_failures:
- php: "hhvm"
exclude:
- php: "hhvm"
env: DISABLE_FUNCTIONS="gzopen"
notifications:
irc:
channels:
- "chat.freenode.net#dokuwiki"
on_success: change
on_failure: change
services:
- "mysql"
- "postgresql"
install:
- wget -O ~/.phpenv/versions/hhvm/bin/phpunit https://phar.phpunit.de/phpunit.phar
- chmod 755 ~/.phpenv/versions/hhvm/bin/phpunit
before_script:
- echo "disable_functions=$DISABLE_FUNCTIONS" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
# Disable the HHVM JIT for faster Unit Testing
- if [[ $TRAVIS_PHP_VERSION = hhv* ]]; then echo 'hhvm.jit = 0' >> /etc/hhvm/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION != hhv* ]]; then test -z "$DISABLE_FUNCTIONS" || echo "disable_functions=$DISABLE_FUNCTIONS" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi
- cp _test/mysql.conf.php.dist _test/mysql.conf.php
- cp _test/pgsql.conf.php.dist _test/pgsql.conf.php
script: cd _test && phpunit --verbose --stderr
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2016-06-26e "Elenor of Tsort"
2017-02-19e "Frusterick Manners"
51 changes: 51 additions & 0 deletions _test/core/DokuWikiTest.php
Expand Up @@ -127,4 +127,55 @@ public function setUp() {
global $INPUT;
$INPUT = new Input();
}

/**
* Compatibility for older PHPUnit versions
*
* @param string $originalClassName
* @return PHPUnit_Framework_MockObject_MockObject
*/
protected function createMock($originalClassName) {
if(is_callable(array('parent', 'createMock'))) {
return parent::createMock($originalClassName);
} else {
return $this->getMock($originalClassName);
}
}

/**
* Compatibility for older PHPUnit versions
*
* @param string $originalClassName
* @param array $methods
* @return PHPUnit_Framework_MockObject_MockObject
*/
protected function createPartialMock($originalClassName, array $methods) {
if(is_callable(array('parent', 'createPartialMock'))) {
return parent::createPartialMock($originalClassName, $methods);
} else {
return $this->getMock($originalClassName, $methods);
}
}

/**
* Waits until a new second has passed
*
* The very first call will return immeadiately, proceeding calls will return
* only after at least 1 second after the last call has passed.
*
* When passing $init=true it will not return immeadiately but use the current
* second as initialization. It might still return faster than a second.
*
* @param bool $init wait from now on, not from last time
* @return int new timestamp
*/
protected function waitForTick($init = false) {
static $last = 0;
if($init) $last = time();
while($last === $now = time()) {
usleep(100000); //recheck in a 10th of a second
}
$last = $now;
return $now;
}
}
11 changes: 11 additions & 0 deletions _test/data/media/wiki/test.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion _test/tests/inc/auth_password.test.php
Expand Up @@ -12,7 +12,7 @@ class auth_password_test extends DokuWikiTest {
'lsmd5' => '{SMD5}HGbkPrkWgy9KgcRGWlrsUWFiY2RlZmdo',
'crypt' => 'ablvoGr1hvZ5k',
'mysql' => '4a1fa3780bd6fd55',
'my411' => '*e5929347e25f82e19e4ebe92f1dc6b6e7c2dbd29',
'my411' => '*E5929347E25F82E19E4EBE92F1DC6B6E7C2DBD29',
'kmd5' => 'a579299436d7969791189acadd86fcb716',
'djangomd5' => 'md5$abcde$d0fdddeda8cd92725d2b54148ac09158',
'djangosha1' => 'sha1$abcde$c8e65a7f0acc9158843048a53dcc5a6bc4d17678',
Expand Down
44 changes: 43 additions & 1 deletion _test/tests/inc/changelog_getlastrevisionat.test.php
Expand Up @@ -124,4 +124,46 @@ function test_notexistingpage() {
$current = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($currentexpected, $current);
}
}

/**
* test get correct revision on deleted media
*
*/
function test_deletedimage() {
global $conf;
global $AUTH_ACL;

//we need to have a user with AUTH_DELETE rights
//save settings
$oldSuperUser = $conf['superuser'];
$oldUseacl = $conf['useacl'];
$oldRemoteUser = $_SERVER['REMOTE_USER'];

$conf['superuser'] = 'admin';
$conf['useacl'] = 1;
$_SERVER['REMOTE_USER'] = 'admin';

$image = 'wiki:imageat.png';

$ret = copy(mediaFn('wiki:kind_zu_katze.png'),mediaFn($image));

$revexpected = @filemtime(mediaFn($image));
$rev = $revexpected + 10;

$this->waitForTick(true);

$ret = media_delete($image, 0);

$medialog = new MediaChangelog($image);
$current = $medialog->getLastRevisionAt($rev);
// as we wait for a tick, we should get something greater than the timestamp
$this->assertGreaterThan($revexpected, $current);
// however, it should be less than the current time or equal to it
$this->assertLessThanOrEqual(time(), $current);

//restore settings
$_SERVER['REMOTE_USER'] = $oldRemoteUser;
$conf['superuser'] = $oldSuperUser;
$conf['useacl'] = $oldUseacl;
}
}
28 changes: 28 additions & 0 deletions _test/tests/inc/common_inlineSVG.test.php
@@ -0,0 +1,28 @@
<?php

class common_embedSVG_test extends DokuWikiTest {

/**
* embed should succeed with a cleaned up result
*/
function test_success() {
$file = mediaFN('wiki:test.svg');
$clean =
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" '.
'width="64" height="64" viewBox="0 0 64 64"><path d="M64 20l-32-16-32 16 32 16 32-16zM32 '.
'9.311l21.379 10.689-21.379 10.689-21.379-10.689 21.379-10.689zM57.59 28.795l6.41 3.205-32 16-32-16 '.
'6.41-3.205 25.59 12.795zM57.59 40.795l6.41 3.205-32 16-32-16 6.41-3.205 25.59 12.795z" '.
'fill="#000000"></path></svg>';

$this->assertEquals($clean, inlineSVG($file));
}

/**
* embed should fail because of the file size limit
*/
function test_fail() {
$file = mediaFN('wiki:test.svg');
$this->assertFalse(inlineSVG($file, 100));
}

}

0 comments on commit e093d61

Please sign in to comment.