Merge pull request #96 from dom-mel/phpunit

Replace SimpleTest with PHPUnit
This commit is contained in:
Andreas Gohr 2012-05-01 12:38:41 -07:00
commit 3c0d44f1aa
164 changed files with 8917 additions and 5540 deletions

1
.gitignore vendored
View File

@ -37,6 +37,7 @@
!/lib/plugins/popularity
!/lib/plugins/revert
!/lib/plugins/safefnrecode
!/lib/plugins/testing
!/lib/plugins/usermanager
!/lib/plugins/action.php
!/lib/plugins/admin.php

View File

@ -1,84 +1,82 @@
--------------------------------------------------------------------------------
Dokuwiki Unit Test Suite
--------------------------------------------------------------------------------
$Date: 2004/02/14 02:14:50 $
Credits: to the WACT team - http://www.phpwact.org, from whom the basis of
this test suite was stolen
--------------------------------------------------------------------------------
INSTALLING & SETUP
1. Grab a copy of the SimpleTest unit testing framework an extract somewhere
http://www.lastcraft.com/simple_test.php
or
http://sourceforge.net/projects/simpletest
2. Edit ./tests.ini
- TEST_ENABLED - set to "1" to allow the test suite to be used
by vistors to your site. Generally best to leave as 0 for
a productive site - running tests alot will hammer the server
Note: you will still be able to run the tests from the command
line even when this is set to 0
- WEB_TEST_URL - this is for running "web tests" where SimpleTest
acts as a web browser and executes HTTP requests against pages.
Should point at your Dokuwiki URL e.g.
http://localhost/dokuwiki
- PROXY - if you're behind a proxy, specify it here
Note: username / password are optional e.g.
http://proxyuser:proxypwd@proxy.yourdomain.com:8080
- REMOTE_TEST_URL - it's possible to run the full test suite
remotely (over HTTP) with some XML goodness. This should
point at the URL of the test suite you want to test
See the following URL for more info;
http://www.sitepoint.com/blogs/2004/06/15/simple-test-remote-testing/
- Simple Test
Update the library_path to point at the directory where you installed
Simple Test
--------------------------------------------------------------------------------
RUNNING THE TESTS
You can run the tests in three ways. From the command line:
$ ./runtests.php -h
Using a web browser;
http://localhost/dokuwiki/_test/index.php
As remote tests run on a remote serveri (specified in tests.ini with REMOTE_TEST_URL) and driven locally from the command line using;
$ ./remotetests.php -h
--------------------------------------------------------------------------------
ADDING TESTS
The test cases are kept in the './cases' directory in a directory structure
mirroring that of the Dokuwiki's
Files with the extension .group.php are group tests (collections of
one or more seperate unit test files) - there should be one group
test per file in Dokuwiki's real directory.
Individual tests files have the extension .test.php
To add tests, create a .test.php file in the correct directory under ./cases
Probably best to use one of the existing scripts as a basis
The test will not be executable via one of the test runners (see above).
To add it to a group of tests, modify the corresponding .group.php file.
One exception to the naming convention - files named .webtest.php and
.webgroup.php are run using SimpleTest's browser simulator.
====== DokuWiki Test Suite ======
This is the test suit to automatically test various parts of DokuWiki.
===== Requirements =====
* PHPUnit 3.6.10+ http://www.phpunit.de/
* PHP 5.3+ http://www.php.net
===== PHPUnit Installation ======
via PEAR:
pear config-set auto_discover 1
pear upgrade
pear install pear.phpunit.de/PHPUnit
on Windows:
FIXME
===== Running all Tests =====
Just change to the ''_test'' directory and run phpunit:
cd _testing/
phpunit
PHPUnit will fail on some systems with a //headers already sent// error.
This is a known problem with PHPUnit, the error can be avoided by passing the
'--stderr' flag to phpunit:
phpunit --stderr
On windows you may have to enable OpenSSL support for https tests.
Some of them point to httpclient_http.tests.php on the failure.
To enable HTTPS support copy the ''libeay32.dll'' and ''ssleay32.dll'' to your ''windows\system32'' folder
and add the following line to your php.ini in the extension section:
<code ini>
extension=php_openssl.dll
</code>
===== Running selected Tests =====
You can run a single test file by providing it as an argument to phpunit:
phpunit --stderr tests/inc/common_cleanText.test.php
You can also use groups to exclude certain test from running. For example use
the following command to avoid long running test or tests accessing the
Internet.
phpunit --stderr --exclude-group slow,internet
===== Create new Tests =====
To create a test for DokuWiki, create a *.test.php file within the tests/
folder. Please respect the folder structure and naming convention. Inside the
file, implement a class, extending 'DokuWikiTest'. Every method, starting
with 'test' will be called as a test (e.g. 'testIfThisIsValid');
===== TODO for the test framework =====
* test cross platform compatibility: especially test windows
* update http://www.dokuwiki.org/devel:unittesting
* optional: add helper methods to TestRequest for easy form submission
* createForm(), ...
* check PHP Unit test_helpers https://github.com/sebastianbergmann/php-test-helpers
===== Migration Protocol =====
The following tests were not migrated:
* inc/indexer_idx_indexlengths (fs dependencies)
* inc/mail_send (integration test)
* inc/parser/parser_formatting
* inc/parser/xhtml_htmlphp (runkit)
* inc/parser/xhtml_links

107
_test/bootstrap.php Normal file
View File

@ -0,0 +1,107 @@
<?php
/**
* Test Suite bootstrapping for DokuWiki
*/
if(!defined('DOKU_UNITTEST')) define('DOKU_UNITTEST',dirname(__FILE__).'/');
require_once DOKU_UNITTEST.'core/phpQuery-onefile.php';
require_once DOKU_UNITTEST.'core/DokuWikiTest.php';
require_once DOKU_UNITTEST.'core/TestResponse.php';
require_once DOKU_UNITTEST.'core/TestRequest.php';
require_once DOKU_UNITTEST.'core/TestUtils.php';
// backward compatibility to old test suite
define('SIMPLE_TEST', true);
// basic behaviours
error_reporting(E_ALL);
set_time_limit(0);
ini_set('memory_limit','2048M');
// prepare temporary directories
define('DOKU_INC', dirname(dirname(__FILE__)).'/');
define('TMP_DIR', sys_get_temp_dir().'/dwtests-'.microtime(true));
define('DOKU_CONF', TMP_DIR.'/conf/');
define('DOKU_TMP_DATA', TMP_DIR.'/data/');
// default plugins
$default_plugins = array(
'acl',
'config',
'info',
'plugin',
'popularity',
'revert',
'safefnrecode',
'usermanager'
);
// default server variables
$default_server_vars = array(
'QUERY_STRING' => '?id=',
'REQUEST_METHOD' => 'GET',
'CONTENT_TYPE' => '',
'CONTENT_LENGTH' => '',
'SCRIPT_NAME' => '/doku.php',
'REQUEST_URI' => '/doku.php?id=',
'DOCUMENT_URI' => '/doku.php',
'DOCUMENT_ROOT' => DOKU_INC,
'SERVER_PROTOCOL' => 'HTTP/1.1',
'SERVER_SOFTWARE' => 'nginx/0.7.67',
'REMOTE_ADDR' => '87.142.120.6',
'REMOTE_PORT' => '21418',
'SERVER_ADDR' => '46.38.241.24',
'SERVER_PORT' => '443',
'SERVER_NAME' => 'wiki.example.com',
'REDIRECT_STATUS' => '200',
'SCRIPT_FILENAME' => DOKU_INC.'doku.php',
'HTTP_HOST' => 'wiki.example.com',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; OpenBSD amd64; rv:11.0) Gecko/20100101 Firefox/11.0',
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
'HTTP_CONNECTION' => 'keep-alive',
'HTTP_CACHE_CONTROL' => 'max-age=0',
'PHP_SELF' => '/doku.php',
'REQUEST_TIME' => time(),
);
// create temp directories
mkdir(TMP_DIR);
// cleanup dir after exit
if (getenv('PRESERVE_TMP') != 'true') {
register_shutdown_function(function() {
TestUtils::rdelete(TMP_DIR);
});
} else {
echo ">>>> Preserving temporary directory: ".TMP_DIR."\n";
}
// populate default dirs
TestUtils::rcopy(TMP_DIR, DOKU_INC.'/conf');
TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/conf');
TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data');
// disable all non-default plugins by default
$dh = dir(DOKU_INC.'lib/plugins/');
while (false !== ($entry = $dh->read())) {
if ($entry == '.' || $entry == '..') {
continue;
}
if (!is_dir(DOKU_INC.'lib/plugins/'.$entry)) {
continue;
}
if (!in_array($entry, $default_plugins)) {
// disable this plugin
TestUtils::fappend(DOKU_CONF.'plugins.local.php', "\$plugins['$entry'] = 0;\n");
}
}
$dh->close();
// load dw
require_once(DOKU_INC.'inc/init.php');

View File

@ -1,31 +0,0 @@
<?php
require_once DOKU_INC.'inc/DifferenceEngine.php';
class differenceengine_test extends UnitTestCase {
function test_white_between_words(){
// From FS#2161
global $lang;
$df = new Diff(explode("\n","example"),
explode("\n","example example2"));
$idf = new InlineDiffFormatter();
$tdf = new TableDiffFormatter();
$this->assertEqual($idf->format($df), '<tr><td colspan="4" class="diff-blockheader">@@ ' . $lang['line'] .
' -1 +1 @@&nbsp;<span class="diff-deletedline"><del>' . $lang['deleted'] .
'</del></span>&nbsp;<span class="diff-addedline">' . $lang['created'] .
'</span></td></tr>
<tr><td colspan="4">example&nbsp;<span class="diff-addedline">example2</span></td></tr>
');
$this->assertEqual($tdf->format($df),
'<tr><td class="diff-blockheader" colspan="2">' . $lang['line'] . ' 1:</td>
<td class="diff-blockheader" colspan="2">' . $lang['line'] . ' 1:</td>
</tr>
<tr><td>-</td><td class="diff-deletedline">example</td><td>+</td><td class="diff-addedline">example&nbsp;<strong>example2</strong></td></tr>
');
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,231 +0,0 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/auth.php';
class auth_acl_test extends UnitTestCase {
function teardown() {
global $conf;
global $AUTH_ACL;
unset($conf);
unset($AUTH_ACL);
}
function test_restricted(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
);
// anonymous user
$this->assertEqual(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user
$this->assertEqual(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
}
function test_restricted_ropage(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
'namespace:page @user 1',
);
// anonymous user
$this->assertEqual(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_READ);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user
$this->assertEqual(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
}
function test_aclexample(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 4',
'* bigboss 16',
'start @ALL 1',
'marketing:* @marketing 8',
'devel:* @ALL 0',
'devel:* @devel 8',
'devel:* bigboss 16',
'devel:funstuff bigboss 0',
'devel:* @marketing 1',
'devel:marketing @marketing 2',
);
$this->assertEqual(auth_aclcheck('page', '' ,array()) , AUTH_CREATE);
$this->assertEqual(auth_aclcheck('page', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEqual(auth_aclcheck('page', 'jill' ,array('marketing')) , AUTH_CREATE);
$this->assertEqual(auth_aclcheck('page', 'jane' ,array('devel')) , AUTH_CREATE);
$this->assertEqual(auth_aclcheck('start', '' ,array()) , AUTH_READ);
$this->assertEqual(auth_aclcheck('start', 'bigboss' ,array('foo')) , AUTH_READ);
$this->assertEqual(auth_aclcheck('start', 'jill' ,array('marketing')) , AUTH_READ);
$this->assertEqual(auth_aclcheck('start', 'jane' ,array('devel')) , AUTH_READ);
$this->assertEqual(auth_aclcheck('marketing:page', '' ,array()) , AUTH_CREATE);
$this->assertEqual(auth_aclcheck('marketing:page', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEqual(auth_aclcheck('marketing:page', 'jill' ,array('marketing')) , AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('marketing:page', 'jane' ,array('devel')) , AUTH_CREATE);
$this->assertEqual(auth_aclcheck('devel:page', '' ,array()) , AUTH_NONE);
$this->assertEqual(auth_aclcheck('devel:page', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEqual(auth_aclcheck('devel:page', 'jill' ,array('marketing')) , AUTH_READ);
$this->assertEqual(auth_aclcheck('devel:page', 'jane' ,array('devel')) , AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('devel:funstuff', '' ,array()) , AUTH_NONE);
$this->assertEqual(auth_aclcheck('devel:funstuff', 'bigboss' ,array('foo')) , AUTH_NONE);
$this->assertEqual(auth_aclcheck('devel:funstuff', 'jill' ,array('marketing')) , AUTH_READ);
$this->assertEqual(auth_aclcheck('devel:funstuff', 'jane' ,array('devel')) , AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('devel:marketing', '' ,array()) , AUTH_NONE);
$this->assertEqual(auth_aclcheck('devel:marketing', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEqual(auth_aclcheck('devel:marketing', 'jill' ,array('marketing')) , AUTH_EDIT);
$this->assertEqual(auth_aclcheck('devel:marketing', 'jane' ,array('devel')) , AUTH_UPLOAD);
}
function test_multiadmin_restricted(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john,@admin,doe,@roots';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
);
// anonymous user
$this->assertEqual(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user john
$this->assertEqual(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
// super user doe
$this->assertEqual(auth_aclcheck('page', 'doe',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','doe',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'doe',array('foo')), AUTH_ADMIN);
// user with matching admin group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','admin')), AUTH_ADMIN);
// user with matching another admin group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','roots')), AUTH_ADMIN);
}
function test_multiadmin_restricted_ropage(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john,@admin,doe,@roots';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
'namespace:page @user 1',
);
// anonymous user
$this->assertEqual(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_READ);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user john
$this->assertEqual(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
// super user doe
$this->assertEqual(auth_aclcheck('page', 'doe',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','doe',array('foo')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'doe',array('foo')), AUTH_ADMIN);
// user with matching admin group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','admin')), AUTH_ADMIN);
// user with matching another admin group
$this->assertEqual(auth_aclcheck('page', 'jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:page','jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEqual(auth_aclcheck('namespace:*', 'jill',array('foo','roots')), AUTH_ADMIN);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,132 +0,0 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/auth.php';
require_once DOKU_INC.'inc/auth/basic.class.php';
class auth_admin_test_AuthInSensitive extends auth_basic {
function isCaseSensitive(){
return false;
}
}
class auth_admin_test extends UnitTestCase {
private $oldauth;
function setup() {
global $auth;
$this->oldauth = $auth;
parent::setup();
}
function setSensitive() {
global $auth;
$auth = new auth_basic;
}
function setInSensitive() {
global $auth;
$auth = new auth_admin_test_AuthInSensitive;
}
function teardown() {
global $auth;
global $conf;
global $AUTH_ACL;
unset($conf);
unset($AUTH_ACL);
$auth = $this->oldauth;
parent::teardown();
}
function test_ismanager_insensitive(){
$this->setInSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte';
$conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny';
// anonymous user
$this->assertEqual(auth_ismanager('jill', null,false), false);
// admin or manager users
$this->assertEqual(auth_ismanager('john', null,false), true);
$this->assertEqual(auth_ismanager('doe', null,false), true);
$this->assertEqual(auth_ismanager('dörte', null,false), true);
$this->assertEqual(auth_ismanager('dänny', null,false), true);
// admin or manager groups
$this->assertEqual(auth_ismanager('jill', array('admin'),false), true);
$this->assertEqual(auth_ismanager('jill', array('managers'),false), true);
$this->assertEqual(auth_ismanager('jill', array('mötly görls'),false), true);
$this->assertEqual(auth_ismanager('jill', array('mötly böys'),false), true);
}
function test_isadmin_insensitive(){
$this->setInSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,doe,@roots';
// anonymous user
$this->assertEqual(auth_ismanager('jill', null,true), false);
// admin user
$this->assertEqual(auth_ismanager('john', null,true), true);
$this->assertEqual(auth_ismanager('doe', null,true), true);
// admin groups
$this->assertEqual(auth_ismanager('jill', array('admin'),true), true);
$this->assertEqual(auth_ismanager('jill', array('roots'),true), true);
$this->assertEqual(auth_ismanager('john', array('admin'),true), true);
$this->assertEqual(auth_ismanager('doe', array('admin'),true), true);
}
function test_ismanager_sensitive(){
$this->setSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte';
$conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny';
// anonymous user
$this->assertEqual(auth_ismanager('jill', null,false), false);
// admin or manager users
$this->assertEqual(auth_ismanager('john', null,false), true);
$this->assertEqual(auth_ismanager('doe', null,false), true);
$this->assertEqual(auth_ismanager('dörte', null,false), false);
$this->assertEqual(auth_ismanager('dänny', null,false), false);
// admin or manager groups
$this->assertEqual(auth_ismanager('jill', array('admin'),false), true);
$this->assertEqual(auth_ismanager('jill', array('managers'),false), true);
$this->assertEqual(auth_ismanager('jill', array('mötly görls'),false), false);
$this->assertEqual(auth_ismanager('jill', array('mötly böys'),false), false);
}
function test_isadmin_sensitive(){
$this->setSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,doe,@roots';
// anonymous user
$this->assertEqual(auth_ismanager('jill', null,true), false);
// admin user
$this->assertEqual(auth_ismanager('john', null,true), true);
$this->assertEqual(auth_ismanager('Doe', null,true), false);
// admin groups
$this->assertEqual(auth_ismanager('jill', array('admin'),true), true);
$this->assertEqual(auth_ismanager('jill', array('roots'),true), true);
$this->assertEqual(auth_ismanager('john', array('admin'),true), true);
$this->assertEqual(auth_ismanager('doe', array('admin'),true), true);
$this->assertEqual(auth_ismanager('Doe', array('admin'),true), true);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,34 +0,0 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/common.php';
class common_clientIP_test extends UnitTestCase {
function test_unix(){
$unix = 'one
two
three';
$this->assertEqual($unix,cleanText($unix));
}
function test_win(){
$unix = 'one
two
three';
$win = 'one
two
three';
$this->assertEqual(bin2hex($unix),'6f6e650a2020202020202020202020202020202074776f0a0a202020202020202020202020202020207468726565');
$this->assertEqual(bin2hex($win),'6f6e650d0a2020202020202020202020202020202074776f0d0a0d0a202020202020202020202020202020207468726565');
$this->assertNotEqual($unix,$win);
$this->assertEqual($unix,cleanText($win));
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,104 +0,0 @@
<?php
require_once DOKU_INC.'inc/html.php';
if (!extension_loaded('runkit')) {
SimpleTestOptions::ignore('html_hilight_test');
trigger_error('Skipping html_hilight_test - http://www.php.net/runkit required');
}
function html_hilight_test_unslash($string,$char="'"){
$str= str_replace('\\'.$char,$char,$string);
return $str;
}
class html_hilight_test extends UnitTestCase{
function setup() {
if ( function_exists('unslash') ) {
runkit_function_rename('unslash','html_hilight_test_unslash_real');
}
runkit_function_rename('html_hilight_test_unslash','unslash');
}
function teardown() {
runkit_function_rename('unslash','html_hilight_test_unslash');
if ( function_exists('html_hilight_test_unslash_real') ) {
runkit_function_rename('html_hilight_test_unslash_real','unslash');
}
}
function testHighlightOneWord() {
$html = 'Foo bar Foo';
$this->assertPattern(
'/Foo <span.*>bar<\/span> Foo/',
html_hilight($html,'bar')
);
}
function testHighlightTwoWords() {
$html = 'Foo bar Foo php Foo';
$this->assertPattern(
'/Foo <span.*>bar<\/span> Foo <span.*>php<\/span> Foo/',
html_hilight($html,array('bar','php'))
);
}
function testHighlightTwoWordsHtml() {
$html = 'Foo <b>bar</b> <i>Foo</i> php Foo';
$this->assertPattern(
'/Foo <b><span.*>bar<\/span><\/b> <i>Foo<\/i> <span.*>php<\/span> Foo/',
html_hilight($html,array('bar','php'))
);
}
function testNoHighlight() {
$html = 'Foo bar Foo';
$this->assertPattern(
'/Foo bar Foo/',
html_hilight($html,'php')
);
}
function testHighlightPHP() {
$html = 'Foo $_GET[\'bar\'] Foo';
$this->assertEqual(
'Foo <span class="search_hit">$_GET[\'bar\']</span> Foo',
html_hilight($html,'$_GET[\'bar\']')
);
}
function testMatchAttribute() {
$html = 'Foo <b class="x">bar</b> Foo';
$this->assertPattern(
'/Foo <b class="x">bar<\/b> Foo/',
html_hilight($html,'class="x"')
);
}
function testMatchAttributeWord() {
$html = 'Foo <b class="x">bar</b> Foo';
$this->assertEqual(
'Foo <b class="x">bar</b> Foo',
html_hilight($html,'class="x">bar')
);
}
function testRegexInjection() {
$html = 'Foo bar Foo';
$this->assertPattern(
'/Foo bar Foo/',
html_hilight($html,'*')
);
}
function testRegexInjectionSlash() {
$html = 'Foo bar Foo';
$this->assertPattern(
'/Foo bar Foo/',
html_hilight($html,'x/')
);
}
}

View File

@ -1,60 +0,0 @@
<?php
require_once DOKU_INC.'inc/indexer.php';
class indexer_idx_indexlengths_test extends UnitTestCase {
/**
* Test the function with an array of one value
*/
function test_oneWord(){
global $conf;
$filter[8] = array('dokuwiki');
// one word should return the index
$ref[] = 8;
sort($ref);
$result = idx_indexLengths(&$filter);
sort($result);
$this->assertIdentical($result, $ref);
}
/**
* Test the function with an array of values
*/
function test_moreWords() {
global $conf;
$filter = array( 4 => array('test'), 8 => array('dokuwiki'), 7 => array('powered'));
// more words should return the indexes
$ref = array(4, 7, 8);
sort($ref);
$result = idx_indexLengths(&$filter);
sort($result);
$this->assertIdentical($result, $ref);
}
/**
* Test a minimal value in case of wildcard search
*/
function test_minValue() {
global $conf;
$filter = 5;
// construction of the list of the index to compare
$dir = @opendir($conf['indexdir']);
$ref = array();
while (($f = readdir($dir)) !== false) {
if (substr($f,0,1) == 'i' && substr($f,-4) == '.idx'){
$i = substr($f,1,-4);
if (is_numeric($i) && $i >= $filter)
$ref[] = (int)$i;
}
}
closedir($dir);
sort($ref);
$result = idx_indexLengths(&$filter);
sort($result);
$this->assertIdentical($result, $ref);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,49 +0,0 @@
<?php
require_once DOKU_INC.'inc/mail.php';
class mail_send extends UnitTestCase {
/**
* These tests will try to send a bunch of mails to dokuwiki1@spam.la and
* dokuwiki2@spam.la - check the correctness at http://spam.la
*/
function test1(){
$addr = array(
'dokuwiki1@spam.la',
'dokuwiki2@spam.la',
'Test User <dokuwiki1@spam.la>',
'dokuwiki1@spam.la, dokuwiki2@spam.la',
'Test User 1 <dokuwiki1@spam.la>, Test User 2 <dokuwiki2@spam.la>'
);
$run = 0;
foreach($addr as $ad){
$run++;
$data = array(
'to' => $ad,
'subject' => 'mailtest 1-'.$run,
'body' => "Mailtest run 1-$run using to: $ad from:",
);
$this->assertTrue((bool) _mail_send_action($data));
$data = array(
'to' => $ad,
'from' => 'dokuwiki1@spam.la',
'subject' => 'mailtest 2-'.$run,
'body' => "Mailtest run 2-$run using to: $ad from: dokuwiki1@spam.la",
);
$this->assertTrue((bool) _mail_send_action($data));
$data = array(
'to' => $ad,
'from' => '"Foo Bar" <dokuwiki@spam.la>',
'subject' => 'mailtest 3-'.$run,
'body' => "Mailtest run 3-$run using to: $ad from: \"Foo Bar\" <dokuwiki@spam.la>",
);
$this->assertTrue((bool) _mail_send_action($data));
}
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,21 +0,0 @@
<?php
/**
* @version $Id: lexer.group.php,v 1.2 2005/03/25 21:00:22 harryf Exp $
* @package JPSpan
* @subpackage Tests
*/
/**
* @package JPSpan
* @subpackage Tests
*/
class LexerGroupTest extends GroupTest {
function LexerGroupTest() {
$this->GroupTest('LexerGroupTest');
$this->addTestFile(dirname(__FILE__).'/lexer.test.php');
}
}
?>

View File

@ -1,625 +0,0 @@
<?php
/**
* @version $Id: lexer.test.php,v 1.2 2005/03/25 21:00:22 harryf Exp $
* @package Doku
* @subpackage Tests
*/
/**
* Includes
*/
require_once DOKU_INC . 'inc/parser/lexer.php';
/**
* @package Doku
* @subpackage Tests
*/
class TestOfLexerParallelRegex extends UnitTestCase {
function TestOfLexerParallelRegex() {
$this->UnitTestCase();
}
function testNoPatterns() {
$regex = new Doku_LexerParallelRegex(false);
$this->assertFalse($regex->match("Hello", $match));
$this->assertEqual($match, "");
}
function testNoSubject() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern(".*");
$this->assertTrue($regex->match("", $match));
$this->assertEqual($match, "");
}
function testMatchAll() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern(".*");
$this->assertTrue($regex->match("Hello", $match));
$this->assertEqual($match, "Hello");
}
function testCaseSensitive() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("abc");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEqual($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEqual($match, "abc");
}
function testCaseInsensitive() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern("abc");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEqual($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEqual($match, "ABC");
}
function testMatchMultiple() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("abc");
$regex->addPattern("ABC");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEqual($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEqual($match, "ABC");
$this->assertFalse($regex->match("Hello", $match));
}
function testPatternLabels() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern("abc", "letter");
$regex->addPattern("123", "number");
$this->assertIdentical($regex->match("abcdef", $match), "letter");
$this->assertEqual($match, "abc");
$this->assertIdentical($regex->match("0123456789", $match), "number");
$this->assertEqual($match, "123");
}
function testMatchMultipleWithLookaheadNot() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("abc");
$regex->addPattern("ABC");
$regex->addPattern("a(?!\n).{1}");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEqual($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEqual($match, "ABC");
$this->assertTrue($regex->match("a\nab", $match));
$this->assertEqual($match, "ab");
$this->assertFalse($regex->match("Hello", $match));
}
function testMatchSetOptionCaseless() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("a(?i)b(?i)c");
$this->assertTrue($regex->match("aBc", $match));
$this->assertEqual($match, "aBc");
}
function testMatchSetOptionUngreedy() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("(?U)\w+");
$this->assertTrue($regex->match("aaaaaa", $match));
$this->assertEqual($match, "a");
}
function testMatchLookaheadEqual() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("\w(?=c)");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEqual($match, "y");
}
function testMatchLookaheadNot() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("\w(?!b|c)");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEqual($match, "b");
}
function testMatchLookbehindEqual() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("(?<=c)\w");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEqual($match, "z");
}
function testMatchLookbehindNot() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("(?<!\A|x|b)\w");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEqual($match, "c");
}
}
class TestOfLexerStateStack extends UnitTestCase {
function TestOfLexerStateStack() {
$this->UnitTestCase();
}
function testStartState() {
$stack = new Doku_LexerStateStack("one");
$this->assertEqual($stack->getCurrent(), "one");
}
function testExhaustion() {
$stack = new Doku_LexerStateStack("one");
$this->assertFalse($stack->leave());
}
function testStateMoves() {
$stack = new Doku_LexerStateStack("one");
$stack->enter("two");
$this->assertEqual($stack->getCurrent(), "two");
$stack->enter("three");
$this->assertEqual($stack->getCurrent(), "three");
$this->assertTrue($stack->leave());
$this->assertEqual($stack->getCurrent(), "two");
$stack->enter("third");
$this->assertEqual($stack->getCurrent(), "third");
$this->assertTrue($stack->leave());
$this->assertTrue($stack->leave());
$this->assertEqual($stack->getCurrent(), "one");
}
}
class TestParser {
function TestParser() {
}
function accept() {
}
function a() {
}
function b() {
}
}
Mock::generate('TestParser');
class TestOfLexer extends UnitTestCase {
function TestOfLexer() {
$this->UnitTestCase();
}
function testNoPatterns() {
$handler = new MockTestParser($this);
$handler->expectNever("accept");
$handler->setReturnValue("accept", true);
$lexer = new Doku_Lexer($handler);
$this->assertFalse($lexer->parse("abcdef"));
}
function testEmptyPage() {
$handler = new MockTestParser($this);
$handler->expectNever("accept");
$handler->setReturnValue("accept", true);
$handler->expectNever("accept");
$handler->setReturnValue("accept", true);
$lexer = new Doku_Lexer($handler);
$lexer->addPattern("a+");
$this->assertTrue($lexer->parse(""));
}
function testSinglePattern() {
$handler = new MockTestParser($this);
$handler->expectArgumentsAt(0, "accept", array("aaa", DOKU_LEXER_MATCHED, 0));
$handler->expectArgumentsAt(1, "accept", array("x", DOKU_LEXER_UNMATCHED, 3));
$handler->expectArgumentsAt(2, "accept", array("a", DOKU_LEXER_MATCHED, 4));
$handler->expectArgumentsAt(3, "accept", array("yyy", DOKU_LEXER_UNMATCHED, 5));
$handler->expectArgumentsAt(4, "accept", array("a", DOKU_LEXER_MATCHED, 8));
$handler->expectArgumentsAt(5, "accept", array("x", DOKU_LEXER_UNMATCHED, 9));
$handler->expectArgumentsAt(6, "accept", array("aaa", DOKU_LEXER_MATCHED, 10));
$handler->expectArgumentsAt(7, "accept", array("z", DOKU_LEXER_UNMATCHED, 13));
$handler->expectCallCount("accept", 8);
$handler->setReturnValue("accept", true);
$lexer = new Doku_Lexer($handler);
$lexer->addPattern("a+");
$this->assertTrue($lexer->parse("aaaxayyyaxaaaz"));
$handler->tally();
}
function testMultiplePattern() {
$handler = new MockTestParser($this);
$target = array("a", "b", "a", "bb", "x", "b", "a", "xxxxxx", "a", "x");
$positions = array(0,1,2,3,5,6,7,8,14,15);
for ($i = 0; $i < count($target); $i++) {
$handler->expectArgumentsAt($i, "accept", array($target[$i], '*', $positions[$i]));
}
$handler->expectCallCount("accept", count($target));
$handler->setReturnValue("accept", true);
$lexer = new Doku_Lexer($handler);
$lexer->addPattern("a+");
$lexer->addPattern("b+");
$this->assertTrue($lexer->parse("ababbxbaxxxxxxax"));
$handler->tally();
}
}
class TestOfLexerModes extends UnitTestCase {
function TestOfLexerModes() {
$this->UnitTestCase();
}
function testIsolatedPattern() {
$handler = new MockTestParser($this);
$handler->expectArgumentsAt(0, "a", array("a", DOKU_LEXER_MATCHED,0));
$handler->expectArgumentsAt(1, "a", array("b", DOKU_LEXER_UNMATCHED,1));
$handler->expectArgumentsAt(2, "a", array("aa", DOKU_LEXER_MATCHED,2));
$handler->expectArgumentsAt(3, "a", array("bxb", DOKU_LEXER_UNMATCHED,4));
$handler->expectArgumentsAt(4, "a", array("aaa", DOKU_LEXER_MATCHED,7));
$handler->expectArgumentsAt(5, "a", array("x", DOKU_LEXER_UNMATCHED,10));
$handler->expectArgumentsAt(6, "a", array("aaaa", DOKU_LEXER_MATCHED,11));
$handler->expectArgumentsAt(7, "a", array("x", DOKU_LEXER_UNMATCHED,15));
$handler->expectCallCount("a", 8);
$handler->setReturnValue("a", true);
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addPattern("b+", "b");
$this->assertTrue($lexer->parse("abaabxbaaaxaaaax"));
$handler->tally();
}
function testModeChange() {
$handler = new MockTestParser($this);
$handler->expectArgumentsAt(0, "a", array("a", DOKU_LEXER_MATCHED,0));
$handler->expectArgumentsAt(1, "a", array("b", DOKU_LEXER_UNMATCHED,1));
$handler->expectArgumentsAt(2, "a", array("aa", DOKU_LEXER_MATCHED,2));
$handler->expectArgumentsAt(3, "a", array("b", DOKU_LEXER_UNMATCHED,4));
$handler->expectArgumentsAt(4, "a", array("aaa", DOKU_LEXER_MATCHED,5));
$handler->expectArgumentsAt(0, "b", array(":", DOKU_LEXER_ENTER,8));
$handler->expectArgumentsAt(1, "b", array("a", DOKU_LEXER_UNMATCHED,9));
$handler->expectArgumentsAt(2, "b", array("b", DOKU_LEXER_MATCHED, 10));
$handler->expectArgumentsAt(3, "b", array("a", DOKU_LEXER_UNMATCHED,11));
$handler->expectArgumentsAt(4, "b", array("bb", DOKU_LEXER_MATCHED,12));
$handler->expectArgumentsAt(5, "b", array("a", DOKU_LEXER_UNMATCHED,14));
$handler->expectArgumentsAt(6, "b", array("bbb", DOKU_LEXER_MATCHED,15));
$handler->expectArgumentsAt(7, "b", array("a", DOKU_LEXER_UNMATCHED,18));
$handler->expectCallCount("a", 5);
$handler->expectCallCount("b", 8);
$handler->setReturnValue("a", true);
$handler->setReturnValue("b", true);
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addEntryPattern(":", "a", "b");
$lexer->addPattern("b+", "b");
$this->assertTrue($lexer->parse("abaabaaa:ababbabbba"));
$handler->tally();
}
function testNesting() {
$handler = new MockTestParser($this);
$handler->setReturnValue("a", true);
$handler->setReturnValue("b", true);
$handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0));
$handler->expectArgumentsAt(1, "a", array("b", DOKU_LEXER_UNMATCHED,2));
$handler->expectArgumentsAt(2, "a", array("aa", DOKU_LEXER_MATCHED,3));
$handler->expectArgumentsAt(3, "a", array("b", DOKU_LEXER_UNMATCHED,5));
$handler->expectArgumentsAt(0, "b", array("(", DOKU_LEXER_ENTER,6));
$handler->expectArgumentsAt(1, "b", array("bb", DOKU_LEXER_MATCHED,7));
$handler->expectArgumentsAt(2, "b", array("a", DOKU_LEXER_UNMATCHED,9));
$handler->expectArgumentsAt(3, "b", array("bb", DOKU_LEXER_MATCHED,10));
$handler->expectArgumentsAt(4, "b", array(")", DOKU_LEXER_EXIT,12));
$handler->expectArgumentsAt(4, "a", array("aa", DOKU_LEXER_MATCHED,13));
$handler->expectArgumentsAt(5, "a", array("b", DOKU_LEXER_UNMATCHED,15));
$handler->expectCallCount("a", 6);
$handler->expectCallCount("b", 5);
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addEntryPattern("(", "a", "b");
$lexer->addPattern("b+", "b");
$lexer->addExitPattern(")", "b");
$this->assertTrue($lexer->parse("aabaab(bbabb)aab"));
$handler->tally();
}
function testSingular() {
$handler = new MockTestParser($this);
$handler->setReturnValue("a", true);
$handler->setReturnValue("b", true);
$handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0));
$handler->expectArgumentsAt(1, "a", array("aa", DOKU_LEXER_MATCHED,3));
$handler->expectArgumentsAt(2, "a", array("xx", DOKU_LEXER_UNMATCHED,5));
$handler->expectArgumentsAt(3, "a", array("xx", DOKU_LEXER_UNMATCHED,10));
$handler->expectArgumentsAt(0, "b", array("b", DOKU_LEXER_SPECIAL,2));
$handler->expectArgumentsAt(1, "b", array("bbb", DOKU_LEXER_SPECIAL,7));
$handler->expectCallCount("a", 4);
$handler->expectCallCount("b", 2);
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addSpecialPattern("b+", "a", "b");
$this->assertTrue($lexer->parse("aabaaxxbbbxx"));
$handler->tally();
}
function testUnwindTooFar() {
$handler = new MockTestParser($this);
$handler->setReturnValue("a", true);
$handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0));
$handler->expectArgumentsAt(1, "a", array(")", DOKU_LEXER_EXIT,2));
$handler->expectCallCount("a", 2);
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addExitPattern(")", "a");
$this->assertFalse($lexer->parse("aa)aa"));
$handler->tally();
}
}
class TestOfLexerHandlers extends UnitTestCase {
function TestOfLexerHandlers() {
$this->UnitTestCase();
}
function testModeMapping() {
$handler = new MockTestParser($this);
$handler->setReturnValue("a", true);
$handler->expectArgumentsAt(0, "a", array("aa", DOKU_LEXER_MATCHED,0));
$handler->expectArgumentsAt(1, "a", array("(", DOKU_LEXER_ENTER,2));
$handler->expectArgumentsAt(2, "a", array("bb", DOKU_LEXER_MATCHED,3));
$handler->expectArgumentsAt(3, "a", array("a", DOKU_LEXER_UNMATCHED,5));
$handler->expectArgumentsAt(4, "a", array("bb", DOKU_LEXER_MATCHED,6));
$handler->expectArgumentsAt(5, "a", array(")", DOKU_LEXER_EXIT,8));
$handler->expectArgumentsAt(6, "a", array("b", DOKU_LEXER_UNMATCHED,9));
$handler->expectCallCount("a", 7);
$lexer = new Doku_Lexer($handler, "mode_a");
$lexer->addPattern("a+", "mode_a");
$lexer->addEntryPattern("(", "mode_a", "mode_b");
$lexer->addPattern("b+", "mode_b");
$lexer->addExitPattern(")", "mode_b");
$lexer->mapHandler("mode_a", "a");
$lexer->mapHandler("mode_b", "a");
$this->assertTrue($lexer->parse("aa(bbabb)b"));
$handler->tally();
}
}
class TestParserByteIndex {
function TestParserByteIndex() {}
function ignore() {}
function caught() {}
}
Mock::generate('TestParserByteIndex');
class TestOfLexerByteIndices extends UnitTestCase {
function TestOfLexerByteIndices() {
$this->UnitTestCase();
}
function testIndex() {
$doc = "aaa<file>bcd</file>eee";
$handler = new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
"caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
"caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
"caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
"caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
$handler->expectCallCount("caught", 5);
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern("<file>", "ignore", "caught");
$lexer->addExitPattern("</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookaheadEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
"caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
"caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
"caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
"caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
$handler->expectCallCount("caught", 5);
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('<file>(?=.*</file>)', "ignore", "caught");
$lexer->addExitPattern("</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookaheadNotEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
"caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
"caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
"caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
"caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
$handler->expectCallCount("caught", 5);
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('<file>(?!foo)', "ignore", "caught");
$lexer->addExitPattern("</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookbehindEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
"caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
"caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
"caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
"caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
$handler->expectCallCount("caught", 5);
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('<file>', "ignore", "caught");
$lexer->addExitPattern("(?<=d)</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookbehindNotEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))
);
$handler->expectArgumentsAt(
1,
"caught",
array("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))
);
$handler->expectArgumentsAt(
2,
"caught",
array("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))
);
$handler->expectArgumentsAt(
3,
"caught",
array("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))
);
$handler->expectArgumentsAt(
4,
"caught",
array("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))
);
$handler->expectCallCount("caught", 5);
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('<file>', "ignore", "caught");
$lexer->addExitPattern("(?<!c)</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
/**
* This test is primarily to ensure the correct match is chosen
* when there are non-captured elements in the pattern.
*/
function testIndexSelectCorrectMatch() {
$doc = "ALL FOOLS ARE FOO";
$pattern = '\bFOO\b';
$handler = new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$matches = array();
preg_match('/'.$pattern.'/',$doc,$matches,PREG_OFFSET_CAPTURE);
$handler->expectArgumentsAt(
0,
"caught",
array("FOO", DOKU_LEXER_SPECIAL, $matches[0][1])
);
$handler->expectCallCount("caught", 1);
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addSpecialPattern($pattern,'ignore','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
}
?>

View File

@ -1,34 +0,0 @@
<?php
/**
* @version $Id: parser.group.php,v 1.3 2005/03/30 13:42:10 harryf Exp $
* @package Dokuwiki
* @subpackage Tests
*/
/**
* @package Dokuwiki
* @subpackage Tests
*/
class ParserGroupTest extends GroupTest {
function ParserGroupTest() {
$dir = dirname(__FILE__).'/';
$this->GroupTest('ParserGroupTest');
$this->addTestFile($dir . 'parser_eol.test.php');
$this->addTestFile($dir . 'parser_footnote.test.php');
$this->addTestFile($dir .'parser_formatting.test.php');
$this->addTestFile($dir .'parser_headers.test.php');
$this->addTestFile($dir .'parser_i18n.test.php');
$this->addTestFile($dir .'parser_links.test.php');
$this->addTestFile($dir .'parser_lists.test.php');
$this->addTestFile($dir .'parser_preformatted.test.php');
$this->addTestFile($dir .'parser_quote.test.php');
$this->addTestFile($dir .'parser_replacements.test.php');
$this->addTestFile($dir .'parser_table.test.php');
# $this->addTestFile($dir .'parser_tocsections.test.php');
$this->addTestFile($dir .'parser_unformatted.test.php');
}
}
?>

View File

@ -1,434 +0,0 @@
<?php
require_once 'parser.inc.php';
class TestOfDoku_Parser_Formatting extends TestOfDoku_Parser {
function TestOfDoku_Parser_Formatting() {
$this->UnitTestCase('TestOfDoku_Parser_Formatting');
}
function testStrong() {
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse('abc **bar** def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('strong_open',array()),
array('cdata',array('bar')),
array('strong_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotStrong() {
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse('abc **bar def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc **bar def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEm() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc //bar// def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('emphasis_open',array()),
array('cdata',array('bar')),
array('emphasis_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmColon() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc //Тест: // def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('emphasis_open',array()),
array('cdata',array('Тест: ')),
array('emphasis_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmSingleChar() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc //b// def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('emphasis_open',array()),
array('cdata',array('b')),
array('emphasis_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmWithUnknownSchema() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc //foo:// bar// def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('emphasis_open',array()),
array('cdata',array('foo:')),
array('emphasis_close',array()),
array('cdata',array(' bar// def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmWithKnownSchema() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
$this->P->parse('abc //foo http://www.google.com bar// def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('emphasis_open',array()),
array('cdata',array('foo ')),
array('externallink',array('http://www.google.com', NULL)),
array('cdata',array(' bar')),
array('emphasis_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotEm() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc //bar def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc //bar def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotEmSchemaAtOpen() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc foo://bar// def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc foo:')),
array('emphasis_open',array()),
array('cdata',array('bar')),
array('emphasis_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotEmSchemaAtClose() {
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc //http:// def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc //http:// def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmWithMultiOccurence() {
// Case from #763
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('//text:// Blablabla Blablabla
//text:// another Blablabla Blablabla');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n")),
array('emphasis_open',array()),
array('cdata',array('text:')),
array('emphasis_close',array()),
array('cdata',array(" Blablabla Blablabla\n\n")),
array('emphasis_open',array()),
array('cdata',array('text:')),
array('emphasis_close',array()),
array('cdata',array(" another Blablabla Blablabla")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmWithUnicode() {
// Case from #1468
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('//Тест://');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n")),
array('emphasis_open',array()),
array('cdata',array('Тест:')),
array('emphasis_close',array()),
array('cdata', array('')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNoEmWithInvalidURL() {
// Case from #1629
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('http://<CertificateServerName>/certsrv/certcarc.asp');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array('http://<CertificateServerName>/certsrv/certcarc.asp')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNoEmWithUnknownURL() {
// Case from #1640
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('svn://example.com/foo/bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array('svn://example.com/foo/bar')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnderline() {
$this->P->addMode('underline',new Doku_Parser_Mode_Formatting('underline'));
$this->P->parse('abc __bar__ def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('underline_open',array()),
array('cdata',array('bar')),
array('underline_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotUnderline() {
$this->P->addMode('underline',new Doku_Parser_Mode_Formatting('underline'));
$this->P->parse('abc __bar def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc __bar def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMonospace() {
$this->P->addMode('monospace',new Doku_Parser_Mode_Formatting('monospace'));
$this->P->parse("abc ''bar'' def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('monospace_open',array()),
array('cdata',array('bar')),
array('monospace_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotMonospace() {
$this->P->addMode('monospace',new Doku_Parser_Mode_Formatting('monospace'));
$this->P->parse("abc ''bar def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc ''bar def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSubscript() {
$this->P->addMode('subscript',new Doku_Parser_Mode_Formatting('subscript'));
$this->P->parse('abc <sub>bar</sub> def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('subscript_open',array()),
array('cdata',array('bar')),
array('subscript_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotSubscript() {
$this->P->addMode('subscript',new Doku_Parser_Mode_Formatting('subscript'));
$this->P->parse('abc <sub>bar def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc <sub>bar def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSuperscript() {
$this->P->addMode('superscript',new Doku_Parser_Mode_Formatting('superscript'));
$this->P->parse("abc <sup>bar</sup> def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('superscript_open',array()),
array('cdata',array('bar')),
array('superscript_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotSuperscript() {
$this->P->addMode('superscript',new Doku_Parser_Mode_Formatting('superscript'));
$this->P->parse("abc <sup>bar def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc <sup>bar def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDeleted() {
$this->P->addMode('deleted',new Doku_Parser_Mode_Formatting('deleted'));
$this->P->parse('abc <del>bar</del> def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('deleted_open',array()),
array('cdata',array('bar')),
array('deleted_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotDeleted() {
$this->P->addMode('deleted',new Doku_Parser_Mode_Formatting('deleted'));
$this->P->parse('abc <del>bar def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc <del>bar def")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNestedFormatting() {
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->addMode('emphasis',new Doku_Parser_Mode_Formatting('emphasis'));
$this->P->parse('abc **a//b//c** def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('strong_open',array()),
array('cdata',array('a')),
array('emphasis_open',array()),
array('cdata',array('b')),
array('emphasis_close',array()),
array('cdata',array('c')),
array('strong_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testIllegalNestedFormatting() {
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse('abc **a**b**c** def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('strong_open',array()),
array('cdata',array('a')),
array('strong_close',array()),
array('cdata',array('b')),
array('strong_open',array()),
array('cdata',array('c')),
array('strong_close',array()),
array('cdata',array(' def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -1,203 +0,0 @@
<?php
if (!defined('DOKU_BASE')) define('DOKU_BASE','./');
require_once 'parser.inc.php';
require_once DOKU_INC.'inc/parser/xhtml.php';
require_once DOKU_INC.'inc/geshi.php';
if (!extension_loaded('runkit')) {
SimpleTestOptions::ignore('xhtml_htmlphp_test');
trigger_error('Skipping xhtml_htmlphp_test - http://www.php.net/runkit required');
}
function xhtml_htmlphp_test_io_makefiledir() {
return;
}
function xhtml_htmlphp_test_io_savefile() {
return true;
}
class Doku_Renderer_tester extends Doku_Renderer_xhtml {
/*
changes to these tests remove the need to redefine any xhtml methods
class left for future use
*/
}
/*
* test case for parser/xhtml.php _headertolink method
* definition: function _headertolink($title,$create)
*/
class xhtml_htmlphp_test extends TestOfDoku_Parser {
var $purge;
var $cachedir;
function setup() {
global $conf;
// set purge to avoid trying to retrieve from cache
$this->purge = isset($_REQUEST['purge']) ? $_REQUEST['purge'] : null;
$_REQUEST['purge'] = 1;
if (!isset($conf['cachedir'])) {
$conf['cachedir'] = '';
$this->cachedir = false;
} else {
$this->cachedir = true;
}
if (function_exists('io_makefiledir')) {
runkit_function_rename('io_makefiledir', 'io_makefiledir_real');
}
runkit_function_rename('xhtml_htmlphp_test_io_makefiledir','io_makefiledir');
if (function_exists('io_savefile')) {
runkit_function_rename('io_savefile', 'io_savefile_real');
}
runkit_function_rename('xhtml_htmlphp_test_io_savefile','io_savefile');
runkit_method_rename('GeSHi','parse_code','parse_code_real');
runkit_method_add('GeSHi','parse_code','', '{ return hsc($this->source); }');
parent::setup();
}
function teardown() {
global $conf;
// restore purge
if (is_null($this->purge)) unset($_REQUEST['purge']);
else $_REQUEST['purge'] = $this->purge;
// restore $conf['cachedir'] if necessary
if (!$this->cachedir) unset($conf['cachedir']);
// restore io_functions
runkit_function_rename('io_makefiledir','xhtml_htmlphp_test_io_makefiledir');
if (function_exists('io_makefiledir_real')) {
runkit_function_rename('io_makefiledir_real', 'io_makefiledir');
}
runkit_function_rename('io_savefile','xhtml_htmlphp_test_io_savefile');
if (function_exists('io_savefile_real')) {
runkit_function_rename('io_savefile_real', 'io_savefile');
}
// restore GeSHi::parse_code
runkit_method_remove('GeSHi','parse_code');
runkit_method_rename('GeSHi','parse_code_real','parse_code');
parent::setup();
}
function _run_parser($modes,$data) {
foreach ($modes as $mode => $name) {
$class = 'Doku_Parser_Mode_'.$name;
$this->P->addMode($mode,new $class());
}
$R = new Doku_Renderer_tester();
$this->P->parse($data);
foreach ( $this->H->calls as $instruction ) {
// Execute the callback against the Renderer
call_user_func_array(array(&$R, $instruction[0]),$instruction[1]);
}
return str_replace("\n",'',$R->doc);
}
function test_html_off(){
$test = array('<html><b>bold</b></html>','<p><code class="code html4strict">&lt;b&gt;bold&lt;/b&gt;</code></p>');
global $conf;
$conf['htmlok'] = 0;
$result = $this->_run_parser(array('html'=>'html'),$test[0]);
$this->assertEqual($result,$test[1]);
}
function test_html_on(){
$test = array('<html><b>bold</b></html>','<p><b>bold</b></p>');
global $conf;
$conf['htmlok'] = 1;
$result = $this->_run_parser(array('html'=>'html'),$test[0]);
$this->assertEqual($result,$test[1]);
}
function test_htmlblock_off(){
$test = array('<HTML><b>bold</b></HTML>','<pre class="code html4strict">&lt;b&gt;bold&lt;/b&gt;</pre>');
global $conf;
$conf['htmlok'] = 0;
$result = $this->_run_parser(array('html'=>'html'),$test[0]);
$this->assertEqual($result,$test[1]);
}
function test_htmlblock_on(){
$test = array('<HTML><b>bold</b></HTML>','<b>bold</b>');
global $conf;
$conf['htmlok'] = 1;
$result = $this->_run_parser(array('html'=>'html'),$test[0]);
$this->assertEqual($result,$test[1]);
}
function test_php_off(){
$test = array('<php>echo(1+1);</php>','<p><code class="code php">echo(1+1);</code></p>');
global $conf;
$conf['phpok'] = 0;
$result = $this->_run_parser(array('php'=>'php'),$test[0]);
$this->assertEqual($result,$test[1]);
}
function test_php_on(){
$test = array('<php>echo(1+1);</php>','<p>2</p>');
global $conf;
$conf['phpok'] = 1;
$result = $this->_run_parser(array('php'=>'php'),$test[0]);
$this->assertEqual($result,$test[1]);
}
function test_phpblock_off(){
$test = array('<PHP>echo(1+1);</PHP>','<pre class="code php">echo(1+1);</pre>');
global $conf;
$conf['phpok'] = 0;
$result = $this->_run_parser(array('php'=>'php'),$test[0]);
$this->assertEqual($result,$test[1]);
}
function test_phpblock_on(){
$test = array('<PHP>echo(1+1);</PHP>',"2");
global $conf;
$conf['phpok'] = 1;
$result = $this->_run_parser(array('php'=>'php'),$test[0]);
$this->assertEqual($result,$test[1]);
}
}

View File

@ -1,239 +0,0 @@
<?php
if (!defined('DOKU_BASE')) define('DOKU_BASE','./');
require_once DOKU_INC.'inc/parser/xhtml.php';
require_once DOKU_INC.'inc/pageutils.php';
class xhtml_links_test extends UnitTestCase {
function test_emaillink(){
global $conf;
$conf['mailguard'] = 'visible';
$conf['userewrite'] = 0;
$p = new Doku_Renderer_xhtml();
$p->emaillink('foo@example.com','<script>alert(\'"alert"\');</script>');
$expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="mail" title="foo [at] example [dot] com">&lt;script&gt;alert(&#039;&quot;alert&quot;&#039;);&lt;/script&gt;</a>';
$this->assertEqual($p->doc,$expect);
}
function test_emaillink_with_media(){
global $conf;
$conf['mailguard'] = 'visible';
$conf['userewrite'] = 2;
$image = array(
'type'=>'internalmedia',
'src'=>'img.gif',
'title'=>'Some Image',
'align'=>NULL,
'width'=>10,
'height'=>20,
'cache'=>'nocache',
'linking'=>'details',
);
$p = new Doku_Renderer_xhtml();
$p->emaillink('foo@example.com',$image);
$expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="media" title="foo [at] example [dot] com"><img src="'.DOKU_BASE.'lib/exe/fetch.php/img.gif?w=10&amp;h=20&amp;cache=nocache" class="media" title="Some Image" alt="Some Image" width="10" height="20" /></a>';
$this->assertEqual($p->doc,$expect);
}
/**
* Produced by syntax like [[ ]]
*/
function test_empty_internallink(){
$page = 'my:space';
global $ID;
$ID = $page;
global $conf;
$conf['start'] = 'start';
global $conf;
$conf['basedir'] = '/';
$conf['useheading'] = 0;
$conf['userewrite'] = 0;
$conf['useslash'] = 0;
$conf['canonical'] = 0;
$p = new Doku_Renderer_xhtml();
$p->internallink('');
if (page_exists($page)) {
$class = 'wikilink1';
$rel = '';
}
else {
$class = 'wikilink2';
$rel = ' rel="nofollow"';
}
$parts = split(':', $page);
$caption = $parts[count($parts)-1];
$expect = '<span class="curid"><a href="/./doku.php?id='.$page.'" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
$this->assertEqual($p->doc, $expect);
}
/**
* Produced by syntax like [[ |my caption]]
*/
function test_empty_internallink_with_caption(){
$page = 'my:space';
$caption = 'my caption';
global $ID;
$ID = $page;
global $conf;
$conf['basedir'] = '/';
$conf['useheading'] = 0;
$conf['userewrite'] = 0;
$conf['useslash'] = 0;
$conf['canonical'] = 0;
$p = new Doku_Renderer_xhtml();
$p->internallink('', $caption);
if (page_exists($page)) {
$class = 'wikilink1';
$rel = '';
}
else {
$class = 'wikilink2';
$rel = ' rel="nofollow"';
}
$expect = '<span class="curid"><a href="/./doku.php?id='.$page.'" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
$this->assertEqual($p->doc, $expect);
}
/**
* Produced by syntax like [[?do=index]]
*/
function test_empty_internallink_index(){
$page = 'my:space';
global $ID;
$ID = $page;
global $conf;
$conf['start'] = 'start';
global $conf;
$conf['basedir'] = '/';
$conf['useheading'] = 0;
$conf['userewrite'] = 0;
$conf['useslash'] = 0;
$conf['canonical'] = 0;
$p = new Doku_Renderer_xhtml();
$p->internallink('?do=index');
if (page_exists($page)) {
$class = 'wikilink1';
$rel = '';
}
else {
$class = 'wikilink2';
$rel = ' rel="nofollow"';
}
$parts = split(':', $page);
$caption = $parts[count($parts)-1];
$expect = '<span class="curid"><a href="/./doku.php?id='.$page.'&amp;do=index" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
$this->assertEqual($p->doc, $expect);
}
/**
* Produced by syntax like [[?do=index|my caption]]
*/
function test_empty_internallink_index_with_caption(){
$page = 'my:space';
$caption = 'my caption';
global $ID;
$ID = $page;
global $conf;
$conf['basedir'] = '/';
$conf['useheading'] = 0;
$conf['userewrite'] = 0;
$conf['useslash'] = 0;
$conf['canonical'] = 0;
$p = new Doku_Renderer_xhtml();
$p->internallink('?do=index', $caption);
if (page_exists($page)) {
$class = 'wikilink1';
$rel = '';
}
else {
$class = 'wikilink2';
$rel = ' rel="nofollow"';
}
$expect = '<span class="curid"><a href="/./doku.php?id='.$page.'&amp;do=index" class="'.$class.'" title="'.$page.'"'.$rel.'>'.$caption.'</a></span>';
$this->assertEqual($p->doc, $expect);
}
/**
* Produced by syntax like [[#test]]
*/
function test_empty_locallink(){
$page = 'my:spacex';
global $ID;
$ID = $page;
global $conf;
$conf['basedir'] = '/';
$conf['useheading'] = 0;
$conf['userewrite'] = 0;
$conf['useslash'] = 0;
$conf['canonical'] = 0;
$p = new Doku_Renderer_xhtml();
$p->locallink('test');
$expect = '<a href="#test" title="'.$page.' &crarr;" class="wikilink1">test</a>';
$this->assertEqual($p->doc, $expect);
}
/**
* Produced by syntax like [[#test|my caption]]
*/
function test_empty_locallink_with_caption(){
$page = 'my:spacex';
$caption = 'my caption';
global $ID;
$ID = $page;
global $conf;
$conf['basedir'] = '/';
$conf['useheading'] = 0;
$conf['userewrite'] = 0;
$conf['useslash'] = 0;
$conf['canonical'] = 0;
$p = new Doku_Renderer_xhtml();
$p->locallink('test', $caption);
$expect = '<a href="#test" title="'.$page.' &crarr;" class="wikilink1">'.$caption.'</a>';
$this->assertEqual($p->doc, $expect);
}
}

21
_test/conf/acl.auth.php Normal file
View File

@ -0,0 +1,21 @@
# acl.auth.php
# <?php exit()?>
# Don't modify the lines above
#
# Access Control Lists
#
# Editing this file by hand shouldn't be necessary. Use the ACL
# Manager interface instead.
#
# If your auth backend allows special char like spaces in groups
# or user names you need to urlencode them (only chars <128, leave
# UTF-8 multibyte chars as is)
#
# none 0
# read 1
# edit 2
# create 4
# upload 8
# delete 16
* @ALL 8

10
_test/conf/local.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$conf['savedir'] = DOKU_TMP_DATA; //where to store all the files
$conf['title'] = 'My Test Wiki'; //what to show in the title
$conf['useacl'] = 1; //Use Access Control Lists to restrict access?
$conf['superuser'] = 'testuser'; //password: testpass
$conf['dnslookups'] = 0; //speedup tests

View File

@ -0,0 +1,8 @@
<?php
/*
* Local plugin enable/disable settings
* 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.
*/

12
_test/conf/users.auth.php Normal file
View File

@ -0,0 +1,12 @@
# users.auth.php
# <?php exit()?>
# Don't modify the lines above
#
# Userfile
#
# Format:
#
# user:MD5password:Real Name:email:groups,comma,seperated
#
# testuser : testpass
testuser:179ad45c6ce2cb97cf1029e212046e81:Arthur Dent:arthur@example.com:

View File

@ -0,0 +1,96 @@
<?php
/**
* Helper class to provide basic functionality for tests
*/
abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
/**
* tests can override this
*
* @var array plugins to enable for test class
*/
protected $pluginsEnabled = array();
/**
* tests can override this
*
* @var array plugins to disable for test class
*/
protected $pluginsDisabled = array();
/**
* Reset the DokuWiki environment before each test run. Makes sure loaded config,
* language and plugins are correct.
*
* @throws Exception if plugin actions fail
* @return void
*/
public function setUp() {
// reload config
global $conf, $config_cascade;
$conf = array();
foreach (array('default','local','protected') as $config_group) {
if (empty($config_cascade['main'][$config_group])) continue;
foreach ($config_cascade['main'][$config_group] as $config_file) {
if (@file_exists($config_file)) {
include($config_file);
}
}
}
// reload license config
global $license;
$license = array();
// load the license file(s)
foreach (array('default','local') as $config_group) {
if (empty($config_cascade['license'][$config_group])) continue;
foreach ($config_cascade['license'][$config_group] as $config_file) {
if(@file_exists($config_file)){
include($config_file);
}
}
}
// make real paths and check them
init_paths();
init_files();
// reset loaded plugins
global $plugin_controller_class, $plugin_controller;
$plugin_controller = new $plugin_controller_class();
// disable all non-default plugins
global $default_plugins;
foreach ($plugin_controller->getList() as $plugin) {
if (!in_array($plugin, $default_plugins)) {
if (!$plugin_controller->disable($plugin)) {
throw new Exception('Could not disable plugin "'.$plugin.'"!');
}
}
}
// disable and enable configured plugins
foreach ($this->pluginsDisabled as $plugin) {
if (!$plugin_controller->disable($plugin)) {
throw new Exception('Could not disable plugin "'.$plugin.'"!');
}
}
foreach ($this->pluginsEnabled as $plugin) {
/* enable() returns false but works...
if (!$plugin_controller->enable($plugin)) {
throw new Exception('Could not enable plugin "'.$plugin.'"!');
}
*/
$plugin_controller->enable($plugin);
}
// reset event handler
global $EVENT_HANDLER;
$EVENT_HANDLER = new Doku_Event_Handler();
// reload language
$local = $conf['lang'];
trigger_event('INIT_LANG_LOAD', $local, 'init_lang', true);
}
}

View File

@ -0,0 +1,82 @@
<?php
/**
* Simulates a full DokuWiki HTTP Request and allows
* runtime inspection.
*/
// output buffering
$output_buffer = '';
function ob_start_callback($buffer) {
global $output_buffer;
$output_buffer .= $buffer;
}
/**
* Helper class to execute a fake request
*/
class TestRequest {
private $server = array();
private $session = array();
private $get = array();
private $post = array();
public function getServer($key) { return $this->server[$key]; }
public function getSession($key) { return $this->session[$key]; }
public function getGet($key) { return $this->get[$key]; }
public function getPost($key) { return $this->post[$key]; }
public function setServer($key, $value) { $this->server[$key] = $value; }
public function setSession($key, $value) { $this->session[$key] = $value; }
public function setGet($key, $value) { $this->get[$key] = $value; }
public function setPost($key, $value) { $this->post[$key] = $value; }
/**
* Executes the request
*
* @return TestResponse the resulting output of the request
*/
public function execute() {
// save old environment
$server = $_SERVER;
$session = $_SESSION;
$get = $_GET;
$post = $_POST;
$request = $_REQUEST;
// fake environment
global $default_server_vars;
$_SERVER = array_merge($default_server_vars, $this->server);
$_SESSION = $this->session;
$_GET = $this->get;
$_POST = $this->post;
$_REQUEST = array_merge($_GET, $_POST);
// reset output buffer
global $output_buffer;
$output_buffer = '';
// now execute dokuwiki and grep the output
header_remove();
ob_start('ob_start_callback');
include(DOKU_INC.'doku.php');
ob_end_flush();
// create the response object
$response = new TestResponse(
$output_buffer,
headers_list()
);
// reset environment
$_SERVER = $server;
$_SESSION = $session;
$_GET = $get;
$_POST = $post;
$_REQUEST = $request;
return $response;
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* holds a copy of all produced outputs of a TestRequest
*/
class TestResponse {
/**
* @var string
*/
private $content;
/**
* @var array
*/
private $headers;
/**
* @var phpQueryObject
*/
private $pq = null;
/**
* @param $content string
* @param $headers array
*/
function __construct($content, $headers) {
$this->content = $content;
$this->headers = $headers;
}
/**
* @return string
*/
public function getContent() {
return $this->content;
}
/**
* @return array
*/
public function getHeaders() {
return $this->headers;
}
/**
* Query the response for a JQuery compatible CSS selector
*
* @link https://code.google.com/p/phpquery/wiki/Selectors
* @param $selector string
* @return phpQueryObject
*/
public function queryHTML($selector){
if(is_null($this->pq)) $this->pq = phpQuery::newDocument($this->content);
return $this->pq->find($selector);
}
}

70
_test/core/TestUtils.php Normal file
View File

@ -0,0 +1,70 @@
<?php
/**
* Helper class with some filesystem utilities.
*/
class TestUtils {
/**
* helper for recursive copy()
*
* @static
* @param $destdir string
* @param $source string
*/
public static function rcopy($destdir, $source) {
if (!is_dir($source)) {
copy($source, $destdir.'/'.basename($source));
} else {
$newdestdir = $destdir.'/'.basename($source);
if (!is_dir($newdestdir)) {
mkdir($newdestdir);
}
$dh = dir($source);
while (false !== ($entry = $dh->read())) {
if ($entry == '.' || $entry == '..') {
continue;
}
TestUtils::rcopy($newdestdir, $source.'/'.$entry);
}
$dh->close();
}
}
/**
* helper for recursive rmdir()/unlink()
*
* @static
* @param $target string
*/
public static function rdelete($target) {
if (!is_dir($target)) {
unlink($target);
} else {
$dh = dir($target);
while (false !== ($entry = $dh->read())) {
if ($entry == '.' || $entry == '..') {
continue;
}
TestUtils::rdelete("$target/$entry");
}
$dh->close();
rmdir($target);
}
}
/**
* helper to append text to a file
*
* @static
* @param $file string
* @param $text string
*/
public static function fappend($file, $text) {
$fh = fopen($file, 'a');
fwrite($fh, $text);
fclose($fh);
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

View File

0
_test/data/meta/_dummy Normal file
View File

View File

@ -0,0 +1,64 @@
====== DokuWiki ======
[[doku>wiki:dokuwiki|{{wiki:dokuwiki-128.png }}]] DokuWiki is a standards compliant, simple to use [[wp>Wiki]], mainly aimed at creating documentation of any kind. It is targeted at developer teams, workgroups and small companies. It has a simple but powerful [[wiki:syntax]] which makes sure the datafiles remain readable outside the Wiki and eases the creation of structured texts. All data is stored in plain text files -- no database is required.
Read the [[doku>manual|DokuWiki Manual]] to unleash the full power of DokuWiki.
===== Download =====
DokuWiki is available at http://www.splitbrain.org/go/dokuwiki
===== Read More =====
All documentation and additional information besides the [[syntax|syntax description]] is maintained in the DokuWiki at [[doku>|www.dokuwiki.org]].
**About DokuWiki**
* [[doku>features|A feature list]] :!:
* [[doku>users|Happy Users]]
* [[doku>press|Who wrote about it]]
* [[doku>blogroll|What Bloggers think]]
* [[http://www.wikimatrix.org/show/DokuWiki|Compare it with other wiki software]]
**Installing DokuWiki**
* [[doku>requirements|System Requirements]]
* [[http://www.splitbrain.org/go/dokuwiki|Download DokuWiki]] :!:
* [[doku>changes|Change Log]]
* [[doku>Install|How to install or upgrade]] :!:
* [[doku>config|Configuration]]
**Using DokuWiki**
* [[doku>syntax|Wiki Syntax]]
* [[doku>manual|The manual]] :!:
* [[doku>FAQ|Frequently Asked Questions (FAQ)]]
* [[doku>glossary|Glossary]]
* [[http://search.dokuwiki.org|Search for DokuWiki help and documentation]]
**Customizing DokuWiki**
* [[doku>tips|Tips and Tricks]]
* [[doku>Template|How to create and use templates]]
* [[doku>plugins|Installing plugins]]
* [[doku>development|Development Resources]]
**DokuWiki Feedback and Community**
* [[doku>newsletter|Subscribe to the newsletter]] :!:
* [[doku>mailinglist|Join the mailing list]]
* [[http://forum.dokuwiki.org|Check out the user forum]]
* [[doku>irc|Talk to other users in the IRC channel]]
* [[http://bugs.splitbrain.org/index.php?project=1|Submit bugs and feature wishes]]
* [[http://www.wikimatrix.org/forum/viewforum.php?id=10|Share your experiences in the WikiMatrix forum]]
* [[doku>thanks|Some humble thanks]]
===== Copyright =====
2004-2010 (c) Andreas Gohr <andi@splitbrain.org>((Please do not contact me for help and support -- use the [[doku>mailinglist]] or [[http://forum.dokuwiki.org|forum]] instead)) and the DokuWiki Community
The DokuWiki engine is licensed under [[http://www.gnu.org/licenses/gpl.html|GNU General Public License]] Version 2. If you use DokuWiki in your company, consider [[doku>donate|donating]] a few bucks ;-).
Not sure what this means? See the [[doku>faq:license|FAQ on the Licenses]].

View File

@ -0,0 +1,486 @@
====== Formatting Syntax ======
[[doku>DokuWiki]] supports some simple markup language, which tries to make the datafiles to be as readable as possible. This page contains all possible syntax you may use when editing the pages. Simply have a look at the source of this page by pressing the //Edit this page// button at the top or bottom of the page. If you want to try something, just use the [[playground:playground|playground]] page. The simpler markup is easily accessible via [[doku>toolbar|quickbuttons]], too.
===== Basic Text Formatting =====
DokuWiki supports **bold**, //italic//, __underlined__ and ''monospaced'' texts. Of course you can **__//''combine''//__** all these.
DokuWiki supports **bold**, //italic//, __underlined__ and ''monospaced'' texts.
Of course you can **__//''combine''//__** all these.
You can use <sub>subscript</sub> and <sup>superscript</sup>, too.
You can use <sub>subscript</sub> and <sup>superscript</sup>, too.
You can mark something as <del>deleted</del> as well.
You can mark something as <del>deleted</del> as well.
**Paragraphs** are created from blank lines. If you want to **force a newline** without a paragraph, you can use two backslashes followed by a whitespace or the end of line.
This is some text with some linebreaks\\ Note that the
two backslashes are only recognized at the end of a line\\
or followed by\\ a whitespace \\this happens without it.
This is some text with some linebreaks\\ Note that the
two backslashes are only recognized at the end of a line\\
or followed by\\ a whitespace \\this happens without it.
You should use forced newlines only if really needed.
===== Links =====
DokuWiki supports multiple ways of creating links.
==== External ====
External links are recognized automagically: http://www.google.com or simply www.google.com - You can set the link text as well: [[http://www.google.com|This Link points to google]]. Email addresses like this one: <andi@splitbrain.org> are recognized, too.
DokuWiki supports multiple ways of creating links. External links are recognized
automagically: http://www.google.com or simply www.google.com - You can set
link text as well: [[http://www.google.com|This Link points to google]]. Email
addresses like this one: <andi@splitbrain.org> are recognized, too.
==== Internal ====
Internal links are created by using square brackets. You can either just give a [[pagename]] or use an additional [[pagename|link text]].
Internal links are created by using square brackets. You can either just give
a [[pagename]] or use an additional [[pagename|link text]].
[[doku>pagename|Wiki pagenames]] are converted to lowercase automatically, special characters are not allowed.
You can use [[some:namespaces]] by using a colon in the pagename.
You can use [[some:namespaces]] by using a colon in the pagename.
For details about namespaces see [[doku>namespaces]].
Linking to a specific section is possible, too. Just add the section name behind a hash character as known from HTML. This links to [[syntax#internal|this Section]].
This links to [[syntax#internal|this Section]].
Notes:
* Links to [[syntax|existing pages]] are shown in a different style from [[nonexisting]] ones.
* DokuWiki does not use [[wp>CamelCase]] to automatically create links by default, but this behavior can be enabled in the [[doku>config]] file. Hint: If DokuWiki is a link, then it's enabled.
* When a section's heading is changed, its bookmark changes, too. So don't rely on section linking too much.
==== Interwiki ====
DokuWiki supports [[doku>Interwiki]] links. These are quick links to other Wikis. For example this is a link to Wikipedia's page about Wikis: [[wp>Wiki]].
DokuWiki supports [[doku>Interwiki]] links. These are quick links to other Wikis.
For example this is a link to Wikipedia's page about Wikis: [[wp>Wiki]].
==== Windows Shares ====
Windows shares like [[\\server\share|this]] are recognized, too. Please note that these only make sense in a homogeneous user group like a corporate [[wp>Intranet]].
Windows Shares like [[\\server\share|this]] are recognized, too.
Notes:
* For security reasons direct browsing of windows shares only works in Microsoft Internet Explorer per default (and only in the "local zone").
* For Mozilla and Firefox it can be enabled through different workaround mentioned in the [[http://kb.mozillazine.org/Links_to_local_pages_do_not_work|Mozilla Knowledge Base]]. However, there will still be a JavaScript warning about trying to open a Windows Share. To remove this warning (for all users), put the following line in ''conf/local.protected.php'':
$lang['js']['nosmblinks'] = '';
==== Image Links ====
You can also use an image to link to another internal or external page by combining the syntax for links and [[#images_and_other_files|images]] (see below) like this:
[[http://www.php.net|{{wiki:dokuwiki-128.png}}]]
[[http://www.php.net|{{wiki:dokuwiki-128.png}}]]
Please note: The image formatting is the only formatting syntax accepted in link names.
The whole [[#images_and_other_files|image]] and [[#links|link]] syntax is supported (including image resizing, internal and external images and URLs and interwiki links).
===== Footnotes =====
You can add footnotes ((This is a footnote)) by using double parentheses.
You can add footnotes ((This is a footnote)) by using double parentheses.
===== Sectioning =====
You can use up to five different levels of headlines to structure your content. If you have more than three headlines, a table of contents is generated automatically -- this can be disabled by including the string ''<nowiki>~~NOTOC~~</nowiki>'' in the document.
==== Headline Level 3 ====
=== Headline Level 4 ===
== Headline Level 5 ==
==== Headline Level 3 ====
=== Headline Level 4 ===
== Headline Level 5 ==
By using four or more dashes, you can make a horizontal line:
----
===== Images and Other Files =====
You can include external and internal [[doku>images]] with curly brackets. Optionally you can specify the size of them.
Real size: {{wiki:dokuwiki-128.png}}
Resize to given width: {{wiki:dokuwiki-128.png?50}}
Resize to given width and height((when the aspect ratio of the given width and height doesn't match that of the image, it will be cropped to the new ratio before resizing)): {{wiki:dokuwiki-128.png?200x50}}
Resized external image: {{http://de3.php.net/images/php.gif?200x50}}
Real size: {{wiki:dokuwiki-128.png}}
Resize to given width: {{wiki:dokuwiki-128.png?50}}
Resize to given width and height: {{wiki:dokuwiki-128.png?200x50}}
Resized external image: {{http://de3.php.net/images/php.gif?200x50}}
By using left or right whitespaces you can choose the alignment.
{{ wiki:dokuwiki-128.png}}
{{wiki:dokuwiki-128.png }}
{{ wiki:dokuwiki-128.png }}
{{ wiki:dokuwiki-128.png}}
{{wiki:dokuwiki-128.png }}
{{ wiki:dokuwiki-128.png }}
Of course, you can add a title (displayed as a tooltip by most browsers), too.
{{ wiki:dokuwiki-128.png |This is the caption}}
{{ wiki:dokuwiki-128.png |This is the caption}}
If you specify a filename (external or internal) that is not an image (''gif, jpeg, png''), then it will be displayed as a link instead.
For linking an image to another page see [[#Image Links]] above.
===== Lists =====
Dokuwiki supports ordered and unordered lists. To create a list item, indent your text by two spaces and use a ''*'' for unordered lists or a ''-'' for ordered ones.
* This is a list
* The second item
* You may have different levels
* Another item
- The same list but ordered
- Another item
- Just use indention for deeper levels
- That's it
<code>
* This is a list
* The second item
* You may have different levels
* Another item
- The same list but ordered
- Another item
- Just use indention for deeper levels
- That's it
</code>
Also take a look at the [[doku>faq:lists|FAQ on list items]].
===== Text Conversions =====
DokuWiki can convert certain pre-defined characters or strings into images or other text or HTML.
The text to image conversion is mainly done for smileys. And the text to HTML conversion is used for typography replacements, but can be configured to use other HTML as well.
==== Text to Image Conversions ====
DokuWiki converts commonly used [[wp>emoticon]]s to their graphical equivalents. Those [[doku>Smileys]] and other images can be configured and extended. Here is an overview of Smileys included in DokuWiki:
* 8-) %% 8-) %%
* 8-O %% 8-O %%
* :-( %% :-( %%
* :-) %% :-) %%
* =) %% =) %%
* :-/ %% :-/ %%
* :-\ %% :-\ %%
* :-? %% :-? %%
* :-D %% :-D %%
* :-P %% :-P %%
* :-O %% :-O %%
* :-X %% :-X %%
* :-| %% :-| %%
* ;-) %% ;-) %%
* ^_^ %% ^_^ %%
* :?: %% :?: %%
* :!: %% :!: %%
* LOL %% LOL %%
* FIXME %% FIXME %%
* DELETEME %% DELETEME %%
==== Text to HTML Conversions ====
Typography: [[DokuWiki]] can convert simple text characters to their typographically correct entities. Here is an example of recognized characters.
-> <- <-> => <= <=> >> << -- --- 640x480 (c) (tm) (r)
"He thought 'It's a man's world'..."
<code>
-> <- <-> => <= <=> >> << -- --- 640x480 (c) (tm) (r)
"He thought 'It's a man's world'..."
</code>
The same can be done to produce any kind of HTML, it just needs to be added to the [[doku>entities|pattern file]].
There are three exceptions which do not come from that pattern file: multiplication entity (640x480), 'single' and "double quotes". They can be turned off through a [[doku>config:typography|config option]].
===== Quoting =====
Some times you want to mark some text to show it's a reply or comment. You can use the following syntax:
I think we should do it
> No we shouldn't
>> Well, I say we should
> Really?
>> Yes!
>>> Then lets do it!
I think we should do it
> No we shouldn't
>> Well, I say we should
> Really?
>> Yes!
>>> Then lets do it!
===== Tables =====
DokuWiki supports a simple syntax to create tables.
^ Heading 1 ^ Heading 2 ^ Heading 3 ^
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
| Row 2 Col 1 | some colspan (note the double pipe) ||
| Row 3 Col 1 | Row 3 Col 2 | Row 3 Col 3 |
Table rows have to start and end with a ''|'' for normal rows or a ''^'' for headers.
^ Heading 1 ^ Heading 2 ^ Heading 3 ^
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
| Row 2 Col 1 | some colspan (note the double pipe) ||
| Row 3 Col 1 | Row 3 Col 2 | Row 3 Col 3 |
To connect cells horizontally, just make the next cell completely empty as shown above. Be sure to have always the same amount of cell separators!
Vertical tableheaders are possible, too.
| ^ Heading 1 ^ Heading 2 ^
^ Heading 3 | Row 1 Col 2 | Row 1 Col 3 |
^ Heading 4 | no colspan this time | |
^ Heading 5 | Row 2 Col 2 | Row 2 Col 3 |
As you can see, it's the cell separator before a cell which decides about the formatting:
| ^ Heading 1 ^ Heading 2 ^
^ Heading 3 | Row 1 Col 2 | Row 1 Col 3 |
^ Heading 4 | no colspan this time | |
^ Heading 5 | Row 2 Col 2 | Row 2 Col 3 |
You can have rowspans (vertically connected cells) by adding '':::'' into the cells below the one to which they should connect.
^ Heading 1 ^ Heading 2 ^ Heading 3 ^
| Row 1 Col 1 | this cell spans vertically | Row 1 Col 3 |
| Row 2 Col 1 | ::: | Row 2 Col 3 |
| Row 3 Col 1 | ::: | Row 2 Col 3 |
Apart from the rowspan syntax those cells should not contain anything else.
^ Heading 1 ^ Heading 2 ^ Heading 3 ^
| Row 1 Col 1 | this cell spans vertically | Row 1 Col 3 |
| Row 2 Col 1 | ::: | Row 2 Col 3 |
| Row 3 Col 1 | ::: | Row 2 Col 3 |
You can align the table contents, too. Just add at least two whitespaces at the opposite end of your text: Add two spaces on the left to align right, two spaces on the right to align left and two spaces at least at both ends for centered text.
^ Table with alignment ^^^
| right| center |left |
|left | right| center |
| xxxxxxxxxxxx | xxxxxxxxxxxx | xxxxxxxxxxxx |
This is how it looks in the source:
^ Table with alignment ^^^
| right| center |left |
|left | right| center |
| xxxxxxxxxxxx | xxxxxxxxxxxx | xxxxxxxxxxxx |
Note: Vertical alignment is not supported.
===== No Formatting =====
If you need to display text exactly like it is typed (without any formatting), enclose the area either with ''%%<nowiki>%%'' tags or even simpler, with double percent signs ''<nowiki>%%</nowiki>''.
<nowiki>
This is some text which contains addresses like this: http://www.splitbrain.org and **formatting**, but nothing is done with it.
</nowiki>
The same is true for %%//__this__ text// with a smiley ;-)%%.
<nowiki>
This is some text which contains addresses like this: http://www.splitbrain.org and **formatting**, but nothing is done with it.
</nowiki>
The same is true for %%//__this__ text// with a smiley ;-)%%.
===== Code Blocks =====
You can include code blocks into your documents by either indenting them by at least two spaces (like used for the previous examples) or by using the tags ''%%<code>%%'' or ''%%<file>%%''.
This is text is indented by two spaces.
<code>
This is preformatted code all spaces are preserved: like <-this
</code>
<file>
This is pretty much the same, but you could use it to show that you quoted a file.
</file>
Those blocks were created by this source:
This is text is indented by two spaces.
<code>
This is preformatted code all spaces are preserved: like <-this
</code>
<file>
This is pretty much the same, but you could use it to show that you quoted a file.
</file>
==== Syntax Highlighting ====
[[wiki:DokuWiki]] can highlight sourcecode, which makes it easier to read. It uses the [[http://qbnz.com/highlighter/|GeSHi]] Generic Syntax Highlighter -- so any language supported by GeSHi is supported. The syntax uses the same code and file blocks described in the previous section, but this time the name of the language syntax to be highlighted is included inside the tag, e.g. ''<nowiki><code java></nowiki>'' or ''<nowiki><file java></nowiki>''.
<code java>
/**
* The HelloWorldApp class implements an application that
* simply displays "Hello World!" to the standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); //Display the string.
}
}
</code>
The following language strings are currently recognized: //4cs, abap, actionscript-french, actionscript, actionscript3, ada, apache, applescript, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, ecmascript, eiffel, email, erlang, fo, fortran, freebasic, fsharp, gambas, genero, genie, gdb, glsl, gml, gnuplot, groovy, gettext, gwbasic, haskell, hicest, hq9plus, html, icon, idl, ini, inno, intercal, io, j, java5, java, javascript, jquery, kixtart, klonec, klonecpp, latex, lisp, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, modula2, modula3, mmix, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, ocaml-brief, ocaml, oobas, oracle8, oracle11, oxygene, oz, pascal, pcre, perl, perl6, per, pf, php-brief, php, pike, pic16, pixelbender, plsql, postgresql, povray, powerbuilder, powershell, progress, prolog, properties, providex, purebasic, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, vala, vbnet, vb, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, winbatch, whois, xbasic, xml, xorg_conf, xpp, z80//
==== Downloadable Code Blocks ====
When you use the ''%%<code>%%'' or ''%%<file>%%'' syntax as above, you might want to make the shown code available for download as well. You can to this by specifying a file name after language code like this:
<code>
<file php myexample.php>
<?php echo "hello world!"; ?>
</file>
</code>
<file php myexample.php>
<?php echo "hello world!"; ?>
</file>
If you don't want any highlighting but want a downloadable file, specify a dash (''-'') as the language code: ''%%<code - myfile.foo>%%''.
===== Embedding HTML and PHP =====
You can embed raw HTML or PHP code into your documents by using the ''%%<html>%%'' or ''%%<php>%%'' tags. (Use uppercase tags if you need to enclose block level elements.)
HTML example:
<code>
<html>
This is some <span style="color:red;font-size:150%;">inline HTML</span>
</html>
<HTML>
<p style="border:2px dashed red;">And this is some block HTML</p>
</HTML>
</code>
<html>
This is some <span style="color:red;font-size:150%;">inline HTML</span>
</html>
<HTML>
<p style="border:2px dashed red;">And this is some block HTML</p>
</HTML>
PHP example:
<code>
<php>
echo 'A logo generated by PHP:';
echo '<img src="' . $_SERVER['PHP_SELF'] . '?=' . php_logo_guid() . '" alt="PHP Logo !" />';
echo '(generated inline HTML)';
</php>
<PHP>
echo '<table class="inline"><tr><td>The same, but inside a block level element:</td>';
echo '<td><img src="' . $_SERVER['PHP_SELF'] . '?=' . php_logo_guid() . '" alt="PHP Logo !" /></td>';
echo '</tr></table>';
</PHP>
</code>
<php>
echo 'A logo generated by PHP:';
echo '<img src="' . $_SERVER['PHP_SELF'] . '?=' . php_logo_guid() . '" alt="PHP Logo !" />';
echo '(inline HTML)';
</php>
<PHP>
echo '<table class="inline"><tr><td>The same, but inside a block level element:</td>';
echo '<td><img src="' . $_SERVER['PHP_SELF'] . '?=' . php_logo_guid() . '" alt="PHP Logo !" /></td>';
echo '</tr></table>';
</PHP>
**Please Note**: HTML and PHP embedding is disabled by default in the configuration. If disabled, the code is displayed instead of executed.
===== RSS/ATOM Feed Aggregation =====
[[DokuWiki]] can integrate data from external XML feeds. For parsing the XML feeds, [[http://simplepie.org/|SimplePie]] is used. All formats understood by SimplePie can be used in DokuWiki as well. You can influence the rendering by multiple additional space separated parameters:
^ Parameter ^ Description ^
| any number | will be used as maximum number items to show, defaults to 8 |
| reverse | display the last items in the feed first |
| author | show item authors names |
| date | show item dates |
| description| show the item description. If [[doku>config:htmlok|HTML]] is disabled all tags will be stripped |
| //n//[dhm] | refresh period, where d=days, h=hours, m=minutes. (e.g. 12h = 12 hours). |
The refresh period defaults to 4 hours. Any value below 10 minutes will be treated as 10 minutes. [[wiki:DokuWiki]] will generally try to supply a cached version of a page, obviously this is inappropriate when the page contains dynamic external content. The parameter tells [[wiki:DokuWiki]] to re-render the page if it is more than //refresh period// since the page was last rendered.
**Example:**
{{rss>http://slashdot.org/index.rss 5 author date 1h }}
{{rss>http://slashdot.org/index.rss 5 author date 1h }}
===== Control Macros =====
Some syntax influences how DokuWiki renders a page without creating any output it self. The following control macros are availble:
^ Macro ^ Description |
| %%~~NOTOC~~%% | If this macro is found on the page, no table of contents will be created |
| %%~~NOCACHE~~%% | DokuWiki caches all output by default. Sometimes this might not be wanted (eg. when the %%<php>%% syntax above is used), adding this macro will force DokuWiki to rerender a page on every call |
===== Syntax Plugins =====
DokuWiki's syntax can be extended by [[doku>plugins|Plugins]]. How the installed plugins are used is described on their appropriate description pages. The following syntax plugins are available in this particular DokuWiki installation:
~~INFO:syntaxplugins~~

0
_test/data/tmp/_dummy Normal file
View File

View File

@ -1,4 +0,0 @@
print "-----------------------------------------------------\n";
print_r(array_map('stripbyteindex',$this->H->calls));
print "-----------------------------------------------------\n";
print_r($calls);

View File

@ -1,228 +0,0 @@
<?php
define('DOKU_UNITTEST',true);
define('DOKU_TESTSCRIPT',$_SERVER['PHP_SELF']);
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
define('DOKU_CONF',realpath(dirname(__FILE__).'/../conf').'/');
require_once DOKU_CONF . 'dokuwiki.php';
if(@file_exists(DOKU_CONF.'local.php')){ require_once(DOKU_CONF.'local.php'); }
$conf['lang'] = 'en';
define('TEST_ROOT', dirname(__FILE__));
define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/');
error_reporting(E_ALL & ~E_DEPRECATED);
set_time_limit(600);
ini_set('memory_limit','128M');
/* Used to determine output to display */
define('DW_TESTS_OUTPUT_HTML',1);
define('DW_TESTS_OUTPUT_XML',2);
if ( isset($_GET['output']) && $_GET['output'] == 'xml' ) {
define('DW_TESTS_OUTPUT',DW_TESTS_OUTPUT_XML);
} else {
define('DW_TESTS_OUTPUT',DW_TESTS_OUTPUT_HTML);
}
require_once 'lib/testmanager.php';
TestManager::setup('tests.ini');
if ( !defined('SIMPLE_TEST') ) {
define('SIMPLE_TEST', ConfigManager::getOptionAsPath('tests', 'simpletest', 'library_path'));
}
if (!@include_once SIMPLE_TEST . 'reporter.php') {
RaiseError('runtime', 'LIBRARY_REQUIRED', array(
'library' => 'Simple Test',
'path' => SIMPLE_TEST));
}
function & DW_TESTS_GetReporter() {
static $Reporter = NULL;
if ( !$Reporter ) {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
require_once SIMPLE_TEST . 'xml.php';
$Reporter = new XmlReporter();
break;
case DW_TESTS_OUTPUT_HTML:
default:
$Reporter = new HTMLReporter('utf-8');
break;
}
}
return $Reporter;
}
function DW_TESTS_PaintRunMore() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
break;
case DW_TESTS_OUTPUT_HTML:
default:
echo "<p><a href='" . DOKU_TESTSCRIPT . "'>Run more tests</a></p>";
break;
}
}
function DW_TESTS_PaintHeader() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
header('Content-Type: text/xml; charset="utf-8"');
break;
case DW_TESTS_OUTPUT_HTML:
$header = <<<EOD
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type'
content='text/html; charset=iso-8859-1' />
<title>Dokuwiki: Unit Test Suite</title>
<link href="tests.css" type="text/css" rel="stylesheet" media="all"/>
</head>
<body>
EOD;
echo $header;
default:
break;
}
}
function DW_TESTS_PaintSuiteHeader() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
break;
case DW_TESTS_OUTPUT_HTML:
default:
echo "<h1>Dokuwiki: Unit Test Suite</h1>\n";
echo "<p><a href='". DOKU_TESTSCRIPT ."?show=groups'>Test groups</a>";
echo " || <a href='". DOKU_TESTSCRIPT ."?show=cases'>Test cases</a></p>";
break;
}
}
function DW_TESTS_PaintCaseList() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
echo XMLTestManager::getTestCaseList(TEST_CASES);
break;
case DW_TESTS_OUTPUT_HTML:
default:
echo HTMLTestManager::getTestCaseList(TEST_CASES);
break;
}
}
function DW_TESTS_PaintGroupTestList() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
echo XMLTestManager::getGroupTestList(TEST_GROUPS);
break;
case DW_TESTS_OUTPUT_HTML:
default:
echo HTMLTestManager::getGroupTestList(TEST_GROUPS);
break;
}
}
function DW_TESTS_PaintPluginTestCaseList() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
echo XMLTestManager::getPluginTestCaseList(TEST_PLUGINS);
break;
case DW_TESTS_OUTPUT_HTML:
default:
echo HTMLTestManager::getPluginTestCaseList(TEST_PLUGINS);
break;
}
}
function DW_TESTS_PaintPluginGroupTestList() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
echo XMLTestManager::getPluginGroupTestList(TEST_PLUGINS);
break;
case DW_TESTS_OUTPUT_HTML:
default:
echo HTMLTestManager::getPluginGroupTestList(TEST_PLUGINS);
break;
}
}
function DW_TESTS_PaintFooter() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
break;
case DW_TESTS_OUTPUT_HTML:
default:
$footer = <<<EOD
</body>
</html>
EOD;
echo $footer;
break;
}
}
/** OUTPUT STARTS HERE **/
// If it's a group test
if (isset($_GET['group'])) {
if ('all' == $_GET['group']) {
TestManager::runAllTests(DW_TESTS_GetReporter());
} else {
TestManager::runGroupTest(ucfirst($_GET['group']),
TEST_GROUPS,
DW_TESTS_GetReporter());
}
DW_TESTS_PaintRunMore();
exit();
}
// If it's a plugin group test
if (isset($_GET['plugin_group'])) {
if ('all' == $_GET['plugin_group']) {
TestManager::runAllPluginTests(DW_TESTS_GetReporter());
} else {
TestManager::runGroupTest(ucfirst($_GET['plugin_group']),
TEST_PLUGINS,
DW_TESTS_GetReporter());
}
DW_TESTS_PaintRunMore();
exit();
}
// If it's a single test case
if (isset($_GET['case'])) {
TestManager::runTestCase($_GET['case'], TEST_CASES, DW_TESTS_GetReporter());
DW_TESTS_PaintRunMore();
exit();
}
// If it's a single plugin test case
if (isset($_GET['plugin_case'])) {
TestManager::runTestCase($_GET['plugin_case'], TEST_PLUGINS, DW_TESTS_GetReporter());
DW_TESTS_PaintRunMore();
exit();
}
// Else it's the main page
DW_TESTS_PaintHeader();
DW_TESTS_PaintSuiteHeader();
if (isset($_GET['show']) && $_GET['show'] == 'cases') {
DW_TESTS_PaintCaseList();
DW_TESTS_PaintPluginTestCaseList();
} else {
/* no group specified, so list them all */
DW_TESTS_PaintGroupTestList();
DW_TESTS_PaintPluginGroupTestList();
}
DW_TESTS_PaintFooter();

View File

@ -1,89 +0,0 @@
/**
* Copy to a JavaScript console on your DokuWiki instance and execute
* Runs JSLint on all our JavaScript files with our settings
*/
(function () {
var globals = ['jQuery', 'SIG', 'NS', 'JSINFO', 'LANG', 'DOKU_BASE',
'DOKU_UHC' // FIXME: Should be moved to JSINFO
], files = {
'scripts/behaviour.js': null,
//"scripts/compatibility.js": null,
"scripts/cookie.js": null,
//"scripts/delay.js": null,
//"scripts/drag.js": null,
"scripts/edit.js": null,
"scripts/editor.js": null,
"scripts/helpers.js": null,
"scripts/hotkeys.js": null,
"scripts/index.js": null,
"scripts/linkwiz.js": null,
"scripts/locktimer.js": null,
"scripts/media.js": null,
"scripts/page.js": null,
"scripts/qsearch.js": null,
"scripts/script.js": null,
"scripts/textselection.js": null,
"scripts/toolbar.js": null,
"scripts/tree.js": null //,
//"scripts/tw-sack.js": null
}, overwrites = {
"scripts/script.js": {evil: true},
"scripts/media.js": {devel: true, windows: true},
"scripts/locktimer.js": {devel: true},
"scripts/behaviour.js": {devel: true},
"scripts/helpers.js": {windows: true}
};
jQuery.ajax({
dataType: 'script',
type: "GET",
// url: 'http://jshint.com/jshint.js'
url: 'https://raw.github.com/douglascrockford/JSLint/master/jslint.js',
success: function () {
for (var file in files) {
jQuery.ajax({
cache: false,
async: false,
type: "GET",
url: DOKU_BASE + 'lib/' + file,
dataType: 'text',
success: function (res) {
files[file] = res;
var data = lint(files[file]);
jQuery.merge(globals, data.globals);
}});
}
for (var file in files) {
if (!files[file]) {
continue;
}
// FIXME more fine-grained write access
var data = lint('/*global ' + globals.join(':true, ') +
':true*/\n' + files[file], overwrites[file]);
console.log(file);
jQuery.each(data.errors || [], function (_, val) {
if (val === null) {
return;
}
console.error(val.reason + ' (Line ' + (val.line - 1) +
', character ' + val.character + '):\n' +
val.evidence);
});
};
}
});
function lint(txt, overwrite) {
JSLINT(txt, jQuery.extend({
// These settings are necessary
browser: true,
// Things we probably should learn someday
sloppy: true, white: true, eqeq: true, nomen: true,
plusplus: true, regexp: true
}, overwrite));
return JSLINT.data();
}
})();

View File

@ -1,114 +0,0 @@
<?php // -*- fill-column: 80; tab-width: 4; c-basic-offset: 4 -*-
if (! defined('ST_FAILDETAIL_SEPARATOR')) {
define('ST_FAILDETAIL_SEPARATOR', "->");
}
if (! defined('ST_FAILS_RETURN_CODE')) {
define('ST_FAILS_RETURN_CODE', 1);
}
if (version_compare(phpversion(), '4.3.0', '<') ||
php_sapi_name() == 'cgi') {
define('STDOUT', fopen('php://stdout', 'w'));
define('STDERR', fopen('php://stderr', 'w'));
register_shutdown_function(
create_function('', 'fclose(STDOUT); fclose(STDERR); return true;'));
}
/**
* Minimal command line test displayer. Writes fail details to STDERR. Returns 0
* to the shell if all tests pass, ST_FAILS_RETURN_CODE if any test fails.
*/
class CLIReporter extends SimpleReporter {
var $faildetail_separator = ST_FAILDETAIL_SEPARATOR;
var $_failinfo;
function CLIReporter($faildetail_separator = NULL) {
$this->SimpleReporter();
if (! is_null($faildetail_separator)) {
$this->setFailDetailSeparator($faildetail_separator);
}
}
function setFailDetailSeparator($separator) {
$this->faildetail_separator = $separator;
}
/**
* Return a formatted faildetail for printing.
*/
function &_paintTestFailDetail(&$message) {
$buffer = '';
$faildetail = $this->getTestList();
array_shift($faildetail);
$buffer .= implode($this->faildetail_separator, $faildetail);
$buffer .= $this->faildetail_separator . "$message\n";
return $buffer;
}
/**
* Paint fail faildetail to STDERR.
*/
function paintFail($message) {
parent::paintFail($message);
fwrite(STDERR, 'FAIL' . $this->faildetail_separator .
$this->_paintTestFailDetail($message));
if($this->_failinfo){
fwrite(STDERR, ' additional info was: '.$this->_failinfo."\n");
$this->_failinfo = '';
}
}
/**
* reset failinfo
*/
function paintPass($message) {
parent::paintPass($message);
$this->_failinfo = '';
}
/**
* Paint exception faildetail to STDERR.
*/
function paintException($message) {
parent::paintException($message);
fwrite(STDERR, 'EXCEPTION' . $this->faildetail_separator .
$this->_paintTestFailDetail($message));
}
/**
* Handle failinfo message
*/
function paintSignal($type,$message) {
parent::paintSignal($type,$message);
if($type = 'failinfo') $this->_failinfo = $message;
}
/**
* Paint a footer with test case name, timestamp, counts of fails and
* exceptions.
*/
function paintFooter($test_name) {
$buffer = $this->getTestCaseProgress() . '/' .
$this->getTestCaseCount() . ' test cases complete: ';
if (0 < ($this->getFailCount() + $this->getExceptionCount())) {
$buffer .= $this->getPassCount() . " passes";
if (0 < $this->getFailCount()) {
$buffer .= ", " . $this->getFailCount() . " fails";
}
if (0 < $this->getExceptionCount()) {
$buffer .= ", " . $this->getExceptionCount() . " exceptions";
}
$buffer .= ".\n";
fwrite(STDOUT, $buffer);
exit(ST_FAILS_RETURN_CODE);
} else {
fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n");
}
}
}

View File

@ -1,519 +0,0 @@
<?php
/**
* base include file for SimpleTest
* @package SimpleTest
* @subpackage MockFunctions
* @version $Id: mock_objects.php,v 1.86 2005/09/10 23:01:56 lastcraft Exp $
*/
/**
* Generates a mock version of a function.
* Note that all public methods in this class should be called
* statically
* Note that you must call the restore method yourself, to remove
* a mock function implementation after associated tests are
* complete
* @package SimpleTest
* @subpackage MockFunctions
*/
class MockFunction {
/**
* Raises an error if you construct MockFunction
* @access private
*/
function MockFunction() {
trigger_error('MockFunction only provides static methods',
E_USER_ERROR);
}
/**
* Generates a mock function
* @param string $function Function name to mock
* @access public
* @return SimpleMockFunction
* @static
*/
function & generate($function) {
$mock = & MockFunction::_instance($function, TRUE);
$mock->deploy();
return $mock;
}
/**
* Removes the mock function implementation and restores
* the real implementation (if one existed)
* @TODO Would be good to have this called automatically
* @param string $function Function name
* @access public
* @static
*/
function restore($function) {
$mock = & MockFunction::_instance($function);
$mock->restore();
}
/**
* Fetch a singleton instance of SimpleMockFunction
* @param string $function Function name
* @param boolean $fresh Force a fresh instance
* @access private
* @static
*/
function &_instance($function, $fresh = FALSE) {
static $singleton = array();
$function = strtolower($function);
if ( $fresh ) {
if ( isset($singleton[$function]) ) {
unset($singleton[$function]);
}
}
if ( !isset($singleton[$function]) ) {
// TODO: case sensitivity issues
$class = $function."MockFunction";
MockFunction::_generateSubClass($class, $function);
$singleton[$function] = new $class($function);
}
return $singleton[$function];
}
/**
* Required for strict mode and SimpleMock
* @TODO Should perhaps be placed in SimpleFunctionGenerator
* @param string $class subclass name
* @param string $method method name
* @access private
* @static
*/
function _generateSubClass($class, $method) {
if ( class_exists($class) ) {
return;
}
$code = "class $class extends SimpleMockFunction {\n";
$code .= " function $method () {}\n";
$code .= "}\n";
eval($code);
}
/**
* Changes the default wildcard object.
* @param string $function Function name wildcard applies to
* @param mixed $wildcard Parameter matching wildcard.
* @access public
* @static
*/
function setWildcard($function, $wildcard) {
$mock = & MockFunction::_instance($function);
$mock->setWildcard($wildcard);
}
/**
* Fetches the call count of a function so far.
* @param string $function Function name called.
* @return Number of calls so far.
* @access public
* @static
*/
function getCallCount($function) {
$mock = & MockFunction::_instance($function);
return $mock->getCallCount($function);
}
/**
* Sets a return for a parameter list that will
* be passed by value for all calls to this function.
* @param string $function Function name.
* @param mixed $value Result of call passed by value.
* @param array $args List of parameters to match
* including wildcards.
* @access public
* @static
*/
function setReturnValue($function, $value, $args = false) {
$mock = & MockFunction::_instance($function);
$mock->setReturnValue($function, $value, $args);
}
/**
* Sets a return for a parameter list that will
* be passed by value only when the required call count
* is reached.
* @param integer $timing Number of calls in the future
* to which the result applies. If
* not set then all calls will return
* the value.
* @param string $function Function name.
* @param mixed $value Result of call passed by value.
* @param array $args List of parameters to match
* including wildcards.
* @access public
* @static
*/
function setReturnValueAt($timing, $function, $value, $args = false) {
$mock = & MockFunction::_instance($function);
$mock->setReturnValueAt($timing, $function, $value, $args);
}
/**
* Sets a return for a parameter list that will
* be passed by reference for all calls.
* @param string $function Function name.
* @param mixed $reference Result of the call will be this object.
* @param array $args List of parameters to match
* including wildcards.
* @access public
* @static
*/
function setReturnReference($function, &$reference, $args = false) {
$mock = & MockFunction::_instance($function);
$mock->setReturnReference($function, $reference, $args);
}
/**
* Sets a return for a parameter list that will
* be passed by value only when the required call count
* is reached.
* @param integer $timing Number of calls in the future
* to which the result applies. If
* not set then all calls will return
* the value.
* @param string $function Function name.
* @param mixed $reference Result of the call will be this object.
* @param array $args List of parameters to match
* including wildcards.
* @access public
* @static
*/
function setReturnReferenceAt($timing, $function, &$reference, $args = false) {
$mock = & MockFunction::_instance($function);
$mock->setReturnReferenceAt($timing, $function, $reference, $args);
}
/**
* Sets up an expected call with a set of
* expected parameters in that call. All
* calls will be compared to these expectations
* regardless of when the call is made.
* @param string $function Function call to test.
* @param array $args Expected parameters for the call
* including wildcards.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectArguments($function, $args, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectArguments($function, $args, $message);
}
/**
* Sets up an expected call with a set of
* expected parameters in that call. The
* expected call count will be adjusted if it
* is set too low to reach this call.
* @param integer $timing Number of calls in the future at
* which to test. Next call is 0.
* @param string $function Function call to test.
* @param array $args Expected parameters for the call
* including wildcards.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectArgumentsAt($timing, $function, $args, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectArgumentsAt($timing, $function, $args, $message);
}
/**
* Sets an expectation for the number of times
* a function will be called.
* @param string $function Function call to test.
* @param integer $count Number of times it should
* have been called at tally.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectCallCount($function, $count, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectCallCount($function, $count, $message);
}
/**
* Sets the number of times a function may be called
* before a test failure is triggered.
* @param string $function Function call to test.
* @param integer $count Most number of times it should
* have been called.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectMaximumCallCount($function, $count, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectMaximumCallCount($function, $count, $message);
}
/**
* Sets the minimum number of times the function must be called
* otherwise a test failure is triggered
* @param string $function Function call to test.
* @param integer $count Least number of times it should
* have been called.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectMinimumCallCount($function, $count, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectMinimumCallCount($function, $count, $message);
}
/**
* Convenience method for barring a function
* call.
* @param string $function Function call to ban.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectNever($function, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectNever($function, $message);
}
/**
* Convenience method for a single function
* call.
* @param string $function Function call to track.
* @param array $args Expected argument list or
* false for any arguments.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectOnce($function, $args = false, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectOnce($function, $args, $message);
}
/**
* Convenience method for requiring a function
* call.
* @param string $function Function call to track.
* @param array $args Expected argument list or
* false for any arguments.
* @param string $message Overridden message.
* @access public
* @static
*/
function expectAtLeastOnce($function, $args = false, $message = '%s') {
$mock = & MockFunction::_instance($function);
$mock->expectAtLeastOnce($function, $args, $message);
}
function atTestEnd($function) {
$mock = & MockFunction::_instance($function);
$mock->atTestEnd($function);
}
}
/**
* Represents a single, mocked function, tracking calls made to it
* @package SimpleTest
* @subpackage MockFunctions
*/
class SimpleMockFunction extends SimpleMock {
var $_is_mocked = FALSE;
var $_generator;
/**
* Sets up the mock, creating a generator depending on whether
* the function is already declared
* @param string $function Name of function being mocked
*/
function SimpleMockFunction($function) {
SimpleMock :: SimpleMock();
if ( function_exists($function) ) {
$this->_generator = new SimpleDeclaredFunctionGenerator($function);
} else {
$this->_generator = new SimpleUndeclaredFunctionGenerator($function);
}
}
/**
* Deploys the mock function implementation into PHP's function
* table, replacing any existing implementation
* @access public
*/
function deploy() {
if ( !$this->_is_mocked ) {
$this->_is_mocked = TRUE;
$this->_generator->deploy();
}
}
/**
* Restores the state of PHP's function table to that before
* the mock function was deployed. Removes the mock function
* implementation and restores any existing implementation of
* that function
* @access public
*/
function restore() {
if ( $this->_is_mocked ) {
$this->_is_mocked = FALSE;
$this->_generator->restore();
}
}
}
/**
* Base class for deploying and restoring from mock functions
* @package SimpleTest
* @subpackage MockFunctions
* @abstract
*/
class SimpleFunctionGenerator {
var $_function;
/**
* @TODO Validate the function name (as it's being used in eval)
* @TODO Add list of illegal functions (ones which must not be mocked
* as they will break SimpleTest, which uses them)
* @param string $function Name of function being mocked
*/
function SimpleFunctionGenerator($function) {
$this->_function = $function;
}
/**
* Generates the mock function implementation, using eval
* @access private
*/
function _generateMockFunction() {
$code = "function " . $this->_function . "() {\n";
$code .= " \$args = func_get_args();\n";
$code .= " \$mock = & MockFunction::_instance('".$this->_function."');\n";
$code .= " \$result = &\$mock->_invoke(\"".$this->_function."\", \$args);\n";
$code .= " return \$result;\n";
$code .= "}\n";
eval($code);
}
}
/**
* Mock function generator for functions which have already been declared
* @package SimpleTest
* @subpackage MockFunctions
*/
class SimpleDeclaredFunctionGenerator extends SimpleFunctionGenerator {
var $_tmp_function = NULL;
/**
* Invokes the _generateTmpFnFname
* @param string $function Name of function being mocked
*/
function SimpleDeclaredFunctionGenerator($function) {
SimpleFunctionGenerator::SimpleFunctionGenerator($function);
$this->_generateTmpFnFname();
}
/**
* Generates a temporary name for the declared function implementation
* which is will be renamed to while the mock function is in use
* @access private
*/
function _generateTmpFnFname() {
static $count = 1;
$this->_tmp_function = 'tmp_'.md5(time().$this->_function.$count);
$count++;
}
/**
* Deploys the mock function implementation
* @access public
*/
function deploy() {
runkit_function_rename(
$this->_function,
$this->_tmp_function
) or
trigger_error('Error archiving real function implementation',
E_USER_ERROR);
$this->_generateMockFunction();
}
/**
* Removes the mock function implementation and restores
* the previously declared implementation
* @access public
*/
function restore() {
runkit_function_remove($this->_function) or
trigger_error('Error removing mock function',
E_USER_ERROR);
runkit_function_rename(
$this->_tmp_function,
$this->_function
) or
trigger_error('Error restoring real function',
E_USER_ERROR);
}
}
/**
* Mock function generator for functions which have not
* already been declared
* @package SimpleTest
* @subpackage MockFunctions
*/
class SimpleUndeclaredFunctionGenerator extends SimpleFunctionGenerator {
/**
* Deploys the mock function implementation
* @access public
*/
function deploy() {
$this->_generateMockFunction();
}
/**
* Removes the mock function implementation
* @access public
*/
function restore() {
runkit_function_remove($this->_function) or
trigger_error('Error removing mock function',
E_USER_ERROR);
}
}

View File

@ -1,369 +0,0 @@
<?php
if(!defined("METAL_LIBRARY_XML_RSS_WRITER_CLASS"))
{
define("METAL_LIBRARY_XML_RSS_WRITER_CLASS",1);
/*
*
* Copyright <EFBFBD> (C) Manuel Lemos 2002
*
* @(#) $Id: rss_writer_class.php,v 1.5 2005/08/20 09:46:06 pachanga Exp $
*
*/
class rss_writer_class extends xml_writer_class
{
/*
* Protected variables
*
*/
var $root="";
var $channel="";
var $image="";
var $textinput="";
var $items=0;
var $itemsequence="";
/*
* Public variables
*
*/
var $specification="1.0";
var $about="";
var $rssnamespaces=array();
var $allownoitems=0;
var $generatedcomment="Generated by: http://www.phpclasses.org/rsswriter";
/*
* Protected functions
*
*/
Function addrssproperties(&$properties,$parent,&$required,&$optional,$scope)
{
$noattributes=array();
$required_properties=0;
Reset($properties);
$end=(GetType($property=Key($properties))!="string");
for(;!$end;)
{
if(IsSet($required[$property]))
{
if($required[$property])
{
$this->error=("required ".$scope." property \"".$property."\" is already set");
return 0;
}
$required[$property]=1;
$required_properties++;
}
else
{
if(IsSet($optional[$property]))
{
if($optional[$property])
{
$this->error=("optional ".$scope." property \"".$property."\" is already set");
return 0;
}
$optional[$property]=1;
}
else
{
if(GetType($colon=strpos($property,":",0))=="integer")
{
$namespace=substr($property,0,$colon);
if(!(!strcmp($namespace,"rdf") || IsSet($this->rssnamespaces[$namespace])))
$this->error=("the name space of property \"".$property."\" was not declared");
}
else
$this->error=("\"".$property."\" is not a supported ".$scope." property");
}
}
if(!($this->adddatatag($property,$noattributes,$properties[$property],$parent,$path)))
return 0;
Next($properties);
$end=(GetType($property=Key($properties))!="string");
}
if($required_properties<count($required))
{
Reset($required);
$end=(GetType($property=Key($required))!="string");
for(;!$end;)
{
if(!($required[$property]))
{
$this->error=("it was not specified the required ".$scope." property \"".$property."\"");
return 0;
}
Next($required);
$end=(GetType($property=Key($required))!="string");
}
}
return 1;
}
/*
* Public functions
*
*/
Function addchannel(&$properties)
{
if(strcmp($this->error,""))
return 0;
if(strcmp($this->channel,""))
{
$this->error="a channel was already added";
return 0;
}
$channel_attributes=array();
switch($this->specification)
{
case "0.9":
$root="rdf:RDF";
$attributes=array("xmlns:rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns"=>"http://my.netscape.com/rdf/simple/0.9/");
$required=array("description"=>0,"link"=>0,"title"=>0);
$optional=array();
break;
case "0.91":
$root="rss";
$attributes=array("version"=>$this->specification);
$required=array("description"=>0,"language"=>0,"link"=>0,"title"=>0);
$optional=array("copyright"=>0,"docs"=>0,"lastBuildDate"=>0,"managingEditor"=>0,"pubDate"=>0,"rating"=>0,"webMaster"=>0);
break;
case "1.0":
if(!strcmp($this->about,""))
{
$this->error="it was not specified the about URL attribute";
return 0;
}
$root="rdf:RDF";
$attributes=array("xmlns:rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns"=>"http://purl.org/rss/1.0/");
Reset($this->rssnamespaces);
$end=(GetType($namespace=Key($this->rssnamespaces))!="string");
for(;!$end;)
{
if(!strcmp($namespace,"rdf"))
{
$this->error="the rdf namespace is being redeclared";
return 0;
}
$attributes[("xmlns:".$namespace)]=$this->rssnamespaces[$namespace];
Next($this->rssnamespaces);
$end=(GetType($namespace=Key($this->rssnamespaces))!="string");
}
$channel_attributes=array("rdf:about"=>$this->about);
$required=array("description"=>0,"link"=>0,"title"=>0);
$optional=array();
break;
default:
$this->error="it was not specified a supported RSS specification version";
return 0;
}
$this->addtag($root,$attributes,"",$path,1);
$this->root=$path;
if(!($this->addtag("channel",$channel_attributes,$this->root,$path,1)))
return 0;
if(!($this->addrssproperties($properties,$path,$required,$optional,"channel")))
return 0;
$this->channel=$path;
return 1;
}
Function additem(&$properties)
{
if(strcmp($this->error,""))
return 0;
if(!strcmp($this->channel,""))
{
$this->error="the channel was not yet added";
return 0;
}
if(strcmp($this->textinput,""))
{
$this->error="items can not be added to the channel after defining the textinput";
return 0;
}
$attributes=array();
switch($this->specification)
{
case "0.9":
$parent=$this->root;
break;
case "0.91":
$parent=$this->channel;
break;
case "1.0":
if(IsSet($properties["link"]))
$attributes["rdf:about"]=$properties["link"];
$parent=$this->root;
break;
default:
$this->error="it was not specified a supported RSS specification version";
return 0;
}
if(!($this->addtag("item",$attributes,$parent,$path,1)))
return 0;
$required=array("link"=>0,"title"=>0);
$optional=array("description"=>0);
if(!($this->addrssproperties($properties,$path,$required,$optional,"item")))
return 0;
if(!strcmp($this->specification,"1.0"))
{
if(!strcmp($this->itemsequence,""))
{
$attributes=array();
if(!($this->addtag("items",$attributes,$this->channel,$path,1) && $this->addtag("rdf:Seq",$attributes,$path,$path,1)))
return 0;
$this->itemsequence=$path;
}
$attributes=array("rdf:resource"=>$properties["link"]);
if(!($this->addtag("rdf:li",$attributes,$this->itemsequence,$path,0)))
return 0;
}
$this->items++;
return 1;
}
Function addimage(&$properties)
{
if(strcmp($this->error,""))
return 0;
if(!strcmp($this->channel,""))
{
$this->error="the channel was not yet added";
return 0;
}
if(strcmp($this->image,""))
{
$this->error="the channel image was already associated";
return 0;
}
if($this->items!=0)
{
$this->error="the image can only be defined before adding the channel items";
return 0;
}
$attributes=array();
switch($this->specification)
{
case "0.9":
$parent=$this->root;
break;
case "0.91":
$parent=$this->channel;
break;
case "1.0":
if(IsSet($properties["url"]))
$attributes["rdf:about"]=$properties["url"];
$parent=$this->root;
break;
default:
$this->error="it was not specified a supported RSS specification version";
return 0;
}
if(!($this->addtag("image",$attributes,$parent,$path,1)))
return 0;
$this->image=$path;
$required=array("link"=>0,"title"=>0,"url"=>0);
$optional=array("description"=>0,"width"=>0,"height"=>0);
if(!($this->addrssproperties($properties,$this->image,$required,$optional,"image")))
return 0;
if(!strcmp($this->specification,"1.0"))
{
$attributes=array("rdf:resource"=>$properties["url"]);
return $this->addtag("image",$attributes,$this->channel,$path,0);
}
return 1;
}
Function addtextinput(&$properties)
{
if(strcmp($this->error,""))
return 0;
if(!strcmp($this->channel,""))
{
$this->error="the channel was not yet added";
return 0;
}
if(strcmp($this->textinput,""))
{
$this->error="the channel text input was already associated";
return 0;
}
if($this->items==0 && !$this->allownoitems)
{
$this->error="it were not specified any items before defining the channel text input";
return 0;
}
$attributes=array();
switch($this->specification)
{
case "0.9":
$parent=$this->root;
break;
case "0.91":
$parent=$this->channel;
break;
case "1.0":
if(IsSet($properties["link"]))
$attributes["rdf:about"]=$properties["link"];
$parent=$this->root;
break;
default:
$this->error="it was not specified a supported RSS specification version";
return 0;
}
if(!($this->addtag("textinput",$attributes,$parent,$path,1)))
return 0;
$this->textinput=$path;
$required=array("description"=>0,"link"=>0,"name"=>0,"title"=>0);
$optional=array();
if(!($this->addrssproperties($properties,$this->textinput,$required,$optional,"textinput")))
return 0;
if(!strcmp($this->specification,"1.0"))
{
$attributes=array("rdf:resource"=>$properties["link"]);
return $this->addtag("textinput",$attributes,$this->channel,$path,0);
}
return 1;
}
Function writerss(&$output)
{
if(strcmp($this->error,""))
return 0;
if(!strcmp($this->channel,""))
{
$this->error="it was not defined the RSS channel";
return 0;
}
if($this->items==0 && !$this->allownoitems)
{
$this->error="it were not defined any RSS channel items";
return 0;
}
switch($this->specification)
{
case "0.9":
$this->dtdtype="PUBLIC";
$this->dtddefinition="-//Netscape Communications//DTD RSS 0.9//EN";
$this->dtdurl="http://my.netscape.com/publish/formats/rss-0.9.dtd";
break;
case "0.91":
$this->dtdtype="PUBLIC";
$this->dtddefinition="-//Netscape Communications//DTD RSS 0.91//EN";
$this->dtdurl="http://my.netscape.com/publish/formats/rss-0.91.dtd";
break;
case "1.0":
$this->dtdtype="";
break;
default:
$this->error="it was not specified a supported RSS specification version";
return 0;
}
return $this->write($output);
}
};
}

View File

@ -1,579 +0,0 @@
<?php // -*- fill-column: 80; tab-width: 4; c-basic-offset: 4 -*-
/**
* Lots TODO here...
*/
define('TEST_GROUPS',realpath(dirname(__FILE__).'/../cases'));
define('TEST_CASES',realpath(dirname(__FILE__).'/../cases'));
define('TEST_PLUGINS',realpath(dirname(__FILE__).'/../../lib/plugins'));
// try to load runkit extension
if (!extension_loaded('runkit') && function_exists('dl')) {
if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
@dl('php_runkit.dll');
} else {
@dl('runkit.so');
}
}
class TestManager {
var $_testcase_extension = '.test.php';
var $_grouptest_extension = '.group.php';
function setup() {
$ini_file = realpath(dirname(__FILE__).'/../tests.ini');
if (! file_exists($ini_file)) {
trigger_error("Missing configuration file {$ini_file}",
E_USER_ERROR);
}
$config = parse_ini_file($ini_file);
foreach ($config as $key => $value) {
define($key, $value);
}
TestManager::_installSimpleTest();
list($version) = file(SIMPLE_TEST.'VERSION');
$version = trim($version);
if(!version_compare('1.0.1alpha',$version,'<')){
echo "At least SimpleTest Version 1.0.1alpha is required.";
echo " Yours is $version\n";
exit;
}
}
function _installSimpleTest() {
require_once SIMPLE_TEST . 'unit_tester.php';
require_once SIMPLE_TEST . 'web_tester.php';
require_once SIMPLE_TEST . 'mock_objects.php';
require_once 'web.inc.php';
require_once 'mock_functions.php';
}
function runAllTests(&$reporter) {
$manager = new TestManager();
$test_cases =& $manager->_getTestFileList();
$test = new GroupTest('All Tests');
foreach ($test_cases as $test_case) {
$test->addTestFile($test_case);
}
$test->run($reporter);
}
function runAllPluginTests(&$reporter) {
$manager = new TestManager();
$test_cases =& $manager->_getTestFileList(TEST_PLUGINS);
$test = new GroupTest('All Plugin Tests');
foreach ($test_cases as $test_case) {
$test->addTestFile($test_case);
}
$test->run($reporter);
}
function runTestCase($testcase_name, $test_case_directory, &$reporter) {
$manager = new TestManager();
$testcase_name = preg_replace('/[^a-zA-Z0-9_:]/','',$testcase_name);
$testcase_name = str_replace(':',DIRECTORY_SEPARATOR,$testcase_name);
$testcase_file = $test_case_directory . DIRECTORY_SEPARATOR .
strtolower($testcase_name) . $manager->_testcase_extension;
if (! file_exists($testcase_file)) {
trigger_error("Test case {$testcase_file} cannot be found",
E_USER_ERROR);
}
$test = new GroupTest("Individual test case: " . $testcase_name);
$test->addTestFile($testcase_file);
$test->run($reporter);
}
function runTestFile($testcase_file, &$reporter) {
$manager = new TestManager();
if (! file_exists($testcase_file)) {
trigger_error("Test case {$testcase_file} cannot be found",
E_USER_ERROR);
}
$test = new GroupTest("Individual test case: " . $testcase_file);
$test->addTestFile($testcase_file);
$test->run($reporter);
}
function runGroupTest($group_test_name, $group_test_directory, &$reporter) {
$manager = new TestManager();
$group_test_name = preg_replace('/[^a-zA-Z0-9_:]/','',$group_test_name);
$group_test_name = str_replace(':',DIRECTORY_SEPARATOR,$group_test_name);
$file_path = $group_test_directory . DIRECTORY_SEPARATOR .
strtolower($group_test_name) . $manager->_grouptest_extension;
if (! file_exists($file_path)) {
trigger_error("Group test {$group_test_name} cannot be found at {$file_path}",
E_USER_ERROR);
}
require_once $file_path;
$test = new GroupTest($group_test_name . ' group test');
foreach ($manager->_getGroupTestClassNames($file_path) as $group_test) {
$test->addTestCase(new $group_test());
}
$test->run($reporter);
}
function addTestCasesFromDirectory(&$group_test, $directory = '.') {
$manager = new TestManager();
$test_cases =& $manager->_getTestFileList($directory);
foreach ($test_cases as $test_case) {
$group_test->addTestFile($test_case);
}
}
function &getTestCaseList($directory = '.') {
$manager = new TestManager();
return $manager->_getTestCaseList($directory);
}
function &_getTestCaseList($directory = '.') {
$file_list =& $this->_getTestFileList($directory);
$testcases = array();
foreach ($file_list as $testcase_file) {
$case = str_replace($this->_testcase_extension, '',$testcase_file);
$case = str_replace(TEST_GROUPS . DIRECTORY_SEPARATOR, '', $case);
$case = str_replace(TEST_PLUGINS . DIRECTORY_SEPARATOR, '', $case);
$case = str_replace(DIRECTORY_SEPARATOR, ':', $case);
$testcases[$testcase_file] = $case;
}
return $testcases;
}
function &_getTestFileList($directory = '.') {
return $this->_getRecursiveFileList($directory,
array(&$this, '_isTestCaseFile'));
}
function &getPluginTestCaseList($directory = '.') {
$manager = new TestManager();
return $manager->_getTestCaseList($directory);
}
function &getPluginGroupTestList($directory = '.') {
$manager = new TestManager();
return $manager->_getTestGroupList($directory);
}
function &getGroupTestList($directory = '.') {
$manager = new TestManager();
return $manager->_getTestGroupList($directory);
}
function &_getTestGroupFileList($directory = '.') {
return $this->_getRecursiveFileList($directory,
array(&$this, '_isTestGroupFile'));
}
function &_getTestGroupList($directory = '.') {
$file_list =& $this->_getTestGroupFileList($directory);
$grouptests = array();
foreach ($file_list as $grouptest_file) {
$group = str_replace($this->_grouptest_extension, '',$grouptest_file);
$group = str_replace(TEST_GROUPS . DIRECTORY_SEPARATOR, '', $group);
$group = str_replace(TEST_PLUGINS . DIRECTORY_SEPARATOR, '', $group);
$group = str_replace(DIRECTORY_SEPARATOR, ':', $group);
$grouptests[$grouptest_file] = $group;
}
sort($grouptests);
return $grouptests;
}
function &_getGroupTestClassNames($grouptest_file) {
$file = implode("\n", file($grouptest_file));
preg_match("~lass\s+?(.*)\s+?extends .*?GroupTest~", $file, $matches);
if (! empty($matches)) {
unset($matches[0]);
return $matches;
} else {
return array();
}
}
function &_getRecursiveFileList($directory = '.', $file_test_function) {
$dh = opendir($directory);
if (! is_resource($dh)) {
trigger_error("Couldn't open {$directory}", E_USER_ERROR);
}
$file_list = array();
while ($file = readdir($dh)) {
$file_path = $directory . DIRECTORY_SEPARATOR . $file;
if (0 === strpos($file, '.')) continue;
if (is_dir($file_path)) {
$file_list =
array_merge($file_list,
$this->_getRecursiveFileList($file_path,
$file_test_function));
}
if ($file_test_function[0]->$file_test_function[1]($file)) {
$file_list[] = $file_path;
}
}
closedir($dh);
return $file_list;
}
function _isTestCaseFile($file) {
return $this->_hasExpectedExtension($file, $this->_testcase_extension);
}
function _isTestGroupFile($file) {
return $this->_hasExpectedExtension($file, $this->_grouptest_extension);
}
function _hasExpectedExtension($file, $extension) {
return $extension ==
strtolower(substr($file, (0 - strlen($extension))));
}
}
/**
* @package WACT_TESTS
*/
class CLITestManager extends TestManager {
function &getGroupTestList($directory = '.') {
$manager = new CLITestManager();
$group_tests =& $manager->_getTestGroupList($directory);
$buffer = "Available grouptests:\n";
foreach ($group_tests as $group_test) {
$buffer .= " " . $group_test . "\n";
}
return $buffer . "\n";
}
function &getTestCaseList($directory = '.') {
$manager = new CLITestManager();
$test_cases =& $manager->_getTestCaseList($directory);
$buffer = "Available test cases:\n";
foreach ($test_cases as $test_case) {
$buffer .= " " . $test_case . "\n";
}
return $buffer . "\n";
}
function &getPluginTestCaseList($directory = '.') {
$manager = new CLITestManager();
$test_cases =& $manager->_getTestCaseList($directory);
$buffer = "Available test cases:\n";
foreach ($test_cases as $test_case) {
$buffer .= " " . $test_case . "\n";
}
return $buffer . "\n";
}
function &getPluginGroupTestList($directory = '.') {
$manager = new CLITestManager();
$test_cases =& $manager->_getTestGroupList($directory);
$buffer = "Available test cases:\n";
foreach ($test_cases as $test_case) {
$buffer .= " " . $test_case . "\n";
}
return $buffer . "\n";
}
}
class HTMLTestManager extends TestManager {
var $_url;
function HTMLTestManager() {
$this->_url = $_SERVER['PHP_SELF'];
}
function getBaseURL() {
return $this->_url;
}
function &getGroupTestList($directory = '.') {
$manager = new HTMLTestManager();
$group_tests =& $manager->_getTestGroupList($directory);
if (1 > count($group_tests)) {
return "<p>No test groups set up!</p>";
}
$buffer = "<p>Available test groups:</p>\n<ul>";
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group=all'>All tests</a></li>\n";
foreach ($group_tests as $group_test) {
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$group_test}'>" .
$group_test . "</a></li>\n";
}
$buffer .= "</ul>\n";
return $buffer;
}
function &getTestCaseList($directory = '.') {
$manager = new HTMLTestManager();
$testcases =& $manager->_getTestCaseList($directory);
if (1 > count($testcases)) {
return "<p>No test cases set up!</p>";
}
$buffer = "<p>Available test cases:</p>\n<ul>";
foreach ($testcases as $testcase) {
$buffer .= "<li><a href='" . $manager->getBaseURL() .
"?case=" . urlencode($testcase) . "'>" .
$testcase . "</a></li>\n";
}
$buffer .= "</ul>\n";
return $buffer;
}
function &getPluginTestCaseList($directory = '.') {
$manager = new HTMLTestManager();
$testcases =& $manager->_getTestCaseList($directory);
if (1 > count($testcases)) {
return "<p>No plugin test cases set up!</p>";
}
$buffer = "<p>Available plugin test cases:</p>\n<ul>";
foreach ($testcases as $testcase) {
$buffer .= "<li><a href='" . $manager->getBaseURL() .
"?plugin_case=" . urlencode($testcase) . "'>" .
$testcase . "</a></li>\n";
}
$buffer .= "</ul>\n";
return $buffer;
}
function &getPluginGroupTestList($directory = '.') {
$manager = new HTMLTestManager();
$group_tests =& $manager->_getTestGroupList($directory);
if (1 > count($group_tests)) {
return "<p>No plugin test groups set up!</p>";
}
$buffer = "<p>Available plugin groups:</p>\n<ul>";
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?plugin_group=all'>All tests</a></li>\n";
foreach ($group_tests as $group_test) {
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?plugin_group={$group_test}'>" .
$group_test . "</a></li>\n";
}
$buffer .= "</ul>\n";
return $buffer;
}
}
/**
* @package WACT_TESTS
*/
class XMLTestManager extends HTMLTestManager {
function XMLTestManager() {
parent::HTMLTestManager();
}
function &getGroupTestList($directory = '.') {
$manager = new XMLTestManager();
$group_tests =& $manager->_getTestGroupList($directory);
$rss = & $manager->_getRssWriter();
if (1 > count($group_tests)) {
$rss->writeRss($output);
return $output;
}
$properties["title"]="All Tests";
$properties["description"]="All Tests";
$properties["link"]='http://'.$_SERVER['SERVER_NAME'].
$manager->getBaseURL()."?group=all&output=xml";
$rss->additem($properties);
foreach ($group_tests as $group_test) {
$properties["title"]=$group_test;
$properties["description"]=$group_test;
$properties["link"]='http://'.$_SERVER['SERVER_NAME'].
$manager->getBaseURL().
"?group={$group_test}&output=xml";
$rss->additem($properties);
}
if ( !$rss->writeRss($output) ) {
die ( $rss->error );
}
return $output;
}
function &getTestCaseList($directory = '.') {
$manager = new XMLTestManager();
$testcases =& $manager->_getTestCaseList($directory);
$rss = & $manager->_getRssWriter();
if (1 > count($testcases)) {
$rss->writeRss($output);
return $output;
}
foreach ($testcases as $testfile => $testcase) {
$properties["title"]=$testcase;
$properties["description"]=$testcase;
$properties["link"]='http://'.$_SERVER['SERVER_NAME'].
$manager->getBaseURL()."?case=" .
urlencode($testcase) . "&output=xml";
// Comment this out for performance?
$properties["dc:date"]=gmdate("Y-m-d\TH:i:sO",filemtime($testfile));
$rss->additem($properties);
}
$rss->writeRss($output);
return $output;
}
function &_getRssWriter() {
$url = 'http://'.$_SERVER['SERVER_NAME'].str_replace('index.php','',$_SERVER['PHP_SELF']);
require_once TEST_ROOT . '/lib/xml_writer_class.php';
require_once TEST_ROOT . '/lib/rss_writer_class.php';
$rss_writer_object= new rss_writer_class();
$rss_writer_object->specification="1.0";
$rss_writer_object->about=$url."index.php?output=xml";
$rss_writer_object->stylesheet=$url."rss2html.xsl";
$rss_writer_object->rssnamespaces["dc"]="http://purl.org/dc/elements/1.1/";
// Channel Properties
$properties=array();
$properties["title"]="Dokuwiki Unit Test Cases";
$properties["description"]="Dokuwiki Unit Test Cases";
$properties["link"]="http://wiki.splitbrain.org/";
$properties["dc:date"]=gmdate("Y-m-d\TH:i:sO");
$rss_writer_object->addchannel($properties);
// Logo like this (if we had one)
/*
$properties=array();
$properties["link"]="http://www.phpclasses.org/";
$properties["title"]="PHP Classes repository logo";
$properties["description"]="Repository of components and other resources for PHP developers";
$rss_writer_object->addimage($properties);
*/
return $rss_writer_object;
}
}
/**
* @package WACT_TESTS
*/
class RemoteTestManager extends TestManager {
function RemoteTestManager() {
RemoteTestManager::_installSimpleTest();
}
function _installSimpleTest() {
require_once SIMPLE_TEST . 'remote.php';
}
function runAllTests(&$reporter, $url = FALSE) {
$groups = RemoteTestManager::getGroupTestList($url);
$T = new RemoteTestCase($groups['All Tests']);
$T->run($reporter);
}
function runTestUrl($case_url,& $reporter, $url = FALSE) {
RemoteTestManager::_installSimpleTest();
$T = new RemoteTestCase($case_url);
$T->run($reporter);
}
function runTestCase($case_id,& $reporter, $url = FALSE) {
$cases = RemoteTestManager::getTestCaseList($url);
if ( !array_key_exists($case_id, $cases) ) {
trigger_error("Unknown test id $case_id\n",E_USER_ERROR);
}
$T = new RemoteTestCase($cases[$case_id]);
$T->run($reporter);
}
function runGroupTest($group_name, &$reporter, $url = FALSE) {
$groups = RemoteTestManager::getGroupTestList($url);
if ( !array_key_exists($group_name, $groups) ) {
trigger_error("Unknown group $group_name\n",E_USER_ERROR);
}
$T = new RemoteTestCase($groups[$group_name]);
$T->run($reporter);
}
function & getGroupTestList($url = FALSE) {
if ( !$url ) {
$url = REMOTE_TEST_URL;
}
$url .= '?output=xml';
$manager = new RemoteTestManager();
$rss = & $manager->_getRssReader($url);
$groupList = array();
foreach ($rss->getItems() as $item) {
$groupList[$item['title']] = $item['link'];
}
return $groupList;
}
function &getTestCaseList($url = FALSE) {
if ( !$url ) {
$url = REMOTE_TEST_URL;
}
$url .= '?show=cases&output=xml';
$manager = new RemoteTestManager();
$rss = & $manager->_getRssReader($url);
$caseList = array();
foreach ($rss->getItems() as $item) {
$caseList[$item['title']] = $item['link'];
}
return $caseList;
}
function &_getRssReader($url) {
require_once "XML/RSS.php";
$rss_reader = new XML_RSS($url);
$status = $rss_reader->parse();
if (PEAR::isError($status) ) {
trigger_error($status->getMessage(),E_USER_WARNING);
}
return $rss_reader;
}
}

View File

@ -1,5 +0,0 @@
<?php
class Doku_UnitTestCase extends UnitTestCase {
}
class Doku_GroupTest extends GroupTest {
}

View File

@ -1,47 +0,0 @@
<?php
/**
* @package WACT_TESTS
* @version $Id: web.inc.php,v 1.6 2005/08/20 09:46:06 pachanga Exp $
*/
SimpleTestOptions::ignore('DWWebTestCase');
class DWWebTestCase extends WebTestCase {
function assertNormalPage() {
$this->assertResponse(array(200));
$this->assertNoUnwantedPattern('/Warning:/i');
$this->assertNoUnwantedPattern('/Error:/i');
$this->assertNoUnwantedPattern('/Fatal error/i');
}
function assertWantedLiteral($str) {
$this->assertWantedPattern('/' . preg_quote($str, '/'). '/');
}
function assertNoUnWantedLiteral($str) {
$this->assertNoUnWantedPattern('/' . preg_quote($str, '/'). '/');
}
function &_fileToPattern($file) {
$file_as_array = file($file);
$pattern = '#^';
foreach ($file_as_array as $line) {
/* strip trailing newline */
if ($line[strlen($line) - 1] == "\n") {
$line = substr($line, 0, strlen($line) - 1);
}
$line = preg_quote($line, '#');
/* replace paths with wildcard */
$line = preg_replace("#'/[^']*#", "'.*", $line);
$pattern .= $line . '\n';
}
/* strip final newline */
$pattern = substr($pattern, 0, strlen($pattern) - 2);
$pattern .= '$#i';
return $pattern;
}
}

View File

@ -1,292 +0,0 @@
<?php
if(!defined("METAL_LIBRARY_XML_XML_WRITER_CLASS"))
{
define("METAL_LIBRARY_XML_XML_WRITER_CLASS",1);
/*
*
* Copyright <EFBFBD> (C) Manuel Lemos 2001-2002
*
* @(#) $Id: xml_writer_class.php,v 1.5 2005/08/20 09:46:06 pachanga Exp $
*
*/
class xml_writer_class
{
/*
* Protected variables
*
*/
var $structure=array();
var $nodes=array();
/*
* Public variables
*
*/
var $stylesheet="";
var $stylesheettype="text/xsl";
var $dtdtype="";
var $dtddefinition="";
var $dtdurl="";
var $outputencoding="utf-8";
var $inputencoding="iso-8859-1";
var $linebreak="\n";
var $indenttext=" ";
var $generatedcomment="Generated by: http://www.phpclasses.org/xmlwriter";
var $error="";
/*
* Protected functions
*
*/
Function escapedata($data)
{
$position=0;
$length=strlen($data);
$escapeddata="";
for(;$position<$length;)
{
$character=substr($data,$position,1);
$code=Ord($character);
switch($code)
{
case 34:
$character="&quot;";
break;
case 38:
$character="&amp;";
break;
case 39:
$character="&apos;";
break;
case 60:
$character="&lt;";
break;
case 62:
$character="&gt;";
break;
default:
if($code<32)
$character=("&#".strval($code).";");
break;
}
$escapeddata.=$character;
$position++;
}
return $escapeddata;
}
Function encodedata($data,&$encodeddata)
{
if(!strcmp($this->inputencoding,$this->outputencoding))
$encodeddata=$this->escapedata($data);
else
{
switch(strtolower($this->outputencoding))
{
case "utf-8":
if(!strcmp(strtolower($this->inputencoding),"iso-8859-1"))
{
$encoded_data=utf8_encode($this->escapedata($data));
$encodeddata=$encoded_data;
}
else
{
$this->error=("can not encode iso-8859-1 data in ".$this->outputencoding);
return 0;
}
break;
case "iso-8859-1":
if(!strcmp(strtolower($this->inputencoding),"utf-8"))
{
$decoded=utf8_decode($data);
$encodeddata=$this->escapedata($decoded);
}
else
{
$this->error=("can not encode utf-8 data in ".$this->outputencoding);
return 0;
}
break;
default:
$this->error=("can not encode data in ".$this->inputencoding);
return 0;
}
}
return 1;
}
Function writetag(&$output,$path,$indent)
{
$tag=$this->structure[$path]["Tag"];
$output.=("<".$tag);
$attributecount=count($this->structure[$path]["Attributes"]);
if($attributecount>0)
{
$attributes=$this->structure[$path]["Attributes"];
Reset($attributes);
$end=(GetType($key=Key($attributes))!="string");
for(;!$end;)
{
$output.=(" ".$key."=\"".$attributes[$key]."\"");
Next($attributes);
$end=(GetType($key=Key($attributes))!="string");
}
}
$elements=$this->structure[$path]["Elements"];
if($elements>0)
{
$output.=">";
$doindent=$this->structure[$path]["Indent"];
$elementindent=(($doindent) ? $this->linebreak.$indent.$this->indenttext : "");
$element=0;
for(;$element<$elements;)
{
$elementpath=($path.",".strval($element));
$output.=$elementindent;
if(IsSet($this->nodes[$elementpath]))
{
if(!($this->writetag($output,$elementpath,$indent.$this->indenttext)))
return 0;
}
else
$output.=$this->structure[$elementpath];
$element++;
}
$output.=((($doindent) ? $this->linebreak.$indent : "")."</".$tag.">");
}
else
$output.="/>";
return 1;
}
/*
* Public functions
*
*/
Function write(&$output)
{
if(strcmp($this->error,""))
return 0;
if(!(IsSet($this->structure["0"])))
{
$this->error="XML document structure is empty";
return 0;
}
$output=("<?xml version=\"1.0\" encoding=\"".$this->outputencoding."\"?>".$this->linebreak);
if(strcmp($this->dtdtype,""))
{
$output.=("<!DOCTYPE ".$this->structure["0"]["Tag"]." ");
switch($this->dtdtype)
{
case "INTERNAL":
if(!strcmp($this->dtddefinition,""))
{
$this->error="it was not specified a valid internal DTD definition";
return 0;
}
$output.=("[".$this->linebreak.$this->dtddefinition.$this->linebreak."]");
break;
case "SYSTEM":
if(!strcmp($this->dtdurl,""))
{
$this->error="it was not specified a valid system DTD url";
return 0;
}
$output.="SYSTEM";
if(strcmp($this->dtddefinition,""))
$output.=(" \"".$this->dtddefinition."\"");
$output.=(" \"".$this->dtdurl."\"");
break;
case "PUBLIC":
if(!strcmp($this->dtddefinition,""))
{
$this->error="it was not specified a valid public DTD definition";
return 0;
}
$output.=("PUBLIC \"".$this->dtddefinition."\"");
if(strcmp($this->dtdurl,""))
$output.=(" \"".$this->dtdurl."\"");
break;
default:
$this->error="it was not specified a valid DTD type";
return 0;
}
$output.=(">".$this->linebreak);
}
if(strcmp($this->stylesheet,""))
{
if(!strcmp($this->stylesheettype,""))
{
$this->error="it was not specified a valid stylesheet type";
return 0;
}
$output.=("<?xml-stylesheet type=\"".$this->stylesheettype."\" href=\"".$this->stylesheet."\"?>".$this->linebreak);
}
if(strcmp($this->generatedcomment,""))
$output.=("<!-- ".$this->generatedcomment." -->".$this->linebreak);
return $this->writetag($output,"0","");
}
Function addtag($tag,&$attributes,$parent,&$path,$indent)
{
if(strcmp($this->error,""))
return 0;
$path=((!strcmp($parent,"")) ? "0" : ($parent.",".strval($this->structure[$parent]["Elements"])));
if(IsSet($this->structure[$path]))
{
$this->error=("tag with path ".$path." is already defined");
return 0;
}
$encodedattributes=array();
Reset($attributes);
$end=(GetType($attribute_name=Key($attributes))!="string");
for(;!$end;)
{
$encodedattributes[$attribute_name]="";
if(!($this->encodedata($attributes[$attribute_name],$encoded_data)))
return 0;
$encodedattributes[$attribute_name]=$encoded_data;
Next($attributes);
$end=(GetType($attribute_name=Key($attributes))!="string");
}
$this->structure[$path]=array(
"Tag"=>$tag,
"Attributes"=>$encodedattributes,
"Elements"=>0,
"Indent"=>$indent
);
$this->nodes[$path]=1;
if(strcmp($parent,""))
$this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1);
return 1;
}
Function adddata($data,$parent,&$path)
{
if(strcmp($this->error,""))
return 0;
if(!(IsSet($this->structure[$parent])))
{
$this->error=("the parent tag path".$path."is not defined");
return 0;
}
if(!strcmp($data,""))
return 1;
$path=($parent.",".strval($this->structure[$parent]["Elements"]));
if(!($this->encodedata($data,$encoded_data)))
return 0;
$this->structure[$path]=$encoded_data;
$this->structure[$parent]["Elements"]=($this->structure[$parent]["Elements"]+1);
return 1;
}
Function adddatatag($tag,&$attributes,$data,$parent,&$path)
{
return $this->addtag($tag,$attributes,$parent,$path,0) && $this->adddata($data,$path,$datapath);
}
};
}

26
_test/phpunit.xml Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="bootstrap.php"
convertNoticesToExceptions="false">
<testsuites>
<testsuite name="DokuWiki Tests">
<directory suffix=".test.php">tests/</directory>
</testsuite>
<testsuite name="Plugin Tests">
<directory suffix=".test.php">../lib/plugins/*/_test</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">../</directory>
<exclude>
<directory suffix=".php">../_cs/</directory>
<directory suffix=".php">../_test/</directory>
<directory suffix=".php">../lib/plugins/*/_test/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

View File

@ -1,163 +0,0 @@
#!/usr/bin/php -q
<?php
ini_set('memory_limit','128M');
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
require_once 'lib/testmanager.php';
TestManager::setup();
function usage() {
$usage = <<<EOD
Usage: ./remotetests.php [OPTION]...
Run the Dokuwiki unit tests remotely executing tests over HTTP and delivering
results to the command line. If ALL of the test cases pass a count of
total passes is printed on STDOUT. If ANY of the test cases fail (or raise
errors) details are printed on STDERR and this script returns a non-zero
exit code.
-c --case=NAME specify a test case by it's ID (see -i for list)
-f --caseurl=NAME specify a test case file (full or relative path)
-g --group=NAME specify a grouptest. If no grouptest is
specified, all test cases will be run.
-i --caselist list individual test cases by their ID
-l --grouplist list available grouptests
-s, --separator=SEP set the character(s) used to separate fail
details to SEP
-p, --path path to SimpleTest installation
-h, --help display this help and exit
-u --url=TEST_URL specify remote server test url (w. index.php)
EOD;
echo $usage;
exit(0);
}
/* default test options */
$opt_separator = '->';
$opt_caselist = FALSE;
$opt_grouplist = FALSE;
$opt_caseid = FALSE;
$opt_caseurl = FALSE;
$opt_groupfile = FALSE;
$opt_url = FALSE;
include_once(DOKU_INC.'inc/cliopts.php');
$short_opts = "c:f:g:hils:p:u:";
$long_opts = array("case=","caselist","help", "caseurl=", "group=", "grouplist", "separator=", "path=","url=");
$OPTS = Doku_Cli_Opts::getOptions(__FILE__,$short_opts,$long_opts);
if ( $OPTS->isError() ) {
fwrite( STDERR, $OPTS->getMessage() . "\n");
usage($available_grouptests);
exit(1);
}
foreach ($OPTS->options as $key => $val) {
switch ($key) {
case 'c':
case 'case':
$opt_caseid = $val;
break;
case 'h':
case 'help':
usage();
break;
case 'f':
case 'caseurl':
$opt_caseurl = $val;
break;
case 'g':
case 'group':
$opt_groupfile = $val;
break;
case 'i':
case 'caselist':
$opt_caselist = TRUE;
break;
case 'l':
case 'grouplist':
$opt_grouplist = TRUE;
break;
case 's':
case 'separator':
$opt_separator = $val;
break;
case 'p':
case 'path':
if (file_exists($val)) {
define('SIMPLE_TEST', $val);
}
break;
case 'u':
case '--url':
$opt_url = $val;
break;
}
}
if ( ! $opt_url ) {
if ( !defined('REMOTE_TEST_URL') ) {
fwrite( STDERR, "No test URL defined. Either modify tests.ini or use -u option\n");
exit(1);
} else {
$opt_url = REMOTE_TEST_URL;
}
}
if (!@include_once SIMPLE_TEST . 'reporter.php') {
if ( defined(SIMPLE_TEST) ) {
fwrite( STDERR, "Where's Simple Test ?!? Not at ".SIMPLE_TEST." \n");
} else {
fwrite( STDERR, "Where's Simple Test ?!? SIMPLE_TEST not even defined!\n");
}
exit(1);
}
require_once 'lib/cli_reporter.php';
/* list grouptests */
if ($opt_grouplist) {
$groups = RemoteTestManager::getGroupTestList($opt_url);
fwrite( STDOUT, "Available grouptests:\n");
foreach ( array_keys($groups) as $group ) {
fwrite( STDOUT, $group."\n");
}
}
/* list test cases */
if ($opt_caselist) {
$cases = RemoteTestManager::getTestCaseList($opt_url);
fwrite( STDOUT, "Available tests tests:\n");
foreach ( array_keys($cases) as $case ) {
fwrite( STDOUT, $case."\n");
}
}
/* exit if we've displayed a list */
if ( $opt_grouplist || $opt_caselist ) {
exit(0);
}
/* run a test case given it's URL */
if ($opt_caseurl) {
RemoteTestManager::runTestUrl($opt_caseurl, new CLIReporter($opt_separator), $opt_url);
exit(0);
}
/* run a test case by id*/
if ($opt_caseid) {
RemoteTestManager::runTestCase($opt_caseid, new CLIReporter($opt_separator), $opt_url);
exit(0);
}
/* run a grouptest */
if ($opt_groupfile) {
RemoteTestManager::runGroupTest(
$opt_groupfile, new CLIReporter($opt_separator), $opt_url
);
exit(0);
}
/* run all tests */
RemoteTestManager::runAllTests(new CLIReporter($opt_separator), $opt_url);
exit(0);
?>

View File

@ -1,110 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
@(#) $Id: rss2html.xsl,v 1.1 2004/06/11 22:00:57 harryf Exp $
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rss="http://purl.org/rss/1.0/" xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
div.channel-title { font-family: sans-serif, arial, helvetica }
</style>
<style type="text/css">
div.image { font-family: sans-serif, arial, helvetica }
</style>
<style type="text/css">
div.image-description { font-family: sans-serif, arial, helvetica }
</style>
<style type="text/css">
div.item-title { font-family: sans-serif, arial, helvetica }
</style>
<style type="text/css">
div.item-description { font-family: sans-serif, arial, helvetica }
</style>
<style type="text/css">
div.textinput-title { font-family: sans-serif, arial, helvetica }
</style>
<style type="text/css">
div.textinput-form { font-family: sans-serif, arial, helvetica }
</style>
<title>
<xsl:for-each select="rdf:RDF/rss:channel">
<xsl:value-of select="rss:description"/>
</xsl:for-each>
</title>
</head>
<body>
<xsl:for-each select="rdf:RDF/rss:image">
<center><div class="image">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="src"><xsl:value-of select="rss:url"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="rss:title"/></xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
</xsl:element>
</xsl:element>
</div></center>
<center><div class="image-description">
<xsl:value-of select="rss:description"/>
</div></center>
</xsl:for-each>
<xsl:for-each select="rdf:RDF/rss:channel">
<center><div class="channel-title">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
<xsl:value-of select="rss:title"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="dc:date"/>
<xsl:text>)</xsl:text>
</xsl:element>
</div></center>
</xsl:for-each>
<ul>
<hr />
<xsl:for-each select="rdf:RDF/rss:item">
<div class="item-title"><li>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="rss:link"/></xsl:attribute>
<xsl:value-of select="rss:title"/>
</xsl:element>
<xsl:text> (</xsl:text>
<xsl:value-of select="dc:date"/>
<xsl:text>)</xsl:text>
</li></div>
<div class="item-description"><xsl:value-of select="rss:description"/></div>
<hr />
</xsl:for-each>
</ul>
<xsl:for-each select="rdf:RDF/rss:textinput">
<center><b><div class="textinput-title"><xsl:value-of select="rss:description"/></div></b></center>
<xsl:element name="form">
<xsl:attribute name="action"><xsl:value-of select="rss:link"/></xsl:attribute>
<xsl:attribute name="method">POST</xsl:attribute>
<center><div class="textinput-form">
<xsl:element name="input">
<xsl:attribute name="name"><xsl:value-of select="rss:name"/></xsl:attribute>
<xsl:attribute name="type">text</xsl:attribute>
</xsl:element>
<xsl:text> </xsl:text>
<xsl:element name="input">
<xsl:attribute name="value"><xsl:value-of select="rss:title"/></xsl:attribute>
<xsl:attribute name="type">submit</xsl:attribute>
</xsl:element>
</div></center>
</xsl:element>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@ -1,187 +0,0 @@
#!/usr/bin/php -q
<?php
ini_set('memory_limit','128M');
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
define('DOKU_UNITTEST',true);
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC.'inc/events.php');
define('TEST_ROOT', dirname(__FILE__));
define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/');
require_once 'lib/testmanager.php';
TestManager::setup();
function usage() {
$usage = <<<EOD
Usage: ./runtests.php [OPTION]...
Run the Dokuwiki unit tests. If ALL of the test cases pass a count of total
passes is printed on STDOUT. If ANY of the test cases fail (or raise
errors) details are printed on STDERR and this script returns a non-zero
exit code.
-c --case=NAME specify a test case by it's ID (see -i for list)
--pcase=NAME specify a plugin test case by it's ID
(see --plugincaselist for list)
-f --file=NAME specify a test case file (full or relative path)
-g --group=NAME specify a grouptest. If no grouptest is
specified, all test cases will be run.
--pgroup=NAME specify a plugin grouptest. If no grouptest is
specified, all test cases will be run.
-i --caselist list individual test cases by their ID
-l --grouplist list available grouptests
--plugincaselist list all individual plugin test cases by their ID
--plugingrouplist list avialable plugin grouptests
-s, --separator=SEP set the character(s) used to separate fail
details to SEP
-p, --path path to SimpleTest installation
-h, --help display this help and exit
EOD;
echo $usage;
exit(0);
}
/* test options */
$opt_separator = '->';
$opt_caselist = FALSE;
$opt_grouplist = FALSE;
$opt_plugincaselist = FALSE;
$opt_plugingrouplist = FALSE;
$opt_caseid = FALSE;
$top_plugincaseid = FALSE;
$opt_casefile = FALSE;
$opt_groupfile = FALSE;
$opt_plugingroupfile = FALSE;
include_once(DOKU_INC.'inc/cliopts.php');
$short_opts = "c:f:g:hils:p:";
$long_opts = array("case=","pcase=","caselist","help", "file=", "group=", "pgroup=", "grouplist", "plugincaselist", "plugingrouplist", "separator=", "path=");
$OPTS = Doku_Cli_Opts::getOptions(__FILE__,$short_opts,$long_opts);
if ( $OPTS->isError() ) {
fwrite( STDERR, $OPTS->getMessage() . "\n");
usage($available_grouptests);
exit(1);
}
foreach ($OPTS->options as $key => $val) {
switch ($key) {
case 'c':
case 'case':
$opt_caseid = $val;
break;
case 'pcase':
$opt_plugincaseid = $val;
break;
case 'h':
case 'help':
usage();
break;
case 'f':
case 'file':
$opt_casefile = $val;
break;
case 'g':
case 'group':
$opt_groupfile = $val;
break;
case 'pgroup':
$opt_plugingroupfile = $val;
break;
case 'i':
case 'caselist':
$opt_caselist = TRUE;
break;
case 'l':
case 'grouplist':
$opt_grouplist = TRUE;
break;
case 'plugincaselist':
$opt_plugincaselist = TRUE;
break;
case 'plugingrouplist':
$opt_plugingrouplist = TRUE;
break;
case 's':
case 'separator':
$opt_separator = $val;
break;
case 'p':
case 'path':
if (file_exists($val)) {
define('SIMPLE_TEST', $val);
}
break;
}
}
if (!@include_once SIMPLE_TEST . 'reporter.php') {
die("Where's Simple Test ?!? Not at ".SIMPLE_TEST);
}
require_once 'lib/cli_reporter.php';
/* list grouptests */
if ($opt_grouplist) {
echo CLITestManager::getGroupTestList(TEST_GROUPS);
}
/* list test cases */
if ($opt_caselist) {
echo CLITestManager::getTestCaseList(TEST_CASES);
}
/* list plugin test cases */
if ($opt_plugincaselist) {
echo CLITestManager::getPluginTestCaseList(TEST_PLUGINS);
}
/* list plugin group tests */
if($opt_plugingrouplist) {
echo CLITestManager::getPluginGroupTestList(TEST_PLUGINS);
}
/* exit if we've displayed a list */
if ( $opt_grouplist || $opt_caselist || $opt_plugincaselist || $opt_plugingrouplist ) {
exit(0);
}
/* run a test case */
if ($opt_casefile) {
TestManager::runTestFile($opt_casefile, new CLIReporter($opt_separator));
exit(0);
}
/* run a test case by id */
if ($opt_caseid) {
TestManager::runTestCase($opt_caseid, TEST_CASES, new CLIReporter($opt_separator));
exit(0);
}
/* run a plugin test by case id */
if ($opt_plugincaseid) {
TestManager::runTestCase($opt_plugincaseid, TEST_PLUGINS, new CLIReporter($opt_separator));
exit(0);
}
/* run a grouptest */
if ($opt_groupfile) {
TestManager::runGroupTest($opt_groupfile, TEST_GROUPS,
new CLIReporter($opt_separator));
exit(0);
}
/* run a plugin grouptest */
if ($opt_plugingroupfile) {
TestManager::runGroupTest($opt_plugingroupfile, TEST_PLUGINS,
new CLIReporter($opt_separator));
exit(0);
}
/* run a plugin group test */
//FIXME
/* run all tests */
TestManager::runAllTests(new CLIReporter($opt_separator));
exit(0);
?>

View File

@ -1,27 +0,0 @@
body {
background-color:#eee;
color:#000;
font:100%/1.2em Georgia,Verdana,Arial,Helvetica,sans-serif;
margin-left:20ex;
max-width:120ex;
}
#sf { float:right; }
h1 {
background-image:url(rephlux.png);
background-repeat:no-repeat;
margin-top:0;
padding:20px 0 0 90px;
color:#600;
font-size:3em;
line-height: 1em;
background-color:inherit;
border-bottom:9px double #333;
}
pre {
font-size:120%;
line-height:1.2em;
color:#006;
}

View File

@ -1,12 +0,0 @@
TEST_ENABLED = 0
; For performing "web tests" - PHP scripts acting as web browser
WEB_TEST_URL = http://localhost/dokuwiki
; See http://www.sitepoint.com/blogs/2004/06/15/simple-test-remote-testing/
REMOTE_TEST_URL = http://localhost/dokuwiki/test/index.php
;PROXY = http://proxyuser:proxypwd@proxy.yourdomain.com:8080
; Path to Simple Test
SIMPLE_TEST = ../../simpletest/

View File

@ -0,0 +1,244 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/auth.php';
require_once DOKU_INC.'inc/auth/basic.class.php';
class auth_acl_test extends DokuWikiTest {
var $oldConf;
var $oldAuthAcl;
function setup() {
global $conf;
global $AUTH_ACL;
global $auth;
$this->oldConf = $conf;
$this->oldAuthAcl = $AUTH_ACL;
$auth = new auth_basic();
}
function teardown() {
global $conf;
global $AUTH_ACL;
$conf = $this->oldConf;
$AUTH_ACL = $this->oldAuthAcl;
}
function test_restricted(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
);
// anonymous user
$this->assertEquals(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user
$this->assertEquals(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
}
function test_restricted_ropage(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
'namespace:page @user 1',
);
// anonymous user
$this->assertEquals(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_READ);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user
$this->assertEquals(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
}
function test_aclexample(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 4',
'* bigboss 16',
'start @ALL 1',
'marketing:* @marketing 8',
'devel:* @ALL 0',
'devel:* @devel 8',
'devel:* bigboss 16',
'devel:funstuff bigboss 0',
'devel:* @marketing 1',
'devel:marketing @marketing 2',
);
$this->assertEquals(auth_aclcheck('page', '' ,array()) , AUTH_CREATE);
$this->assertEquals(auth_aclcheck('page', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEquals(auth_aclcheck('page', 'jill' ,array('marketing')) , AUTH_CREATE);
$this->assertEquals(auth_aclcheck('page', 'jane' ,array('devel')) , AUTH_CREATE);
$this->assertEquals(auth_aclcheck('start', '' ,array()) , AUTH_READ);
$this->assertEquals(auth_aclcheck('start', 'bigboss' ,array('foo')) , AUTH_READ);
$this->assertEquals(auth_aclcheck('start', 'jill' ,array('marketing')) , AUTH_READ);
$this->assertEquals(auth_aclcheck('start', 'jane' ,array('devel')) , AUTH_READ);
$this->assertEquals(auth_aclcheck('marketing:page', '' ,array()) , AUTH_CREATE);
$this->assertEquals(auth_aclcheck('marketing:page', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEquals(auth_aclcheck('marketing:page', 'jill' ,array('marketing')) , AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('marketing:page', 'jane' ,array('devel')) , AUTH_CREATE);
$this->assertEquals(auth_aclcheck('devel:page', '' ,array()) , AUTH_NONE);
$this->assertEquals(auth_aclcheck('devel:page', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEquals(auth_aclcheck('devel:page', 'jill' ,array('marketing')) , AUTH_READ);
$this->assertEquals(auth_aclcheck('devel:page', 'jane' ,array('devel')) , AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('devel:funstuff', '' ,array()) , AUTH_NONE);
$this->assertEquals(auth_aclcheck('devel:funstuff', 'bigboss' ,array('foo')) , AUTH_NONE);
$this->assertEquals(auth_aclcheck('devel:funstuff', 'jill' ,array('marketing')) , AUTH_READ);
$this->assertEquals(auth_aclcheck('devel:funstuff', 'jane' ,array('devel')) , AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('devel:marketing', '' ,array()) , AUTH_NONE);
$this->assertEquals(auth_aclcheck('devel:marketing', 'bigboss' ,array('foo')) , AUTH_DELETE);
$this->assertEquals(auth_aclcheck('devel:marketing', 'jill' ,array('marketing')) , AUTH_EDIT);
$this->assertEquals(auth_aclcheck('devel:marketing', 'jane' ,array('devel')) , AUTH_UPLOAD);
}
function test_multiadmin_restricted(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john,@admin,doe,@roots';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
);
// anonymous user
$this->assertEquals(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user john
$this->assertEquals(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
// super user doe
$this->assertEquals(auth_aclcheck('page', 'doe',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','doe',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'doe',array('foo')), AUTH_ADMIN);
// user with matching admin group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','admin')), AUTH_ADMIN);
// user with matching another admin group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','roots')), AUTH_ADMIN);
}
function test_multiadmin_restricted_ropage(){
global $conf;
global $AUTH_ACL;
$conf['superuser'] = 'john,@admin,doe,@roots';
$conf['useacl'] = 1;
$AUTH_ACL = array(
'* @ALL 0',
'* @user 8',
'namespace:page @user 1',
);
// anonymous user
$this->assertEquals(auth_aclcheck('page', '',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','',array()), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', '',array()), AUTH_NONE);
// user with no matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo')), AUTH_NONE);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo')), AUTH_NONE);
// user with matching group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','user')), AUTH_UPLOAD);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','user')), AUTH_READ);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','user')), AUTH_UPLOAD);
// super user john
$this->assertEquals(auth_aclcheck('page', 'john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','john',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'john',array('foo')), AUTH_ADMIN);
// super user doe
$this->assertEquals(auth_aclcheck('page', 'doe',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','doe',array('foo')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'doe',array('foo')), AUTH_ADMIN);
// user with matching admin group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','admin')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','admin')), AUTH_ADMIN);
// user with matching another admin group
$this->assertEquals(auth_aclcheck('page', 'jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:page','jill',array('foo','roots')), AUTH_ADMIN);
$this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','roots')), AUTH_ADMIN);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -0,0 +1,130 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/auth.php';
require_once DOKU_INC.'inc/auth/basic.class.php';
class auth_admin_test_AuthInSensitive extends auth_basic {
function isCaseSensitive(){
return false;
}
}
class auth_admin_test extends DokuWikiTest {
private $oldauth;
function setup() {
global $auth;
$this->oldauth = $auth;
}
function setSensitive() {
global $auth;
$auth = new auth_basic();
}
function setInSensitive() {
global $auth;
$auth = new auth_admin_test_AuthInSensitive();
}
function teardown() {
global $auth;
global $conf;
global $AUTH_ACL;
unset($conf);
unset($AUTH_ACL);
$auth = $this->oldauth;
}
function test_ismanager_insensitive(){
$this->setInSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte';
$conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny';
// anonymous user
$this->assertEquals(auth_ismanager('jill', null,false), false);
// admin or manager users
$this->assertEquals(auth_ismanager('john', null,false), true);
$this->assertEquals(auth_ismanager('doe', null,false), true);
$this->assertEquals(auth_ismanager('dörte', null,false), true);
$this->assertEquals(auth_ismanager('dänny', null,false), true);
// admin or manager groups
$this->assertEquals(auth_ismanager('jill', array('admin'),false), true);
$this->assertEquals(auth_ismanager('jill', array('managers'),false), true);
$this->assertEquals(auth_ismanager('jill', array('mötly görls'),false), true);
$this->assertEquals(auth_ismanager('jill', array('mötly böys'),false), true);
}
function test_isadmin_insensitive(){
$this->setInSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,doe,@roots';
// anonymous user
$this->assertEquals(auth_ismanager('jill', null,true), false);
// admin user
$this->assertEquals(auth_ismanager('john', null,true), true);
$this->assertEquals(auth_ismanager('doe', null,true), true);
// admin groups
$this->assertEquals(auth_ismanager('jill', array('admin'),true), true);
$this->assertEquals(auth_ismanager('jill', array('roots'),true), true);
$this->assertEquals(auth_ismanager('john', array('admin'),true), true);
$this->assertEquals(auth_ismanager('doe', array('admin'),true), true);
}
function test_ismanager_sensitive(){
$this->setSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,@Mötly Görls, Dörte';
$conf['manager'] = 'john,@managers,doe, @Mötly Böys, Dänny';
// anonymous user
$this->assertEquals(auth_ismanager('jill', null,false), false);
// admin or manager users
$this->assertEquals(auth_ismanager('john', null,false), true);
$this->assertEquals(auth_ismanager('doe', null,false), true);
$this->assertEquals(auth_ismanager('dörte', null,false), false);
$this->assertEquals(auth_ismanager('dänny', null,false), false);
// admin or manager groups
$this->assertEquals(auth_ismanager('jill', array('admin'),false), true);
$this->assertEquals(auth_ismanager('jill', array('managers'),false), true);
$this->assertEquals(auth_ismanager('jill', array('mötly görls'),false), false);
$this->assertEquals(auth_ismanager('jill', array('mötly böys'),false), false);
}
function test_isadmin_sensitive(){
$this->setSensitive();
global $conf;
$conf['superuser'] = 'john,@admin,doe,@roots';
// anonymous user
$this->assertEquals(auth_ismanager('jill', null,true), false);
// admin user
$this->assertEquals(auth_ismanager('john', null,true), true);
$this->assertEquals(auth_ismanager('Doe', null,true), false);
// admin groups
$this->assertEquals(auth_ismanager('jill', array('admin'),true), true);
$this->assertEquals(auth_ismanager('jill', array('roots'),true), true);
$this->assertEquals(auth_ismanager('john', array('admin'),true), true);
$this->assertEquals(auth_ismanager('doe', array('admin'),true), true);
$this->assertEquals(auth_ismanager('Doe', array('admin'),true), true);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -3,7 +3,7 @@
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/auth.php';
class auth_nameencode_test extends UnitTestCase {
class auth_nameencode_test extends DokuWikiTest {
function teardown() {
global $cache_authname;
@ -13,37 +13,37 @@ class auth_nameencode_test extends UnitTestCase {
function test_simple(){
$in = 'hey$you';
$out = 'hey%24you';
$this->assertEqual(auth_nameencode($in),$out);
$this->assertEquals(auth_nameencode($in),$out);
}
function test_quote(){
$in = 'hey"you';
$out = 'hey%22you';
$this->assertEqual(auth_nameencode($in),$out);
$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';
$this->assertEqual(auth_nameencode($in),$out);
$this->assertEquals(auth_nameencode($in),$out);
}
function test_complexutf8(){
$in = 'häü $ yü !$%! foo ';
$out = 'häü%20%24%20yü%20%21%24%25%21%20foo%20';
$this->assertEqual(auth_nameencode($in),$out);
$this->assertEquals(auth_nameencode($in),$out);
}
function test_groupskipon(){
$in = '@hey$you';
$out = '@hey%24you';
$this->assertEqual(auth_nameencode($in,true),$out);
$this->assertEquals(auth_nameencode($in,true),$out);
}
function test_groupskipoff(){
$in = '@hey$you';
$out = '%40hey%24you';
$this->assertEqual(auth_nameencode($in),$out);
$this->assertEquals(auth_nameencode($in),$out);
}
}

View File

@ -3,7 +3,7 @@
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/auth.php';
class auth_password_test extends UnitTestCase {
class auth_password_test extends PHPUnit_Framework_TestCase {
// hashes for the password foo$method, using abcdefgh as salt
var $passes = array(
@ -17,8 +17,6 @@ class auth_password_test extends UnitTestCase {
'mysql' => '4a1fa3780bd6fd55',
'my411' => '*e5929347e25f82e19e4ebe92f1dc6b6e7c2dbd29',
'kmd5' => 'a579299436d7969791189acadd86fcb716',
'pmd5' => '$P$abcdefgh1RC6Fd32heUzl7EYCG9uGw.',
'hmd5' => '$H$abcdefgh1ZbJodHxmeXVAhEzTG7IAp.',
'djangomd5' => 'md5$abcde$d0fdddeda8cd92725d2b54148ac09158',
'djangosha1' => 'sha1$abcde$c8e65a7f0acc9158843048a53dcc5a6bc4d17678',
);
@ -27,25 +25,24 @@ class auth_password_test extends UnitTestCase {
function test_cryptPassword(){
foreach($this->passes as $method => $hash){
$info = "testing method $method";
$this->signal('failinfo',$info);
$this->assertEqual(auth_cryptPassword('foo'.$method,$method,'abcdefgh12345678912345678912345678'),$hash);
$this->assertEquals(auth_cryptPassword('foo'.$method, $method,'abcdefgh12345678912345678912345678'),
$hash, $info);
}
}
function test_verifyPassword(){
foreach($this->passes as $method => $hash){
$info = "testing method $method";
$this->signal('failinfo',$info);
$this->assertTrue(auth_verifyPassword('foo'.$method,$hash));
$this->assertTrue(auth_verifyPassword('foo'.$method, $hash), $info);
$this->assertFalse(auth_verifyPassword('bar'.$method, $hash), $info);
}
}
function test_verifySelf(){
foreach($this->passes as $method => $hash){
$info = "testing method $method";
$this->signal('failinfo',$info);
$hash = auth_cryptPassword('foo'.$method,$method);
$this->assertTrue(auth_verifyPassword('foo'.$method,$hash));
$this->assertTrue(auth_verifyPassword('foo'.$method, $hash), $info);
}
}
@ -67,6 +64,20 @@ class auth_password_test extends UnitTestCase {
$this->assertTrue(auth_verifyPassword('test12345','$H$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0'));
}
/**
* pmd5 checking should throw an exception when a hash with a too high
* iteration count is passed
*/
function test_verifyPassword_pmd5Exception(){
$except = false;
try{
auth_verifyPassword('foopmd5', '$H$abcdefgh1ZbJodHxmeXVAhEzTG7IAp.');
}catch (Exception $e){
$except = true;
}
$this->assertTrue($except);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -0,0 +1,28 @@
<?php
require_once DOKU_INC . 'inc/init.php';
require_once DOKU_INC . 'inc/common.php';
class common_cleanText_test extends DokuWikiTest {
function test_unix(){
$unix = 'one
two
three';
$this->assertEquals($unix,cleanText($unix));
}
function test_win(){
$unix = "one\ntwo\nthree";
$win = "one\r\ntwo\r\nthree";
$this->assertEquals(bin2hex($unix), '6f6e650a74776f0a7468726565');
$this->assertEquals(bin2hex($win), '6f6e650d0a74776f0d0a7468726565');
$this->assertNotEquals($unix, $win);
$this->assertEquals($unix, cleanText($win));
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -3,14 +3,14 @@
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/common.php';
class common_clientIP_test extends UnitTestCase {
class common_clientIP_test extends DokuWikiTest {
function test_simple_all(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '';
$out = '123.123.123.123';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
function test_proxy1_all(){
@ -18,7 +18,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '77.77.77.77';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '';
$out = '123.123.123.123,77.77.77.77';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
function test_proxy2_all(){
@ -26,7 +26,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '77.77.77.77';
$out = '123.123.123.123,77.77.77.77';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
function test_proxyhops_all(){
@ -34,7 +34,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '77.77.77.77,66.66.66.66';
$out = '123.123.123.123,77.77.77.77,66.66.66.66';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
function test_simple_single(){
@ -42,7 +42,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '';
$out = '123.123.123.123';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_proxy1_single(){
@ -50,7 +50,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '77.77.77.77';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '';
$out = '77.77.77.77';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_proxy2_single(){
@ -58,7 +58,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '77.77.77.77';
$out = '77.77.77.77';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_proxyhops_single(){
@ -66,7 +66,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '77.77.77.77,66.66.66.66';
$out = '66.66.66.66';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_local_all(){
@ -74,7 +74,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '127.0.0.1';
$out = '123.123.123.123,127.0.0.1';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
function test_local1_single(){
@ -82,7 +82,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '127.0.0.1';
$out = '123.123.123.123';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_local2_single(){
@ -90,7 +90,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '123.123.123.123';
$out = '123.123.123.123';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_local3_single(){
@ -98,7 +98,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '127.0.0.1,10.0.0.1,192.168.0.2,172.17.1.1,172.21.1.1,172.31.1.1';
$out = '123.123.123.123';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_local4_single(){
@ -106,7 +106,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '192.168.0.5';
$out = '192.168.0.5';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_garbage_all(){
@ -114,7 +114,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = 'some garbage, or something, 222';
$out = '123.123.123.123';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
function test_garbage_single(){
@ -122,7 +122,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = 'some garbage, or something, 222';
$out = '123.123.123.123';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_garbageonly_all(){
@ -130,7 +130,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = 'some garbage, or something, 222';
$out = '0.0.0.0';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
function test_garbageonly_single(){
@ -138,7 +138,7 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = 'some garbage, or something, 222';
$out = '0.0.0.0';
$this->assertEqual(clientIP(true),$out);
$this->assertEquals(clientIP(true),$out);
}
function test_malicious(){
@ -146,10 +146,9 @@ class common_clientIP_test extends UnitTestCase {
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '<?php set_time_limit(0);echo \'my_delim\';passthru(123.123.123.123);die;?>';
$out = '0.0.0.0';
$this->assertEqual(clientIP(),$out);
$this->assertEquals(clientIP(),$out);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,26 +1,27 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/common.php';
class common_obfuscate_test extends UnitTestCase {
class common_obfuscate_test extends DokuWikiTest {
function test_none(){
global $conf;
$conf['mailguard'] = 'none';
$this->assertEqual(obfuscate('jon-doe@example.com'), 'jon-doe@example.com');
$this->assertEquals(obfuscate('jon-doe@example.com'), 'jon-doe@example.com');
}
function test_hex(){
global $conf;
$conf['mailguard'] = 'hex';
$this->assertEqual(obfuscate('jon-doe@example.com'),
$this->assertEquals(obfuscate('jon-doe@example.com'),
'&#x6a;&#x6f;&#x6e;&#x2d;&#x64;&#x6f;&#x65;&#x40;&#x65;&#x78;&#x61;&#x6d;&#x70;&#x6c;&#x65;&#x2e;&#x63;&#x6f;&#x6d;');
}
function test_visible(){
global $conf;
$conf['mailguard'] = 'visible';
$this->assertEqual(obfuscate('jon-doe@example.com'), 'jon [dash] doe [at] example [dot] com');
$this->assertEquals(obfuscate('jon-doe@example.com'), 'jon [dash] doe [at] example [dot] com');
}

View File

@ -1,8 +1,9 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/common.php';
class common_pagetemplate_test extends UnitTestCase {
class common_pagetemplate_test extends DokuWikiTest {
function test_none(){
global $conf;
@ -11,9 +12,7 @@ class common_pagetemplate_test extends UnitTestCase {
'id' => 'page-id-long',
'tpl' => '"@PAGE@" "@!PAGE@" "@!!PAGE@" "@!PAGE!@"',
);
$old = error_reporting(E_ALL & ~E_NOTICE);
$this->assertEqual(parsePageTemplate($data), '"page id long" "Page id long" "Page Id Long" "PAGE ID LONG"');
error_reporting($old);
$this->assertEquals(parsePageTemplate($data), '"page id long" "Page id long" "Page Id Long" "PAGE ID LONG"');
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,9 +1,8 @@
<?php
require_once DOKU_INC.'inc/auth.php';
require_once DOKU_INC.'inc/form.php';
require_once DOKU_INC.'inc/init.php';
class form_test extends UnitTestCase {
class form_test extends DokuWikiTest {
function _testform() {
$form = new Doku_Form(array('id' => 'dw__testform', 'action' => '/test'));
@ -52,13 +51,13 @@ class form_test extends UnitTestCase {
$output = ob_get_contents();
ob_end_clean();
$form->addHidden('sectok', getSecurityToken());
$this->assertEqual($this->_ignoreTagWS($output),$this->_ignoreTagWS($this->_realoutput()));
$this->assertEquals($this->_ignoreTagWS($output),$this->_ignoreTagWS($this->_realoutput()));
}
function test_get_element_at() {
$form = $this->_testform();
$e1 =& $form->getElementAt(1);
$this->assertEqual($e1, array('_elem'=>'textfield',
$this->assertEquals($e1, array('_elem'=>'textfield',
'_text'=>'Text',
'_class'=>'block',
'id'=>'text__id',
@ -66,24 +65,24 @@ class form_test extends UnitTestCase {
'value'=>'v',
'class'=>'edit'));
$e2 =& $form->getElementAt(99);
$this->assertEqual($e2, array('_elem'=>'closefieldset'));
$this->assertEquals($e2, array('_elem'=>'closefieldset'));
}
function test_find_element_by_type() {
$form = $this->_testform();
$this->assertEqual($form->findElementByType('button'), 3);
$this->assertEquals($form->findElementByType('button'), 3);
$this->assertFalse($form->findElementByType('text'));
}
function test_find_element_by_id() {
$form = $this->_testform();
$this->assertEqual($form->findElementById('check__id'), 2);
$this->assertEquals($form->findElementById('check__id'), 2);
$this->assertFalse($form->findElementById('dw__testform'));
}
function test_find_element_by_attribute() {
$form = $this->_testform();
$this->assertEqual($form->findElementByAttribute('value','Cancel'), 4);
$this->assertEquals($form->findElementByAttribute('value','Cancel'), 4);
$this->assertFalse($form->findElementByAttribute('name','cancel'));
}
@ -99,7 +98,7 @@ class form_test extends UnitTestCase {
$form->printForm();
$output = ob_get_contents();
ob_end_clean();
$this->assertEqual($this->_ignoreTagWS($output),$this->_ignoreTagWS($this->_realoutput()));
$this->assertEquals($this->_ignoreTagWS($output),$this->_ignoreTagWS($this->_realoutput()));
}
}

View File

@ -0,0 +1,100 @@
<?php
class html_hilight_test extends DokuWikiTest {
function testHighlightOneWord() {
$html = 'Foo bar Foo';
$this->assertRegExp(
'/Foo <span.*>bar<\/span> Foo/',
html_hilight($html,'bar')
);
}
function testHighlightTwoWords() {
$html = 'Foo bar Foo php Foo';
$this->assertRegExp(
'/Foo <span.*>bar<\/span> Foo <span.*>php<\/span> Foo/',
html_hilight($html,array('bar','php'))
);
}
function testHighlightTwoWordsHtml() {
$html = 'Foo <b>bar</b> <i>Foo</i> php Foo';
$this->assertRegExp(
'/Foo <b><span.*>bar<\/span><\/b> <i>Foo<\/i> <span.*>php<\/span> Foo/',
html_hilight($html,array('bar','php'))
);
}
function testNoMatchHtml() {
$html = 'Foo <font>font</font> Bar';
$this->assertRegExp(
'/Foo <font><span.*>font<\/span><\/font> Bar/',
html_hilight($html,'font')
);
}
function testWildcardRight() {
$html = 'foo bar foobar barfoo foobarfoo foo';
$this->assertRegExp(
'/foo <span.*>bar<\/span> foobar <span.*>bar<\/span>foo foobarfoo foo/',
html_hilight($html,'bar*')
);
}
function testWildcardLeft() {
$html = 'foo bar foobar barfoo foobarfoo foo';
$this->assertRegExp(
'/foo <span.*>bar<\/span> foo<span.*>bar<\/span> barfoo foobarfoo foo/',
html_hilight($html,'*bar')
);
}
function testWildcardBoth() {
$html = 'foo bar foobar barfoo foobarfoo foo';
$this->assertRegExp(
'/foo <span.*>bar<\/span> foo<span.*>bar<\/span> <span.*>bar<\/span>foo foo<span.*>bar<\/span>foo foo/',
html_hilight($html,'*bar*')
);
}
function testNoHighlight() {
$html = 'Foo bar Foo';
$this->assertRegExp(
'/Foo bar Foo/',
html_hilight($html,'php')
);
}
function testMatchAttribute() {
$html = 'Foo <b class="x">bar</b> Foo';
$this->assertRegExp(
'/Foo <b class="x">bar<\/b> Foo/',
html_hilight($html,'class="x"')
);
}
function testMatchAttributeWord() {
$html = 'Foo <b class="x">bar</b> Foo';
$this->assertEquals(
'Foo <b class="x">bar</b> Foo',
html_hilight($html,'class="x">bar')
);
}
function testRegexInjection() {
$html = 'Foo bar Foo';
$this->assertRegExp(
'/Foo bar Foo/',
html_hilight($html,'*')
);
}
function testRegexInjectionSlash() {
$html = 'Foo bar Foo';
$this->assertRegExp(
'/Foo bar Foo/',
html_hilight($html,'x/')
);
}
}

View File

@ -0,0 +1,180 @@
<?php
class httpclient_http_test extends DokuWikiTest {
protected $server = 'http://httpbin.org';
/**
* @group internet
*/
function test_simpleget(){
$http = new HTTPClient();
$data = $http->get($this->server.'/get?foo=bar');
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('args',$resp);
$this->assertEquals(array('foo'=>'bar'), $resp['args']);
}
/**
* @group internet
*/
function test_dget(){
$http = new HTTPClient();
$data = $http->dget($this->server.'/get',array('foo'=>'bar'));
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('args',$resp);
$this->assertEquals(array('foo'=>'bar'), $resp['args']);
}
/**
* @group internet
*/
function test_gzip(){
$http = new HTTPClient();
$data = $http->get($this->server.'/gzip');
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('gzipped',$resp);
$this->assertTrue($resp['gzipped']);
}
/**
* @group internet
*/
function test_simplepost(){
$http = new HTTPClient();
$data = $http->post($this->server.'/post',array('foo'=>'bar'));
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('form',$resp);
$this->assertEquals(array('foo'=>'bar'), $resp['form']);
}
/**
* @group internet
*/
function test_redirect(){
$http = new HTTPClient();
$data = $http->get($this->server.'/redirect/3');
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('url',$resp);
$this->assertRegExp('/\/get$/', $resp['url']);
}
/**
* @group internet
*/
function test_relredirect(){
$http = new HTTPClient();
$data = $http->get($this->server.'/relative-redirect/3');
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('url',$resp);
$this->assertRegExp('/\/get$/', $resp['url']);
}
/**
* @group internet
*/
function test_redirectfail(){
$http = new HTTPClient();
$data = $http->get($this->server.'/redirect/5');
$this->assertTrue($data === false, 'HTTP response');
$this->assertEquals('Maximum number of redirects exceeded',$http->error);
}
/**
* @group internet
*/
function test_cookies(){
$http = new HTTPClient();
$http->get($this->server.'/cookies/set/foo/bar');
$this->assertEquals(array('foo' => 'bar'), $http->cookies);
$data = $http->get($this->server.'/cookies');
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('cookies',$resp);
$this->assertEquals(array('foo'=>'bar'), $resp['cookies']);
}
/**
* @group internet
*/
function test_teapot(){
$http = new HTTPClient();
$data = $http->get($this->server.'/status/418');
$this->assertTrue($data === false, 'HTTP response');
$this->assertEquals(418,$http->status);
}
/**
* @group internet
*/
function test_maxbody(){
$http = new HTTPClient();
$http->max_bodysize = 250;
$data = $http->get($this->server.'/stream/30');
$this->assertTrue($data === false, 'HTTP response');
}
/**
* @group internet
*/
function test_basicauth(){
$http = new HTTPClient();
$http->user = 'user';
$http->pass = 'pass';
$data = $http->get($this->server.'/basic-auth/user/pass');
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertEquals(array('authenticated'=>true,'user'=>'user'), $resp);
}
/**
* @group internet
*/
function test_basicauthfail(){
$http = new HTTPClient();
$http->user = 'user';
$http->pass = 'invalid';
$data = $http->get($this->server.'/basic-auth/user/pass');
$this->assertTrue($data === false, 'HTTP response');
$this->assertEquals(401,$http->status);
}
/**
* @group internet
*/
function test_timeout(){
$http = new HTTPClient();
$http->timeout = 5;
$data = $http->get($this->server.'/delay/10');
$this->assertTrue($data === false, 'HTTP response');
$this->assertEquals(-100,$http->status);
}
/**
* @group internet
*/
function test_headers(){
$http = new HTTPClient();
$data = $http->get($this->server.'/response-headers?baz=&foo=bar');
$this->assertFalse($data === false, 'HTTP response');
$resp = json_decode($data, true);
$this->assertTrue(is_array($resp), 'JSON response');
$this->assertArrayHasKey('baz',$http->resp_headers);
$this->assertArrayHasKey('foo',$http->resp_headers);
$this->assertEquals('bar',$http->resp_headers['foo']);
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -0,0 +1,17 @@
<?php
require_once dirname(__FILE__).'/httpclient_http.test.php';
class httpclient_https_test extends httpclient_http_test {
protected $server = 'https://httpbin.org/';
public function setUp(){
// skip tests when this PHP has no SSL support
$transports = stream_get_transports();
if(!in_array('ssl',$transports)){
$this->markTestSkipped('No SSL support available.');
}
parent::setUp();
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -1,7 +1,7 @@
<?php
require_once DOKU_INC.'inc/init.php';
class init_fullpath_test extends UnitTestCase {
class init_fullpath_test extends DokuWikiTest {
function test_unix_paths(){
$base = $_SERVER['SCRIPT_FILENAME'];
@ -27,9 +27,8 @@ class init_fullpath_test extends UnitTestCase {
foreach($tests as $from => $to){
$info = "Testing '$from' resulted in '".fullpath($from)."'";
$this->signal('failinfo',$info);
$this->assertEqual(fullpath($from),$to);
$this->assertEquals(fullpath($from), $to, $info);
}
@ -75,9 +74,8 @@ class init_fullpath_test extends UnitTestCase {
foreach($tests as $from => $to){
$info = "Testing '$from' resulted in '".fullpath($from)."'";
$this->signal('failinfo',$info);
$this->assertEqual(fullpath($from),$to);
$this->assertEquals(fullpath($from), $to, $info);
}

View File

@ -2,7 +2,7 @@
require_once DOKU_INC.'inc/init.php';
class init_getBaseURL_test extends UnitTestCase {
class init_getBaseURL_test extends DokuWikiTest {
/**
* Apache, mod_php, subdirectory
@ -24,7 +24,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
$this->assertEquals(getBaseURL(),'/dokuwiki/');
}
/**
@ -47,7 +47,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/home/bengen/public_html/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/~bengen/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/~bengen/dokuwiki/');
$this->assertEquals(getBaseURL(),'/~bengen/dokuwiki/');
}
/**
@ -70,7 +70,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/home/bengen/public_html/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/~bengen/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/~bengen/dokuwiki/');
$this->assertEquals(getBaseURL(),'/~bengen/dokuwiki/');
}
/**
@ -93,7 +93,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/home/bengen/public_html/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/~bengen/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/~bengen/dokuwiki/');
$this->assertEquals(getBaseURL(),'/~bengen/dokuwiki/');
}
/**
@ -116,7 +116,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = 'C:\\Inetpub\\wwwroot\\wiki\\doku.php';
$_SERVER['PHP_SELF'] = '/wiki/doku.php';
$this->assertEqual(getBaseURL(),'/wiki/');
$this->assertEquals(getBaseURL(),'/wiki/');
}
/**
@ -139,7 +139,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = null;
$_SERVER['PHP_SELF'] = '/wiki/syntax';
$this->assertEqual(getBaseURL(),'/');
$this->assertEquals(getBaseURL(),'/');
}
/**
@ -162,7 +162,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = null;
$_SERVER['PHP_SELF'] = '';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
$this->assertEquals(getBaseURL(),'/dokuwiki/');
}
/**
@ -185,7 +185,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/var/www/wiki/syntax';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki/syntax';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
$this->assertEquals(getBaseURL(),'/dokuwiki/');
}
/**
@ -208,7 +208,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
$this->assertEquals(getBaseURL(),'/dokuwiki/');
}
/**
@ -240,7 +240,7 @@ class init_getBaseURL_test extends UnitTestCase {
foreach ($tests as $test => $correct_result) {
$conf['baseurl'] = $test;
$this->assertEqual(getBaseURL(true),$correct_result);
$this->assertEquals(getBaseURL(true),$correct_result);
}
}
/**
@ -272,7 +272,7 @@ class init_getBaseURL_test extends UnitTestCase {
foreach ($tests as $test => $correct_result) {
$conf['baseurl'] = $test;
$this->assertEqual(getBaseURL(true),$correct_result);
$this->assertEquals(getBaseURL(true),$correct_result);
}
}
@ -298,7 +298,7 @@ class init_getBaseURL_test extends UnitTestCase {
$_SERVER['PHP_SELF'] = '/~michitux/dokuwiki/doku.php';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['SERVER_NAME'] = '[fd00';
$this->assertEqual(getBaseURL(true), 'http://[fd00::6592:39ed:a2ed:2c78]/~michitux/dokuwiki/');
$this->assertEquals(getBaseURL(true), 'http://[fd00::6592:39ed:a2ed:2c78]/~michitux/dokuwiki/');
}
}

View File

@ -1,7 +1,9 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/IXR_Library.php';
class ixr_library_date_test extends UnitTestCase {
class ixr_library_date_test extends DokuWikiTest {
function test_parseIso(){
@ -26,7 +28,7 @@ class ixr_library_date_test extends UnitTestCase {
foreach($tests as $test){
$dt = new IXR_Date($test[0]);
$this->assertEqual($dt->getTimeStamp(),$test[1]);
$this->assertEquals($dt->getTimeStamp(),$test[1]);
}
}

View File

@ -1,7 +1,8 @@
<?php
require_once DOKU_INC.'inc/init.php';
require_once DOKU_INC.'inc/IXR_Library.php';
class ixr_library_ixr_message_test extends UnitTestCase {
class ixr_library_ixr_message_test extends DokuWikiTest {
@ -13,9 +14,9 @@ class ixr_library_ixr_message_test extends UnitTestCase {
$ixrmsg = new IXR_Message($xml);
$ixrmsg->parse();
$this->assertEqual($ixrmsg->messageType,'methodCall');
$this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEqual($ixrmsg->params,array(' change '));
$this->assertEquals($ixrmsg->messageType,'methodCall');
$this->assertEquals($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEquals($ixrmsg->params,array(' change '));
}
function test_untypedvalue2(){
@ -32,9 +33,9 @@ class ixr_library_ixr_message_test extends UnitTestCase {
$ixrmsg = new IXR_Message($xml);
$ixrmsg->parse();
$this->assertEqual($ixrmsg->messageType,'methodCall');
$this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEqual($ixrmsg->params,array(' change '));
$this->assertEquals($ixrmsg->messageType,'methodCall');
$this->assertEquals($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEquals($ixrmsg->params,array(' change '));
}
function test_stringvalue1(){
@ -43,9 +44,9 @@ class ixr_library_ixr_message_test extends UnitTestCase {
$ixrmsg = new IXR_Message($xml);
$ixrmsg->parse();
$this->assertEqual($ixrmsg->messageType,'methodCall');
$this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEqual($ixrmsg->params,array(' change '));
$this->assertEquals($ixrmsg->messageType,'methodCall');
$this->assertEquals($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEquals($ixrmsg->params,array(' change '));
}
function test_stringvalue2(){
@ -64,9 +65,9 @@ class ixr_library_ixr_message_test extends UnitTestCase {
$ixrmsg = new IXR_Message($xml);
$ixrmsg->parse();
$this->assertEqual($ixrmsg->messageType,'methodCall');
$this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEqual($ixrmsg->params,array(' change '));
$this->assertEquals($ixrmsg->messageType,'methodCall');
$this->assertEquals($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEquals($ixrmsg->params,array(' change '));
}
function test_emptyvalue1(){
@ -75,9 +76,9 @@ class ixr_library_ixr_message_test extends UnitTestCase {
$ixrmsg = new IXR_Message($xml);
$ixrmsg->parse();
$this->assertEqual($ixrmsg->messageType,'methodCall');
$this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEqual($ixrmsg->params,array(''));
$this->assertEquals($ixrmsg->messageType,'methodCall');
$this->assertEquals($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEquals($ixrmsg->params,array(''));
}
function test_emptyvalue2(){
@ -96,9 +97,9 @@ class ixr_library_ixr_message_test extends UnitTestCase {
$ixrmsg = new IXR_Message($xml);
$ixrmsg->parse();
$this->assertEqual($ixrmsg->messageType,'methodCall');
$this->assertEqual($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEqual($ixrmsg->params,array(''));
$this->assertEquals($ixrmsg->messageType,'methodCall');
$this->assertEquals($ixrmsg->methodName,'wiki.getBackLinks');
$this->assertEquals($ixrmsg->params,array(''));
}
function test_struct(){
@ -130,9 +131,9 @@ class ixr_library_ixr_message_test extends UnitTestCase {
$ixrmsg = new IXR_Message($xml);
$ixrmsg->parse();
$this->assertEqual($ixrmsg->messageType,'methodCall');
$this->assertEqual($ixrmsg->methodName,'wiki.putPage');
$this->assertEqual($ixrmsg->params,array('start','test text',array('sum'=>'xmlrpc edit','minor'=>'1')));
$this->assertEquals($ixrmsg->messageType,'methodCall');
$this->assertEquals($ixrmsg->methodName,'wiki.putPage');
$this->assertEquals($ixrmsg->params,array('start','test text',array('sum'=>'xmlrpc edit','minor'=>'1')));
}
}

View File

@ -1,8 +1,8 @@
<?php
// use no mbstring help here
require_once DOKU_INC.'inc/mail.php';
require_once DOKU_INC.'inc/init.php';
class mail_isvalid extends UnitTestCase {
class mail_isvalid extends DokuWikiTest {
function test1(){
@ -69,12 +69,11 @@ class mail_isvalid extends UnitTestCase {
foreach($tests as $test){
$info = 'Testing '.$test[0];
$this->signal('failinfo',$info);
if($test[1]){
$this->assertTrue((bool) mail_isvalid($test[0]));
$this->assertTrue((bool) mail_isvalid($test[0]), $info);
}else{
$this->assertFalse((bool) mail_isvalid($test[0]));
$this->assertFalse((bool) mail_isvalid($test[0]), $info);
}
}
}

View File

@ -2,42 +2,42 @@
require_once DOKU_INC.'inc/mail.php';
class mail_quotedprintable_encode extends UnitTestCase {
class mail_quotedprintable_encode extends DokuWikiTest {
function test_simple(){
$in = 'hello';
$out = 'hello';
$this->assertEqual(mail_quotedprintable_encode($in),$out);
$this->assertEquals(mail_quotedprintable_encode($in),$out);
}
function test_spaceend(){
$in = "hello \nhello";
$out = "hello=20\nhello";
$this->assertEqual(mail_quotedprintable_encode($in),$out);
$this->assertEquals(mail_quotedprintable_encode($in),$out);
}
function test_german_utf8(){
$in = 'hello überlänge';
$out = 'hello =C3=BCberl=C3=A4nge';
$this->assertEqual(mail_quotedprintable_encode($in),$out);
$this->assertEquals(mail_quotedprintable_encode($in),$out);
}
function test_wrap(){
$in = '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789';
$out = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234=\n56789 123456789";
$this->assertEqual(mail_quotedprintable_encode($in,74),$out);
$this->assertEquals(mail_quotedprintable_encode($in,74),$out);
}
function test_nowrap(){
$in = '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789';
$out = '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789';
$this->assertEqual(mail_quotedprintable_encode($in,0),$out);
$this->assertEquals(mail_quotedprintable_encode($in,0),$out);
}
function test_russian_utf8(){
$in = 'Ваш пароль для системы Доку Вики';
$out = '=D0=92=D0=B0=D1=88 =D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8C =D0=B4=D0=BB=D1=8F =D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B =D0=94=D0=BE=D0=BA=D1=83 =D0=92=D0=B8=D0=BA=D0=B8';
$this->assertEqual(mail_quotedprintable_encode($in,0),$out);
$this->assertEquals(mail_quotedprintable_encode($in,0),$out);
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* Extends the mailer class to expose internal variables for testing
*/
class TestMailer extends Mailer {
public function prop($name){
return $this->$name;
}
}
class mailer_test extends DokuWikiTest {
function test_userheader(){
$mail = new TestMailer();
$headers = $mail->prop('headers');
$this->assertArrayNotHasKey('X-Dokuwiki-User',$headers);
$_SERVER['REMOTE_USER'] = 'andi';
$mail = new TestMailer();
$headers = $mail->prop('headers');
$this->assertArrayHasKey('X-Dokuwiki-User',$headers);
}
function test_setHeader(){
$mail = new TestMailer();
// check existance of default headers
$headers = $mail->prop('headers');
$this->assertArrayHasKey('X-Mailer',$headers);
$this->assertArrayHasKey('X-Dokuwiki-Title',$headers);
$this->assertArrayHasKey('X-Dokuwiki-Server',$headers);
$this->assertArrayHasKey('X-Auto-Response-Suppress',$headers);
$this->assertArrayHasKey('List-Id',$headers);
// set a bunch of test headers
$mail->setHeader('test-header','bla');
$mail->setHeader('to','A valid ASCII name <test@example.com>');
$mail->setHeader('from',"Thös ne\needs\x00serious cleaning%.");
$mail->setHeader('bad',"Thös ne\needs\x00serious cleaning%.",false);
$mail->setHeader("weird\n*+\x00foo.-_@bar?",'now clean');
// are they set?
$headers = $mail->prop('headers');
$this->assertArrayHasKey('Test-Header',$headers);
$this->assertEquals('bla',$headers['Test-Header']);
$this->assertArrayHasKey('To',$headers);
$this->assertEquals('A valid ASCII name <test@example.com>',$headers['To']);
$this->assertArrayHasKey('From',$headers);
$this->assertEquals('Ths neeedsserious cleaning.',$headers['From']);
$this->assertArrayHasKey('Bad',$headers);
$this->assertEquals("Thös ne\needs\x00serious cleaning%.",$headers['Bad']);
$this->assertArrayHasKey('Weird+foo.-_@bar',$headers);
// unset a header again
$mail->setHeader('test-header','');
$headers = $mail->prop('headers');
$this->assertArrayNotHasKey('Test-Header',$headers);
}
function test_simplemail(){
global $conf;
$conf['htmlmail'] = 0;
$mail = new TestMailer();
$mail->to('test@example.com');
$mail->setBody('A test mail in ASCII');
$dump = $mail->dump();
$this->assertNotRegexp('/Content-Type: multipart/',$dump);
$this->assertRegexp('#Content-Type: text/plain; charset=UTF-8#',$dump);
$this->assertRegexp('/'.base64_encode('A test mail in ASCII').'/',$dump);
$conf['htmlmail'] = 1;
}
function test_replacements(){
$mail = new TestMailer();
$replacements = array( '@DATE@','@BROWSER@','@IPADDRESS@','@HOSTNAME@',
'@TITLE@','@DOKUWIKIURL@','@USER@','@NAME@','@MAIL@');
$mail->setBody('A test mail in with replacements '.join(' ',$replacements));
$text = $mail->prop('text');
$html = $mail->prop('html');
foreach($replacements as $repl){
$this->assertNotRegexp("/$repl/",$text,"$repl replacement still in text");
$this->assertNotRegexp("/$repl/",$html,"$repl replacement still in html");
}
}
}
//Setup VIM: ex: et ts=4 :

View File

@ -2,7 +2,7 @@
require_once DOKU_INC.'inc/utf8.php';
require_once DOKU_INC.'inc/pageutils.php';
class init_clean_id_test extends UnitTestCase {
class init_clean_id_test extends DokuWikiTest {
function teardown() {
global $cache_cleanid;
@ -50,7 +50,7 @@ class init_clean_id_test extends UnitTestCase {
$tests[] = array('page/page',false,'page_page');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
$conf['useslash'] = 1;
@ -60,7 +60,7 @@ class init_clean_id_test extends UnitTestCase {
$this->teardown();
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
}
@ -77,7 +77,7 @@ class init_clean_id_test extends UnitTestCase {
$tests[] = array('pa%ge',false,'pa-ge');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
}
@ -97,7 +97,7 @@ class init_clean_id_test extends UnitTestCase {
$tests[] = array('ښ侧化并곦ঝഈβ',false,'ښ侧化并곦ঝഈβ');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
}
@ -117,7 +117,7 @@ class init_clean_id_test extends UnitTestCase {
$tests[] = array('ښ侧化并곦ঝഈβ',false,'ښ侧化并곦ঝഈβ');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
}
@ -137,19 +137,19 @@ class init_clean_id_test extends UnitTestCase {
$tests[] = array('ښ侧化并곦ঝഈβ',true,'');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
$conf['deaccent'] = 1;
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
$conf['deaccent'] = 2;
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
$this->assertEquals(cleanID($test[0],$test[1]),$test[2]);
}
}

View File

@ -2,7 +2,7 @@
require_once DOKU_INC.'inc/utf8.php';
require_once DOKU_INC.'inc/pageutils.php';
class init_getID_test extends UnitTestCase {
class init_getID_test extends DokuWikiTest {
/**
* fetch media files with basedir and urlrewrite=2
@ -19,7 +19,7 @@ class init_getID_test extends UnitTestCase {
$_SERVER['SCRIPT_FILENAME'] = '/lib/exe/fetch.php';
$_SERVER['REQUEST_URI'] = '/lib/exe/fetch.php/myhdl-0.5dev1.tar.gz?id=snapshots&cache=cache';
$this->assertEqual(getID('media'), 'myhdl-0.5dev1.tar.gz');
$this->assertEquals(getID('media'), 'myhdl-0.5dev1.tar.gz');
}
@ -41,8 +41,8 @@ class init_getID_test extends UnitTestCase {
$_SERVER['PATH_INFO'] = '/wiki/discussion/button-dw.png';
$_SERVER['PATH_TRANSLATED'] = '/var/www/wiki/discussion/button-dw.png';
$this->assertEqual(getID('media',true), 'wiki:discussion:button-dw.png');
$this->assertEqual(getID('media',false), 'wiki/discussion/button-dw.png');
$this->assertEquals(getID('media',true), 'wiki:discussion:button-dw.png');
$this->assertEquals(getID('media',false), 'wiki/discussion/button-dw.png');
}
/**
@ -61,7 +61,7 @@ class init_getID_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/var/www/wiki:dokuwiki';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki:dokuwiki';
$this->assertEqual(getID(), 'wiki:dokuwiki');
$this->assertEquals(getID(), 'wiki:dokuwiki');
}
/**
@ -72,6 +72,8 @@ class init_getID_test extends UnitTestCase {
$conf['basedir'] = '';
$conf['userewrite'] = '2';
$conf['baseurl'] = '';
$conf['useslash'] = '1';
$_SERVER['DOCUMENT_ROOT'] = '/var/www/vhosts/example.com/htdocs';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/vhosts/example.com/htdocs/doku.php';
$_SERVER['SCRIPT_NAME'] = '/doku.php';
@ -80,7 +82,7 @@ class init_getID_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php';
$_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki';
$this->assertEqual(getID(), 'wiki:dokuwiki');
$this->assertEquals(getID(), 'wiki:dokuwiki');
}
/**
@ -99,7 +101,7 @@ class init_getID_test extends UnitTestCase {
$_SERVER['PATH_TRANSLATED'] = '/var/www/index.html';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/';
$this->assertEqual(getID(), cleanID($conf['start']));
$this->assertEquals(getID(), cleanID($conf['start']));
}
}

View File

@ -2,7 +2,7 @@
require_once DOKU_INC.'inc/utf8.php';
require_once DOKU_INC.'inc/pageutils.php';
class init_resolve_id_test extends UnitTestCase {
class init_resolve_id_test extends DokuWikiTest {
function test1(){
@ -37,7 +37,7 @@ class init_resolve_id_test extends UnitTestCase {
$tests[] = array('lev1:lev2','..:..:lev3:..:page:....:...','page');
foreach($tests as $test){
$this->assertEqual(resolve_id($test[0],$test[1]),$test[2]);
$this->assertEquals(resolve_id($test[0],$test[1]),$test[2]);
}
}

View File

@ -5,7 +5,7 @@ require_once DOKU_INC.'inc/pageutils.php';
global $conf;
if (!isset($conf['datadir'])) $conf['datadir'] = $conf['savedir'].'/pages';
class init_resolve_pageid_test extends UnitTestCase {
class init_resolve_pageid_test extends DokuWikiTest {
function test1(){
@ -48,7 +48,6 @@ class init_resolve_pageid_test extends UnitTestCase {
$tests[] = array('foo','.:','foo:start');
$tests[] = array('','foo:','foo:start');
$tests[] = array('foo','foo:','foo:start');
$tests[] = array('foo','playground:','playground:playground');
// empty $page
global $ID;
@ -59,7 +58,7 @@ class init_resolve_pageid_test extends UnitTestCase {
$page = $test[1];
resolve_pageid($test[0],$page,$foo);
$this->assertEqual($page,$test[2]);
$this->assertEquals($page,$test[2]);
}
}
@ -69,7 +68,6 @@ class init_resolve_pageid_test extends UnitTestCase {
function test_resolve_pageid_empty_homepage() {
global $ID;
$ID = '';
global $conf;
$conf['start'] = 'someverystrangestartname';
@ -78,7 +76,7 @@ class init_resolve_pageid_test extends UnitTestCase {
$exist = true;
resolve_pageid($ns, $page, $exist);
$this->assertEqual($page, $conf['start']);
$this->assertEquals($page, $conf['start']);
}
}

View File

@ -0,0 +1,531 @@
<?php
/**
* @version $Id: lexer.todo.php,v 1.2 2005/03/25 21:00:22 harryf Exp $
* @package Doku
* @subpackage Tests
*/
/**
* Includes
*/
require_once DOKU_INC . 'inc/parser/lexer.php';
/**
* @package Doku
* @subpackage Tests
*/
class TestOfLexerParallelRegex extends DokuWikiTest {
function testNoPatterns() {
$regex = new Doku_LexerParallelRegex(false);
$this->assertFalse($regex->match("Hello", $match));
$this->assertEquals($match, "");
}
function testNoSubject() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern(".*");
$this->assertTrue($regex->match("", $match));
$this->assertEquals($match, "");
}
function testMatchAll() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern(".*");
$this->assertTrue($regex->match("Hello", $match));
$this->assertEquals($match, "Hello");
}
function testCaseSensitive() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("abc");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEquals($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEquals($match, "abc");
}
function testCaseInsensitive() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern("abc");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEquals($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEquals($match, "ABC");
}
function testMatchMultiple() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("abc");
$regex->addPattern("ABC");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEquals($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEquals($match, "ABC");
$this->assertFalse($regex->match("Hello", $match));
}
function testPatternLabels() {
$regex = new Doku_LexerParallelRegex(false);
$regex->addPattern("abc", "letter");
$regex->addPattern("123", "number");
$this->assertEquals($regex->match("abcdef", $match), "letter");
$this->assertEquals($match, "abc");
$this->assertEquals($regex->match("0123456789", $match), "number");
$this->assertEquals($match, "123");
}
function testMatchMultipleWithLookaheadNot() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("abc");
$regex->addPattern("ABC");
$regex->addPattern("a(?!\n).{1}");
$this->assertTrue($regex->match("abcdef", $match));
$this->assertEquals($match, "abc");
$this->assertTrue($regex->match("AAABCabcdef", $match));
$this->assertEquals($match, "ABC");
$this->assertTrue($regex->match("a\nab", $match));
$this->assertEquals($match, "ab");
$this->assertFalse($regex->match("Hello", $match));
}
function testMatchSetOptionCaseless() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("a(?i)b(?i)c");
$this->assertTrue($regex->match("aBc", $match));
$this->assertEquals($match, "aBc");
}
function testMatchSetOptionUngreedy() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("(?U)\w+");
$this->assertTrue($regex->match("aaaaaa", $match));
$this->assertEquals($match, "a");
}
function testMatchLookaheadEqual() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("\w(?=c)");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEquals($match, "y");
}
function testMatchLookaheadNot() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("\w(?!b|c)");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEquals($match, "b");
}
function testMatchLookbehindEqual() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("(?<=c)\w");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEquals($match, "z");
}
function testMatchLookbehindNot() {
$regex = new Doku_LexerParallelRegex(true);
$regex->addPattern("(?<!\A|x|b)\w");
$this->assertTrue($regex->match("xbyczd", $match));
$this->assertEquals($match, "c");
}
}
class TestOfLexerStateStack extends DokuWikiTest {
function testStartState() {
$stack = new Doku_LexerStateStack("one");
$this->assertEquals($stack->getCurrent(), "one");
}
function testExhaustion() {
$stack = new Doku_LexerStateStack("one");
$this->assertFalse($stack->leave());
}
function testStateMoves() {
$stack = new Doku_LexerStateStack("one");
$stack->enter("two");
$this->assertEquals($stack->getCurrent(), "two");
$stack->enter("three");
$this->assertEquals($stack->getCurrent(), "three");
$this->assertTrue($stack->leave());
$this->assertEquals($stack->getCurrent(), "two");
$stack->enter("third");
$this->assertEquals($stack->getCurrent(), "third");
$this->assertTrue($stack->leave());
$this->assertTrue($stack->leave());
$this->assertEquals($stack->getCurrent(), "one");
}
}
class TestParser {
function TestParser() {
}
function accept() {
}
function a() {
}
function b() {
}
}
class TestOfLexer extends DokuWikiTest {
function testNoPatterns() {
$handler = $this->getMock('TestParser');
$handler->expects($this->never())->method('accept');
$lexer = new Doku_Lexer($handler);
$this->assertFalse($lexer->parse("abcdef"));
}
function testEmptyPage() {
$handler = $this->getMock('TestParser');
$handler->expects($this->never())->method('accept');
$lexer = new Doku_Lexer($handler);
$lexer->addPattern("a+");
$this->assertTrue($lexer->parse(""));
}
function testSinglePattern() {
$handler = $this->getMock('TestParser');
$handler->expects($this->at(0))->method('accept')
->with("aaa", DOKU_LEXER_MATCHED, 0)->will($this->returnValue(true));
$handler->expects($this->at(1))->method('accept')
->with("x", DOKU_LEXER_UNMATCHED, 3)->will($this->returnValue(true));
$handler->expects($this->at(2))->method('accept')
->with("a", DOKU_LEXER_MATCHED, 4)->will($this->returnValue(true));
$handler->expects($this->at(3))->method('accept')
->with("yyy", DOKU_LEXER_UNMATCHED, 5)->will($this->returnValue(true));
$handler->expects($this->at(4))->method('accept')
->with("a", DOKU_LEXER_MATCHED, 8)->will($this->returnValue(true));
$handler->expects($this->at(5))->method('accept')
->with("x", DOKU_LEXER_UNMATCHED, 9)->will($this->returnValue(true));
$handler->expects($this->at(6))->method('accept')
->with("aaa", DOKU_LEXER_MATCHED, 10)->will($this->returnValue(true));
$handler->expects($this->at(7))->method('accept')
->with("z", DOKU_LEXER_UNMATCHED, 13)->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler);
$lexer->addPattern("a+");
$this->assertTrue($lexer->parse("aaaxayyyaxaaaz"));
}
function testMultiplePattern() {
$handler = $this->getMock('TestParser', array('accept'));
$target = array("a", "b", "a", "bb", "x", "b", "a", "xxxxxx", "a", "x");
$positions = array(0, 1, 2, 3, 5, 6, 7, 8, 14, 15);
for ($i = 0; $i < count($target); $i++) {
$handler->expects($this->at($i))->method('accept')
->with($target[$i], $this->anything(), $positions[$i])->will($this->returnValue(true));
}
$lexer = new Doku_Lexer($handler);
$lexer->addPattern("a+");
$lexer->addPattern("b+");
$this->assertTrue($lexer->parse("ababbxbaxxxxxxax"));
}
}
class TestOfLexerModes extends DokuWikiTest {
function testIsolatedPattern() {
$handler = $this->getMock('TestParser');
$handler->expects($this->at(0))->method('a')
->with("a", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true));
$handler->expects($this->at(1))->method('a')
->with("b", DOKU_LEXER_UNMATCHED,1)->will($this->returnValue(true));
$handler->expects($this->at(2))->method('a')
->with("aa", DOKU_LEXER_MATCHED,2)->will($this->returnValue(true));
$handler->expects($this->at(3))->method('a')
->with("bxb", DOKU_LEXER_UNMATCHED,4)->will($this->returnValue(true));
$handler->expects($this->at(4))->method('a')
->with("aaa", DOKU_LEXER_MATCHED,7)->will($this->returnValue(true));
$handler->expects($this->at(5))->method('a')
->with("x", DOKU_LEXER_UNMATCHED,10)->will($this->returnValue(true));
$handler->expects($this->at(6))->method('a')
->with("aaaa", DOKU_LEXER_MATCHED,11)->will($this->returnValue(true));
$handler->expects($this->at(7))->method('a')
->with("x", DOKU_LEXER_UNMATCHED,15)->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addPattern("b+", "b");
$this->assertTrue($lexer->parse("abaabxbaaaxaaaax"));
}
function testModeChange() {
$handler = $this->getMock('TestParser');
$handler->expects($this->at(0))->method('a')
->with("a", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true));
$handler->expects($this->at(1))->method('a')
->with("b", DOKU_LEXER_UNMATCHED,1)->will($this->returnValue(true));
$handler->expects($this->at(2))->method('a')
->with("aa", DOKU_LEXER_MATCHED,2)->will($this->returnValue(true));
$handler->expects($this->at(3))->method('a')
->with("b", DOKU_LEXER_UNMATCHED,4)->will($this->returnValue(true));
$handler->expects($this->at(4))->method('a')
->with("aaa", DOKU_LEXER_MATCHED,5)->will($this->returnValue(true));
$handler->expects($this->at(5))->method('b')
->with(":", DOKU_LEXER_ENTER,8)->will($this->returnValue(true));
$handler->expects($this->at(6))->method('b')
->with("a", DOKU_LEXER_UNMATCHED,9)->will($this->returnValue(true));
$handler->expects($this->at(7))->method('b')
->with("b", DOKU_LEXER_MATCHED, 10)->will($this->returnValue(true));
$handler->expects($this->at(8))->method('b')
->with("a", DOKU_LEXER_UNMATCHED,11)->will($this->returnValue(true));
$handler->expects($this->at(9))->method('b')
->with("bb", DOKU_LEXER_MATCHED,12)->will($this->returnValue(true));
$handler->expects($this->at(10))->method('b')
->with("a", DOKU_LEXER_UNMATCHED,14)->will($this->returnValue(true));
$handler->expects($this->at(11))->method('b')
->with("bbb", DOKU_LEXER_MATCHED,15)->will($this->returnValue(true));
$handler->expects($this->at(12))->method('b')
->with("a", DOKU_LEXER_UNMATCHED,18)->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addEntryPattern(":", "a", "b");
$lexer->addPattern("b+", "b");
$this->assertTrue($lexer->parse("abaabaaa:ababbabbba"));
}
function testNesting() {
$handler = $this->getMock('TestParser');
$handler->expects($this->at(0))->method('a')
->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true));
$handler->expects($this->at(1))->method('a')
->with("b", DOKU_LEXER_UNMATCHED,2)->will($this->returnValue(true));
$handler->expects($this->at(2))->method('a')
->with("aa", DOKU_LEXER_MATCHED,3)->will($this->returnValue(true));
$handler->expects($this->at(3))->method('a')
->with("b", DOKU_LEXER_UNMATCHED,5)->will($this->returnValue(true));
$handler->expects($this->at(4))->method('b')
->with("(", DOKU_LEXER_ENTER,6)->will($this->returnValue(true));
$handler->expects($this->at(5))->method('b')
->with("bb", DOKU_LEXER_MATCHED,7)->will($this->returnValue(true));
$handler->expects($this->at(6))->method('b')
->with("a", DOKU_LEXER_UNMATCHED,9)->will($this->returnValue(true));
$handler->expects($this->at(7))->method('b')
->with("bb", DOKU_LEXER_MATCHED,10)->will($this->returnValue(true));
$handler->expects($this->at(8))->method('b')
->with(")", DOKU_LEXER_EXIT,12)->will($this->returnValue(true));
$handler->expects($this->at(9))->method('a')
->with("aa", DOKU_LEXER_MATCHED,13)->will($this->returnValue(true));
$handler->expects($this->at(10))->method('a')
->with("b", DOKU_LEXER_UNMATCHED,15)->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addEntryPattern("(", "a", "b");
$lexer->addPattern("b+", "b");
$lexer->addExitPattern(")", "b");
$this->assertTrue($lexer->parse("aabaab(bbabb)aab"));
}
function testSingular() {
$handler = $this->getMock('TestParser');
$handler->expects($this->at(0))->method('a')
->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true));
$handler->expects($this->at(1))->method('b')
->with("b", DOKU_LEXER_SPECIAL,2)->will($this->returnValue(true));
$handler->expects($this->at(2))->method('a')
->with("aa", DOKU_LEXER_MATCHED,3)->will($this->returnValue(true));
$handler->expects($this->at(3))->method('a')
->with("xx", DOKU_LEXER_UNMATCHED,5)->will($this->returnValue(true));
$handler->expects($this->at(4))->method('b')
->with("bbb", DOKU_LEXER_SPECIAL,7)->will($this->returnValue(true));
$handler->expects($this->at(5))->method('a')
->with("xx", DOKU_LEXER_UNMATCHED,10)->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addSpecialPattern("b+", "a", "b");
$this->assertTrue($lexer->parse("aabaaxxbbbxx"));
}
function testUnwindTooFar() {
$handler = $this->getMock('TestParser');
$handler->expects($this->at(0))->method('a')
->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true));
$handler->expects($this->at(1))->method('a')
->with(")", DOKU_LEXER_EXIT,2)->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "a");
$lexer->addPattern("a+", "a");
$lexer->addExitPattern(")", "a");
$this->assertFalse($lexer->parse("aa)aa"));
}
}
class TestOfLexerHandlers extends DokuWikiTest {
function testModeMapping() {
$handler = $this->getMock('TestParser');
$handler->expects($this->at(0))->method('a')
->with("aa", DOKU_LEXER_MATCHED,0)->will($this->returnValue(true));
$handler->expects($this->at(1))->method('a')
->with("(", DOKU_LEXER_ENTER,2)->will($this->returnValue(true));
$handler->expects($this->at(2))->method('a')
->with("bb", DOKU_LEXER_MATCHED,3)->will($this->returnValue(true));
$handler->expects($this->at(3))->method('a')
->with("a", DOKU_LEXER_UNMATCHED,5)->will($this->returnValue(true));
$handler->expects($this->at(4))->method('a')
->with("bb", DOKU_LEXER_MATCHED,6)->will($this->returnValue(true));
$handler->expects($this->at(5))->method('a')
->with(")", DOKU_LEXER_EXIT,8)->will($this->returnValue(true));
$handler->expects($this->at(6))->method('a')
->with("b", DOKU_LEXER_UNMATCHED,9)->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "mode_a");
$lexer->addPattern("a+", "mode_a");
$lexer->addEntryPattern("(", "mode_a", "mode_b");
$lexer->addPattern("b+", "mode_b");
$lexer->addExitPattern(")", "mode_b");
$lexer->mapHandler("mode_a", "a");
$lexer->mapHandler("mode_b", "a");
$this->assertTrue($lexer->parse("aa(bbabb)b"));
}
}
class TestParserByteIndex {
function TestParserByteIndex() {}
function ignore() {}
function caught() {}
}
class TestOfLexerByteIndices extends DokuWikiTest {
function testIndex() {
$doc = "aaa<file>bcd</file>eee";
$handler = $this->getMock('TestParserByteIndex');
$handler->expects($this->any())->method('ignore')->will($this->returnValue(true));
$handler->expects($this->at(1))->method('caught')
->with("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))->will($this->returnValue(true));
$handler->expects($this->at(2))->method('caught')
->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true));
$handler->expects($this->at(3))->method('caught')
->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true));
$handler->expects($this->at(4))->method('caught')
->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true));
$handler->expects($this->at(5))->method('caught')
->with("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern("<file>", "ignore", "caught");
$lexer->addExitPattern("</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
}
function testIndexLookaheadEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = $this->getMock('TestParserByteIndex');
$handler->expects($this->any())->method('ignore')->will($this->returnValue(true));
$handler->expects($this->at(1))->method('caught')
->with("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))->will($this->returnValue(true));
$handler->expects($this->at(2))->method('caught')
->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true));
$handler->expects($this->at(3))->method('caught')
->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true));
$handler->expects($this->at(4))->method('caught')
->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true));
$handler->expects($this->at(5))->method('caught')
->with("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('<file>(?=.*</file>)', "ignore", "caught");
$lexer->addExitPattern("</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
}
function testIndexLookaheadNotEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = $this->getMock('TestParserByteIndex');
$handler->expects($this->any())->method('ignore')->will($this->returnValue(true));
$handler->expects($this->at(1))->method('caught')
->with("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))->will($this->returnValue(true));
$handler->expects($this->at(2))->method('caught')
->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true));
$handler->expects($this->at(3))->method('caught')
->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true));
$handler->expects($this->at(4))->method('caught')
->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true));
$handler->expects($this->at(5))->method('caught')
->with("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('<file>(?!foo)', "ignore", "caught");
$lexer->addExitPattern("</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
}
function testIndexLookbehindEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = $this->getMock('TestParserByteIndex');
$handler->expects($this->any())->method('ignore')->will($this->returnValue(true));
$handler->expects($this->at(1))->method('caught')
->with("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))->will($this->returnValue(true));
$handler->expects($this->at(2))->method('caught')
->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true));
$handler->expects($this->at(3))->method('caught')
->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true));
$handler->expects($this->at(4))->method('caught')
->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true));
$handler->expects($this->at(5))->method('caught')
->with("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('<file>', "ignore", "caught");
$lexer->addExitPattern("(?<=d)</file>", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
}
function testIndexLookbehindNotEqual() {
$doc = "aaa<file>bcd</file>eee";
$handler = $this->getMock('TestParserByteIndex');
$handler->expects($this->any())->method('ignore')->will($this->returnValue(true));
$handler->expects($this->at(1))->method('caught')
->with("<file>", DOKU_LEXER_ENTER, strpos($doc,'<file>'))->will($this->returnValue(true));
$handler->expects($this->at(2))->method('caught')
->with("b", DOKU_LEXER_SPECIAL, strpos($doc,'b'))->will($this->returnValue(true));
$handler->expects($this->at(3))->method('caught')
->with("c", DOKU_LEXER_MATCHED, strpos($doc,'c'))->will($this->returnValue(true));
$handler->expects($this->at(4))->method('caught')
->with("d", DOKU_LEXER_UNMATCHED, strpos($doc,'d'))->will($this->returnValue(true));
$handler->expects($this->at(5))->method('caught')
->with("</file>", DOKU_LEXER_EXIT, strpos($doc,'</file>'))->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, 'ignore');
$lexer->addEntryPattern('<file>', 'ignore', 'caught');
$lexer->addExitPattern('(?<!c)</file>', 'caught');
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
}
/**
* This test is primarily to ensure the correct match is chosen
* when there are non-captured elements in the pattern.
*/
function testIndexSelectCorrectMatch() {
$doc = "ALL FOOLS ARE FOO";
$pattern = '\bFOO\b';
$handler = $this->getMock('TestParserByteIndex');
$handler->expects($this->any())->method('ignore')->will($this->returnValue(true));
$matches = array();
preg_match('/'.$pattern.'/',$doc,$matches,PREG_OFFSET_CAPTURE);
$handler->expects($this->once())->method('caught')
->with("FOO", DOKU_LEXER_SPECIAL, $matches[0][1])->will($this->returnValue(true));
$lexer = new Doku_Lexer($handler, "ignore");
$lexer->addSpecialPattern($pattern,'ignore','caught');
$this->assertTrue($lexer->parse($doc));
}
}
?>

View File

@ -15,23 +15,15 @@ require_once DOKU_INC . 'inc/parser/handler.php';
require_once DOKU_INC . 'inc/events.php';
require_once DOKU_INC . 'inc/mail.php';
//require_once DOKU . 'parser/renderer.php';
//Mock::generate('Doku_Renderer');
/**
* @package Doku
* @subpackage Tests
*/
class TestOfDoku_Parser extends UnitTestCase {
abstract class TestOfDoku_Parser extends PHPUnit_Framework_TestCase {
var $P;
var $H;
function TestOfDoku_Parser() {
$this->UnitTestCase('TestOfDoku_Parser');
}
function setup() {
$this->P = new Doku_Parser();
$this->H = new Doku_Handler();

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Eol extends TestOfDoku_Parser {
function TestOfDoku_Parser_Eol() {
$this->UnitTestCase('TestOfDoku_Parser_Eol');
}
function testEol() {
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("Foo\nBar");
@ -17,7 +13,7 @@ class TestOfDoku_Parser_Eol extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEolMultiple() {
@ -33,7 +29,7 @@ class TestOfDoku_Parser_Eol extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testWinEol() {
@ -46,7 +42,7 @@ class TestOfDoku_Parser_Eol extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testLinebreak() {
@ -61,7 +57,7 @@ class TestOfDoku_Parser_Eol extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testLinebreakPlusEol() {
@ -80,7 +76,7 @@ class TestOfDoku_Parser_Eol extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testLinebreakInvalid() {
@ -93,7 +89,7 @@ class TestOfDoku_Parser_Eol extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
function TestOfDoku_Parser_Footnote() {
$this->UnitTestCase('TestOfDoku_Parser_Footnote');
}
function setup() {
parent::setup();
$this->P->addMode('footnote',new Doku_Parser_Mode_Footnote());
@ -27,7 +23,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotAFootnote() {
@ -39,7 +35,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteLinefeed() {
@ -58,7 +54,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteNested() {
@ -76,7 +72,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteEol() {
@ -95,7 +91,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteStrong() {
@ -118,7 +114,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteHr() {
@ -139,7 +135,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteCode() {
@ -160,7 +156,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnotePreformatted() {
@ -181,7 +177,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnotePreformattedEol() {
@ -204,7 +200,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteUnformatted() {
@ -225,7 +221,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteNotHeader() {
@ -244,7 +240,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteTable() {
@ -290,7 +286,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteList() {
@ -332,7 +328,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteQuote() {
@ -361,7 +357,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteNesting() {
@ -386,7 +382,7 @@ class TestOfDoku_Parser_Footnote extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
function TestOfDoku_Parser_Headers() {
$this->UnitTestCase('TestOfDoku_Parser_Headers');
}
function testHeader1() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ====== Header ====== \n def");
@ -23,7 +19,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader2() {
@ -42,7 +38,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader3() {
@ -61,7 +57,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader4() {
@ -80,7 +76,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader5() {
@ -99,7 +95,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader2UnevenSmaller() {
@ -118,7 +114,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader2UnevenBigger() {
@ -137,7 +133,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeaderLarge() {
@ -156,7 +152,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeaderSmall() {
@ -169,7 +165,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
@ -189,7 +185,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader5Mixed() {
@ -208,7 +204,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeaderMultiline() {
@ -227,7 +223,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
# function testNoToc() {
@ -253,7 +249,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
@ -279,7 +275,7 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array())
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_i18n extends TestOfDoku_Parser {
function TestOfDoku_Parser_i18n() {
$this->UnitTestCase('TestOfDoku_Parser_i18n');
}
function testFormatting() {
$formats = array (
'strong', 'emphasis', 'underline', 'monospace',
@ -51,7 +47,7 @@ class TestOfDoku_Parser_i18n extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testHeader() {
@ -70,7 +66,7 @@ class TestOfDoku_Parser_i18n extends TestOfDoku_Parser {
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTable() {
@ -114,7 +110,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testAcronym() {
@ -130,7 +126,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testInterwiki() {
@ -145,7 +141,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLink() {
@ -160,7 +156,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
}

View File

@ -3,11 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
function TestOfDoku_Parser_Links() {
$this->UnitTestCase('TestOfDoku_Parser_Links');
}
function testExternalLinkSimple() {
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
$this->P->parse("Foo http://www.google.com Bar");
@ -20,7 +15,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalLinkCase() {
@ -35,7 +30,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalIPv4() {
@ -50,7 +45,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalIPv6() {
@ -65,7 +60,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalMulti(){
@ -95,8 +90,6 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
$source = "[[$link|$title]]";
$name = $title;
}
$this->signal('failinfo',$source);
$this->setup();
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
@ -110,7 +103,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls), $calls, $source);
$this->teardown();
}
}
@ -128,7 +121,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalWWWLink() {
@ -143,7 +136,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalFTPLink() {
@ -158,7 +151,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEmail() {
$this->P->addMode('emaillink',new Doku_Parser_Mode_Emaillink());
@ -172,7 +165,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEmailRFC2822() {
@ -187,7 +180,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEmailCase() {
@ -202,7 +195,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
@ -218,7 +211,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkNoChar() {
@ -233,7 +226,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkNamespaceNoTitle() {
@ -248,7 +241,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkNamespace() {
@ -263,7 +256,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkSectionRef() {
@ -278,7 +271,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalInInternalLink() {
@ -293,7 +286,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInterwikiLink() {
@ -308,7 +301,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInterwikiLinkCase() {
@ -323,7 +316,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInterwikiPedia() {
@ -338,7 +331,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testCamelCase() {
@ -353,7 +346,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testFileLink() {
@ -368,7 +361,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testFileLinkInternal() {
@ -383,7 +376,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testWindowsShareLink() {
@ -398,7 +391,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testWindowsShareLinkHyphen() {
@ -413,7 +406,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testWindowsShareLinkInternal() {
@ -428,7 +421,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternal() {
@ -443,7 +436,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalLinkOnly() {
@ -458,7 +451,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaNotImage() {
@ -473,7 +466,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalLAlign() {
@ -488,7 +481,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalRAlign() {
@ -503,7 +496,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalCenter() {
@ -518,7 +511,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalParams() {
@ -533,7 +526,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalTitle() {
@ -548,7 +541,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaExternal() {
@ -563,7 +556,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaExternalParams() {
@ -578,7 +571,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaExternalTitle() {
@ -594,7 +587,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInInternalLink() {
@ -621,7 +614,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaNoImageInInternalLink() {
@ -648,7 +641,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInEmailLink() {
@ -675,7 +668,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testNestedMedia() {
@ -691,7 +684,7 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
function TestOfDoku_Parser_Lists() {
$this->UnitTestCase('TestOfDoku_Parser_Lists');
}
function testUnorderedList() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse('
@ -37,7 +33,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testOrderedList() {
@ -70,7 +66,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
array('listo_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
@ -104,7 +100,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
array('listo_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListWinEOL() {
@ -133,7 +129,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testOrderedListWinEOL() {
@ -162,7 +158,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
array('listo_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotAList() {
@ -175,7 +171,7 @@ class TestOfDoku_Parser_Lists extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListParagraph() {
@ -215,7 +211,7 @@ Bar');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - formatting able to spread across list items
@ -250,7 +246,7 @@ Bar');
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - unformatted able to spread across list items
@ -281,7 +277,7 @@ Bar');
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListLinebreak() {
@ -317,7 +313,7 @@ Bar');
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListLinebreak2() {
@ -344,7 +340,7 @@ Bar');
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListFootnote() {
@ -391,7 +387,7 @@ Bar');
array('document_end',array())
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
function TestOfDoku_Parser_Preformatted() {
$this->UnitTestCase('TestOfDoku_Parser_Preformatted');
}
function testFile() {
$this->P->addMode('file',new Doku_Parser_Mode_File());
$this->P->parse('Foo <file>testing</file> Bar');
@ -22,7 +18,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCode() {
@ -39,7 +35,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCodeWhitespace() {
@ -56,7 +52,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCodeLang() {
@ -73,7 +69,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformatted() {
@ -90,7 +86,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedWinEOL() {
@ -107,7 +103,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedTab() {
@ -124,7 +120,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedTabWinEOL() {
@ -141,7 +137,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedList() {
@ -173,7 +169,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
// test for php
@ -190,7 +186,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
// test with for HTML
@ -207,7 +203,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
@ -229,7 +225,7 @@ class TestOfDoku_Parser_Preformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Quote extends TestOfDoku_Parser {
function TestOfDoku_Parser_Quote() {
$this->UnitTestCase('TestOfDoku_Parser_Quote');
}
function testQuote() {
$this->P->addMode('quote',new Doku_Parser_Mode_Quote());
$this->P->parse("abc\n> def\n>>ghi\nklm");
@ -27,7 +23,7 @@ class TestOfDoku_Parser_Quote extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testQuoteWinCr() {
@ -50,7 +46,7 @@ class TestOfDoku_Parser_Quote extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testQuoteMinumumContext() {
@ -67,7 +63,7 @@ class TestOfDoku_Parser_Quote extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testQuoteEol() {
@ -91,7 +87,7 @@ class TestOfDoku_Parser_Quote extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -9,10 +9,6 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
$conf['typography'] = 2;
}
function TestOfDoku_Parser_Quotes() {
$this->UnitTestCase('TestOfDoku_Parser_Quotes');
}
function testSingleQuoteOpening() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("Foo 'hello Bar");
@ -27,7 +23,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuoteOpeningSpecial() {
@ -44,7 +40,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuoteClosing() {
@ -61,7 +57,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuoteClosingSpecial() {
@ -78,7 +74,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuotes() {
@ -97,7 +93,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testApostrophe() {
@ -114,7 +110,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
@ -134,7 +130,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteOpening() {
@ -151,7 +147,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteOpeningSpecial() {
@ -168,7 +164,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteClosing() {
@ -185,7 +181,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteClosingSpecial() {
@ -202,7 +198,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuotes() {
@ -221,7 +217,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuotesSpecial() {
@ -240,7 +236,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testAllQuotes() {
@ -266,7 +262,7 @@ class TestOfDoku_Parser_Quotes extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -3,11 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
function TestOfDoku_Parser_Replacements() {
$this->UnitTestCase('TestOfDoku_Parser_Replacements');
}
function testSingleAcronym() {
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym(array('FOOBAR')));
$this->P->parse('abc FOOBAR xyz');
@ -22,7 +17,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testAlmostAnAcronym() {
@ -37,7 +32,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPickAcronymCorrectly() {
@ -54,7 +49,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleAcronyms() {
@ -73,7 +68,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
@ -97,7 +92,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleAcronymsWithSubset2() {
@ -120,7 +115,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleSmileyFail() {
@ -135,7 +130,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleSmiley() {
@ -152,7 +147,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleSmileysFail() {
@ -167,7 +162,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleSmileys() {
@ -186,7 +181,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testBackslashSmileyFail() {
@ -202,7 +197,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testBackslashSmiley() {
@ -220,7 +215,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleWordblock() {
@ -237,7 +232,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testWordblockCase() {
@ -254,7 +249,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleWordblock() {
@ -273,7 +268,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleEntity() {
@ -290,7 +285,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleEntities() {
@ -309,7 +304,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultiplyEntity() {
@ -326,7 +321,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultiplyEntityHex() {
@ -342,7 +337,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testHR() {
@ -360,7 +355,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testHREol() {
@ -378,7 +373,7 @@ class TestOfDoku_Parser_Replacements extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Table extends TestOfDoku_Parser {
function TestOfDoku_Parser_Table() {
$this->UnitTestCase('TestOfDoku_Parser_Table');
}
function testTable() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
@ -48,7 +44,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableWinEOL() {
@ -88,7 +84,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmptyTable() {
@ -113,7 +109,7 @@ def');
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableHeaders() {
@ -147,7 +143,7 @@ def');
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
@ -182,7 +178,7 @@ def');
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellSpan() {
@ -224,7 +220,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellRowSpan() {
@ -272,7 +268,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellAlignmentFormatting() {
@ -311,7 +307,7 @@ def');
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
@ -357,7 +353,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - formatting able to spread across cols
@ -412,7 +408,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - unformatted able to spread across cols
@ -463,7 +459,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableLinebreak() {
@ -511,7 +507,7 @@ def');
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - footnote able to spread across cols
@ -570,7 +566,7 @@ def');
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
}

View File

@ -3,10 +3,6 @@ require_once 'parser.inc.php';
class TestOfDoku_Parser_Unformatted extends TestOfDoku_Parser {
function TestOfDoku_Parser_Unformatted() {
$this->UnitTestCase('TestOfDoku_Parser_Unformatted');
}
function testNowiki() {
$this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
$this->P->parse("Foo <nowiki>testing</nowiki> Bar");
@ -20,7 +16,7 @@ class TestOfDoku_Parser_Unformatted extends TestOfDoku_Parser {
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
@ -36,7 +32,7 @@ class TestOfDoku_Parser_Unformatted extends TestOfDoku_Parser {
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls);
}
}

View File

@ -2,7 +2,7 @@
require_once DOKU_INC.'inc/init.php';
class parserutils_set_metadata_during_rendering_test extends UnitTestCase {
class parserutils_set_metadata_during_rendering_test extends DokuWikiTest {
// the id used for this test case
private $id;
// if the test case is currently running
@ -35,15 +35,15 @@ class parserutils_set_metadata_during_rendering_test extends UnitTestCase {
$plugin_controller = $this->plugin_controller;
// assert that all three calls to p_set_metadata have been successful
$this->assertEqual($newMeta['test_before_set'], 'test');
$this->assertEqual($newMeta['test_after_set'], 'test');
$this->assertEqual($newMeta['test_during_rendering'], 'test');
$this->assertEquals($newMeta['test_before_set'], 'test');
$this->assertEquals($newMeta['test_after_set'], 'test');
$this->assertEquals($newMeta['test_during_rendering'], 'test');
// clean up
$this->active = false;
// make sure the saved metadata is the one that has been rendered
$this->assertEqual($newMeta, p_get_metadata($this->id));
$this->assertEquals($newMeta, p_get_metadata($this->id));
saveWikiText($this->id, '', 'Test data remove');
}
@ -55,7 +55,7 @@ class parserutils_set_metadata_during_rendering_test extends UnitTestCase {
$key = array_pop(array_keys($meta));
$this->assertTrue(is_string($meta[$key])); // ensure we really have a key
// ensure that the metadata property hasn't been set previously
$this->assertNotEqual($meta[$key], p_get_metadata($this->id, $key));
$this->assertNotEquals($meta[$key], p_get_metadata($this->id, $key));
}
}
@ -71,7 +71,7 @@ class parserutils_set_metadata_during_rendering_test extends UnitTestCase {
$key = 'test_during_rendering';
p_set_metadata($this->id, array($key => 'test'), false, true);
// ensure that the metadata property hasn't been set previously
$this->assertNotEqual($key, p_get_metadata($this->id, $key));
$this->assertNotEquals($key, p_get_metadata($this->id, $key));
}
}

View File

@ -4,8 +4,6 @@ require_once DOKU_INC . 'inc/init.php';
require_once DOKU_INC . 'inc/RemoteAPICore.php';
require_once DOKU_INC . 'inc/auth/basic.class.php';
Mock::generate('Doku_Plugin_Controller');
class MockAuth extends auth_basic {
function isCaseSensitive() { return true; }
}
@ -116,7 +114,7 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin {
}
class remote_test extends UnitTestCase {
class remote_test extends DokuWikiTest {
var $originalConf;
var $userinfo;
@ -130,9 +128,11 @@ class remote_test extends UnitTestCase {
global $auth;
parent::setUp();
$pluginManager = new MockDoku_Plugin_Controller();
$pluginManager->setReturnValue('getList', array('testplugin'));
$pluginManager->setReturnValue('load', new remote_plugin_testplugin());
$pluginManager = $this->getMock('Doku_Plugin_Controller');
$pluginManager->expects($this->any())->method('getList')->will($this->returnValue(array('testplugin')));
$pluginManager->expects($this->any())->method('load')->will($this->returnValue(new remote_plugin_testplugin()));
$plugin_controller = $pluginManager;
$this->originalConf = $conf;
@ -160,7 +160,7 @@ class remote_test extends UnitTestCase {
sort($actual);
$expect = array('plugin.testplugin.method1', 'plugin.testplugin.method2', 'plugin.testplugin.methodString', 'plugin.testplugin.method2ext', 'plugin.testplugin.publicCall');
sort($expect);
$this->assertEqual($expect,$actual);
$this->assertEquals($expect,$actual);
}
function test_hasAccessSuccess() {
@ -213,10 +213,12 @@ class remote_test extends UnitTestCase {
$this->remote->forceAccess(); // no exception should occur
}
/**
* @expectedException RemoteException
*/
function test_forceAccessFail() {
global $conf;
$conf['remote'] = 0;
$this->expectException('RemoteException');
$this->remote->forceAccess();
}
@ -226,21 +228,23 @@ class remote_test extends UnitTestCase {
$remoteApi = new RemoteApi();
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
$this->assertEqual($remoteApi->call('wiki.stringTestMethod'), 'success');
$this->assertEqual($remoteApi->call('wiki.intTestMethod'), 42);
$this->assertEqual($remoteApi->call('wiki.floatTestMethod'), 3.14159265);
$this->assertEqual($remoteApi->call('wiki.dateTestMethod'), 2623452346);
$this->assertEqual($remoteApi->call('wiki.fileTestMethod'), 'file content');
$this->assertEqual($remoteApi->call('wiki.voidTestMethod'), null);
$this->assertEquals($remoteApi->call('wiki.stringTestMethod'), 'success');
$this->assertEquals($remoteApi->call('wiki.intTestMethod'), 42);
$this->assertEquals($remoteApi->call('wiki.floatTestMethod'), 3.14159265);
$this->assertEquals($remoteApi->call('wiki.dateTestMethod'), 2623452346);
$this->assertEquals($remoteApi->call('wiki.fileTestMethod'), 'file content');
$this->assertEquals($remoteApi->call('wiki.voidTestMethod'), null);
}
/**
* @expectedException RemoteException
*/
function test_generalCoreFunctionOnArgumentMismatch() {
global $conf;
$conf['remote'] = 1;
$remoteApi = new RemoteApi();
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
$this->expectException('RemoteException');
$remoteApi->call('wiki.voidTestMethod', array('something'));
}
@ -251,10 +255,10 @@ class remote_test extends UnitTestCase {
$remoteApi = new RemoteApi();
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
$this->assertEqual($remoteApi->call('wiki.oneStringArgMethod', array('string')), 'string');
$this->assertEqual($remoteApi->call('wiki.twoArgMethod', array('string', 1)), array('string' , 1));
$this->assertEqual($remoteApi->call('wiki.twoArgWithDefaultArg', array('string')), array('string', 'default'));
$this->assertEqual($remoteApi->call('wiki.twoArgWithDefaultArg', array('string', 'another')), array('string', 'another'));
$this->assertEquals($remoteApi->call('wiki.oneStringArgMethod', array('string')), 'string');
$this->assertEquals($remoteApi->call('wiki.twoArgMethod', array('string', 1)), array('string' , 1));
$this->assertEquals($remoteApi->call('wiki.twoArgWithDefaultArg', array('string')), array('string', 'default'));
$this->assertEquals($remoteApi->call('wiki.twoArgWithDefaultArg', array('string', 'another')), array('string', 'another'));
}
function test_pluginCallMethods() {
@ -262,18 +266,20 @@ class remote_test extends UnitTestCase {
$conf['remote'] = 1;
$remoteApi = new RemoteApi();
$this->assertEqual($remoteApi->call('plugin.testplugin.method1'), null);
$this->assertEqual($remoteApi->call('plugin.testplugin.method2', array('string', 7)), array('string', 7, false));
$this->assertEqual($remoteApi->call('plugin.testplugin.method2ext', array('string', 7, true)), array('string', 7, true));
$this->assertEqual($remoteApi->call('plugin.testplugin.methodString'), 'success');
$this->assertEquals($remoteApi->call('plugin.testplugin.method1'), null);
$this->assertEquals($remoteApi->call('plugin.testplugin.method2', array('string', 7)), array('string', 7, false));
$this->assertEquals($remoteApi->call('plugin.testplugin.method2ext', array('string', 7, true)), array('string', 7, true));
$this->assertEquals($remoteApi->call('plugin.testplugin.methodString'), 'success');
}
/**
* @expectedException RemoteException
*/
function test_notExistingCall() {
global $conf;
$conf['remote'] = 1;
$remoteApi = new RemoteApi();
$this->expectException('RemoteException');
$remoteApi->call('dose not exist');
}
@ -292,20 +298,24 @@ class remote_test extends UnitTestCase {
$this->assertTrue($remoteApi->call('plugin.testplugin.publicCall'));
}
/**
* @expectedException RemoteAccessDeniedException
*/
function test_publicCallCoreDeny() {
global $conf;
$conf['useacl'] = 1;
$remoteApi = new RemoteApi();
$remoteApi->getCoreMethods(new RemoteAPICoreTest());
$this->expectException('RemoteAccessDeniedException');
$remoteApi->call('wiki.stringTestMethod');
}
/**
* @expectedException RemoteAccessDeniedException
*/
function test_publicCallPluginDeny() {
global $conf;
$conf['useacl'] = 1;
$remoteApi = new RemoteApi();
$this->expectException('RemoteAccessDeniedException');
$remoteApi->call('plugin.testplugin.methodString');
}
@ -315,7 +325,7 @@ class remote_test extends UnitTestCase {
$remoteApi = new RemoteAPI();
$result = $remoteApi->call('custom.path');
$this->assertEqual($result, 'success');
$this->assertEquals($result, 'success');
}
function pluginCallCustomPathRegister(&$event, $param) {

View File

@ -4,7 +4,7 @@ if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
require_once DOKU_INC.'inc/utf8.php';
require_once DOKU_INC.'inc/SafeFN.class.php';
class safeFN_test extends UnitTestCase {
class safeFN_test extends DokuWikiTest {
function test1(){
@ -30,8 +30,8 @@ class safeFN_test extends UnitTestCase {
foreach($tests as $test){
list($utf8,$safe) = $test;
$this->assertEqual(SafeFN::encode($utf8),$safe);
$this->assertEqual(SafeFN::decode($safe),$utf8);
$this->assertEquals(SafeFN::encode($utf8),$safe);
$this->assertEquals(SafeFN::decode($safe),$utf8);
}
}
@ -40,7 +40,7 @@ class safeFN_test extends UnitTestCase {
foreach($tests as $test){
list($utf8,$safe) = $test;
$this->assertEqual(SafeFN::decode($safe),$utf8);
$this->assertEquals(SafeFN::decode($safe),$utf8);
}
}

View File

@ -1,7 +1,7 @@
<?php
require_once DOKU_INC.'inc/search.php';
require_once DOKU_INC.'inc/init.php';
class search_test extends UnitTestCase {
class search_test extends DokuWikiTest {
function strip_index_data($entry) {
$n_entry = array();
foreach(array('id', 'type', 'level', 'open') as $k) {
@ -14,7 +14,7 @@ class search_test extends UnitTestCase {
$data = array();
search($data, dirname(__FILE__) . '/data', 'search_index',
array('ns' => 'ns2'));
$this->assertEqual(array_map(array($this, 'strip_index_data'), $data),
$this->assertEquals(array_map(array($this, 'strip_index_data'), $data),
array(
array(
'id' => 'ns1',
@ -35,7 +35,7 @@ class search_test extends UnitTestCase {
$data = array();
search($data, dirname(__FILE__) . '/data', 'search_index',
array('ns' => 'ns1/ns3'));
$this->assertEqual(array_map(array($this, 'strip_index_data'), $data),
$this->assertEquals(array_map(array($this, 'strip_index_data'), $data),
array(
array(
'id' => 'ns1',
@ -76,7 +76,7 @@ class search_test extends UnitTestCase {
$data = array();
search($data, dirname(__FILE__) . '/data', 'search_index',
array('ns' => 'ns1/ns3', 'nofiles' => true));
$this->assertEqual(array_map(array($this, 'strip_index_data'), $data),
$this->assertEquals(array_map(array($this, 'strip_index_data'), $data),
array(
array(
'id' => 'ns1',

View File

@ -3,7 +3,7 @@
if(!defined('UTF8_NOMBSTRING')) define('UTF8_NOMBSTRING',1);
require_once DOKU_INC.'inc/utf8.php';
class utf8_correctidx_test extends UnitTestCase {
class utf8_correctidx_test extends DokuWikiTest {
function test_singlebyte(){
@ -16,7 +16,7 @@ class utf8_correctidx_test extends UnitTestCase {
$tests[] = array('aaживπά우리をあöä',1,true,1);
foreach($tests as $test){
$this->assertEqual(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
$this->assertEquals(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
}
}
@ -34,7 +34,7 @@ class utf8_correctidx_test extends UnitTestCase {
$tests[] = array('aaживπά우리をあöä',4,true,4);
foreach($tests as $test){
$this->assertEqual(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
$this->assertEquals(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
}
}
@ -54,7 +54,7 @@ class utf8_correctidx_test extends UnitTestCase {
$tests[] = array('aaживπά우리をあöä',13,true,13);
foreach($tests as $test){
$this->assertEqual(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
$this->assertEquals(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
}
}
@ -70,7 +70,7 @@ class utf8_correctidx_test extends UnitTestCase {
$tests[] = array('aaживπά우리をあöä',128,true,29);
foreach($tests as $test){
$this->assertEqual(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
$this->assertEquals(utf8_correctIdx($test[0],$test[1],$test[2]),$test[3]);
}
}

Some files were not shown because too many files have changed in this diff Show More