pax_global_header 0000666 0000000 0000000 00000000064 11343270035 0014510 g ustar 00root root 0000000 0000000 52 comment=d6c824bc110a9f2c475d125acfcbcbcf399539fe
splitbrain-dokuwiki-d6c824b/ 0000775 0000000 0000000 00000000000 11343270035 0016121 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/.gitignore 0000664 0000000 0000000 00000000475 11343270035 0020117 0 ustar 00root root 0000000 0000000 /conf/*.local.conf
/conf/acl.auth.php
/conf/local.php
/conf/local.protected.php
/conf/users.auth.php
/conf/user*.css
/conf/user*.js
/conf/words.aspell
.htaccess
*.swp
*.bak
*.old
*~
/data/attic/*
/data/cache/*
/data/index/*
/data/locks/*
/data/media/*
/data/meta/*
/data/pages/*
/data/tmp/*
/lib/tpl/*
/lib/plugins/*
splitbrain-dokuwiki-d6c824b/.htaccess.dist 0000664 0000000 0000000 00000002676 11343270035 0020674 0 ustar 00root root 0000000 0000000 ## Enable this to restrict editing to logged in users only
## You should disable Indexes and MultiViews either here or in the
## global config. Symlinks maybe needed for URL rewriting.
#Options -Indexes -MultiViews +FollowSymLinks
## make sure nobody gets the htaccess files
Order allow,deny
Deny from all
Satisfy All
## Uncomment these rules if you want to have nice URLs using
## $conf['userewrite'] = 1 - not needed for rewrite mode 2
#RewriteEngine on
#
## Not all installations will require the following line. If you do,
## change "/dokuwiki" to the path to your dokuwiki directory relative
## to your document root.
#RewriteBase /dokuwiki
#
## If you enable DokuWikis XML-RPC interface, you should consider to
## restrict access to it over HTTPS only! Uncomment the following two
## rules if your server setup allows HTTPS.
#RewriteCond %{HTTPS} !=on
#RewriteRule ^lib/exe/xmlrpc.php$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
#
#RewriteRule ^_media/(.*) lib/exe/fetch.php?media=$1 [QSA,L]
#RewriteRule ^_detail/(.*) lib/exe/detail.php?media=$1 [QSA,L]
#RewriteRule ^_export/([^/]+)/(.*) doku.php?do=export_$1&id=$2 [QSA,L]
#RewriteRule ^$ doku.php [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule (.*) doku.php?id=$1 [QSA,L]
#RewriteRule ^index.php$ doku.php
splitbrain-dokuwiki-d6c824b/COPYING 0000664 0000000 0000000 00000043110 11343270035 0017153 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
splitbrain-dokuwiki-d6c824b/README 0000664 0000000 0000000 00000000376 11343270035 0017007 0 ustar 00root root 0000000 0000000 All documentation for DokuWiki is available online
at http://www.dokuwiki.org/
For Installation Instructions see
http://www.dokuwiki.org/install
DokuWiki - 2004-2010 (c) Andreas Gohr
See COPYING and file headers for license info
splitbrain-dokuwiki-d6c824b/_cs/ 0000775 0000000 0000000 00000000000 11343270035 0016665 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/ 0000775 0000000 0000000 00000000000 11343270035 0020413 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/DokuWikiCodingStandard.php 0000664 0000000 0000000 00000007021 11343270035 0025457 0 ustar 00root root 0000000 0000000
*/
if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) {
throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_CodingStandard not found');
}
/**
* DokuWiki Coding Standard.
*
* @category PHP
* @package PHP_CodeSniffer
* @author Andreas Gohr
*/
class PHP_CodeSniffer_Standards_DokuWiki_DokuWikiCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard {
/**
* Return a list of external sniffs to include with this standard.
*
* @return array
*/
public function getIncludedSniffs() {
return array(
'Generic/Sniffs/Classes/DuplicateClassNameSniff.php',
'Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php',
'Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php',
'Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php',
'Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php',
'Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php',
'Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php',
'Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php',
'Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php',
'Generic/Sniffs/Commenting/TodoSniff.php',
'Generic/Sniffs/Files/LineEndingsSniff.php',
'Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php',
'Generic/Sniffs/Metrics/NestingLevelSniff.php',
// 'Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php', //FIXME we might need to tune this first
'Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
'Generic/Sniffs/PHP/LowerCaseConstantSniff.php',
'Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
'Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php',
'Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php',
'DokuWiki/Sniffs/WhiteSpace/ScopeIndentSniff.php',
'Zend/Sniffs/Files/ClosingTagSniff.php',
'PEAR/Sniffs/Functions/ValidDefaultValueSniff.php',
'Squiz/Sniffs/PHP/EvalSniff.php',
'Squiz/Sniffs/PHP/NonExecutableCodeSniff.php',
// 'Squiz/Sniffs/PHP/CommentedOutCodeSniff.php', //FIXME should ignore oneliners
'Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php',
'Squiz/Sniffs/PHP/NonExecutableCodeSniff.php',
'Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php',
'Squiz/Sniffs/CSS/MissingColonSniff.php',
'Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php',
'Squiz/Sniffs/CSS/ColonSpacingSniff.php',
'Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php',
'Squiz/Sniffs/CSS/SemicolonSpacingSniff.php',
'Squiz/Sniffs/CSS/IndentationSniff.php',
'Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php',
'Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php',
'Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php',
'Squiz/Sniffs/CSS/OpacitySniff.php',
'Squiz/Sniffs/CSS/ColourDefinitionSniff.php',
'Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php',
'Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php',
'Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php',
);
}
}//end class
splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/Sniffs/ 0000775 0000000 0000000 00000000000 11343270035 0021643 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/Sniffs/Functions/ 0000775 0000000 0000000 00000000000 11343270035 0023613 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/Sniffs/Functions/OpeningFunctionBraceSniff.php 0000664 0000000 0000000 00000005243 11343270035 0031360 0 ustar 00root root 0000000 0000000 getTokens();
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
return;
}
$openingBrace = $tokens[$stackPtr]['scope_opener'];
// The end of the function occurs at the end of the argument list. Its
// like this because some people like to break long function declarations
// over multiple lines.
$functionLine = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line'];
$braceLine = $tokens[$openingBrace]['line'];
$lineDifference = ($braceLine - $functionLine);
if ($lineDifference > 0) {
$error = 'Opening brace should be on the same line as the declaration';
$phpcsFile->addError($error, $openingBrace);
return;
}
// Checks that the closing parenthesis and the opening brace are
// separated by a whitespace character.
$closerColumn = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['column'];
$braceColumn = $tokens[$openingBrace]['column'];
$columnDifference = ($braceColumn - $closerColumn);
if ($columnDifference > 2) {
$error = 'Expected 0 or 1 space between the closing parenthesis and the opening brace; found '.($columnDifference - 1).'.';
$phpcsFile->addError($error, $openingBrace);
return;
}
// Check that a tab was not used instead of a space.
$spaceTokenPtr = ($tokens[$stackPtr]['parenthesis_closer'] + 1);
$spaceContent = $tokens[$spaceTokenPtr]['content'];
if ($columnDifference == 2 && $spaceContent !== ' ') {
$error = 'Expected a none or a single space character between closing parenthesis and opening brace; found "'.$spaceContent.'".';
$phpcsFile->addError($error, $openingBrace);
return;
}
}//end process()
}//end class
?>
splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/Sniffs/PHP/ 0000775 0000000 0000000 00000000000 11343270035 0022272 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/Sniffs/PHP/DiscouragedFunctionsSniff.php 0000664 0000000 0000000 00000003304 11343270035 0030113 0 ustar 00root root 0000000 0000000
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
* @version CVS: $Id: DiscouragedFunctionsSniff.php 265110 2008-08-19 06:36:11Z squiz $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
if (class_exists('Generic_Sniffs_PHP_ForbiddenFunctionsSniff', true) === false) {
throw new PHP_CodeSniffer_Exception('Class Generic_Sniffs_PHP_ForbiddenFunctionsSniff not found');
}
/**
* DokuWiki_Sniffs_PHP_DiscouragedFunctionsSniff.
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
* @version Release: 1.2.2
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class DokuWiki_Sniffs_PHP_DiscouragedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
{
/**
* A list of forbidden functions with their alternatives.
*
* The value is NULL if no alternative exists. IE, the
* function should just not be used.
*
* @var array(string => string|null)
*/
protected $forbiddenFunctions = array(
'date' => 'dformat',
'strftime' => 'dformat',
);
/**
* If true, an error will be thrown; otherwise a warning.
*
* @var bool
*/
protected $error = false;
}//end class
?>
splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/Sniffs/WhiteSpace/ 0000775 0000000 0000000 00000000000 11343270035 0023677 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_cs/DokuWiki/Sniffs/WhiteSpace/ScopeIndentSniff.php 0000664 0000000 0000000 00000027752 11343270035 0027626 0 ustar 00root root 0000000 0000000
* @author Greg Sherwood
* @author Marc McIntyre
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
* @version CVS: $Id: ScopeIndentSniff.php 270281 2008-12-02 02:38:34Z squiz $
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
/**
* Generic_Sniffs_Whitespace_ScopeIndentSniff.
*
* Checks that control structures are structured correctly, and their content
* is indented correctly.
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood
* @author Marc McIntyre
* @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
* @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
* @version Release: 1.2.0
* @link http://pear.php.net/package/PHP_CodeSniffer
*/
class DokuWiki_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
{
/**
* The number of spaces code should be indented.
*
* @var int
*/
protected $indent = 4;
/**
* Does the indent need to be exactly right.
*
* If TRUE, indent needs to be exactly $ident spaces. If FALSE,
* indent needs to be at least $ident spaces (but can be more).
*
* @var bool
*/
protected $exact = false;
/**
* Any scope openers that should not cause an indent.
*
* @var array(int)
*/
protected $nonIndentingScopes = array();
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
*/
public function register()
{
return PHP_CodeSniffer_Tokens::$scopeOpeners;
}//end register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// If this is an inline condition (ie. there is no scope opener), then
// return, as this is not a new scope.
if (isset($tokens[$stackPtr]['scope_opener']) === false) {
return;
}
if ($tokens[$stackPtr]['code'] === T_ELSE) {
$next = $phpcsFile->findNext(
PHP_CodeSniffer_Tokens::$emptyTokens,
($stackPtr + 1),
null,
true
);
// We will handle the T_IF token in another call to process.
if ($tokens[$next]['code'] === T_IF) {
return;
}
}
// Find the first token on this line.
$firstToken = $stackPtr;
for ($i = $stackPtr; $i >= 0; $i--) {
// Record the first code token on the line.
if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$emptyTokens) === false) {
$firstToken = $i;
}
// It's the start of the line, so we've found our first php token.
if ($tokens[$i]['column'] === 1) {
break;
}
}
// Based on the conditions that surround this token, determine the
// indent that we expect this current content to be.
$expectedIndent = $this->calculateExpectedIndent($tokens, $firstToken);
if ($tokens[$firstToken]['column'] !== $expectedIndent) {
if($this->exact || $tokens[$firstToken]['column'] < $expectedIndent){
$error = 'Line indented incorrectly; expected ';
$error .= ($expectedIndent - 1).' spaces, found ';
$error .= ($tokens[$firstToken]['column'] - 1);
$phpcsFile->addError($error, $stackPtr);
}elseif((($tokens[$firstToken]['column'] - 1) % $this->indent)){
$error = 'Line indented not by multiple of '.$this->indent.'; expected ';
$error .= ($expectedIndent - 1).' spaces, found ';
$error .= ($tokens[$firstToken]['column'] - 1);
$phpcsFile->addError($error, $stackPtr);
}
}
$scopeOpener = $tokens[$stackPtr]['scope_opener'];
$scopeCloser = $tokens[$stackPtr]['scope_closer'];
// Some scopes are expected not to have indents.
if (in_array($tokens[$firstToken]['code'], $this->nonIndentingScopes) === false) {
$indent = ($expectedIndent + $this->indent);
} else {
$indent = $expectedIndent;
}
$newline = false;
$commentOpen = false;
$inHereDoc = false;
// Only loop over the content beween the opening and closing brace, not
// the braces themselves.
for ($i = ($scopeOpener + 1); $i < $scopeCloser; $i++) {
// If this token is another scope, skip it as it will be handled by
// another call to this sniff.
if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$scopeOpeners) === true) {
if (isset($tokens[$i]['scope_opener']) === true) {
$i = $tokens[$i]['scope_closer'];
} else {
// If this token does not have a scope_opener indice, then
// it's probably an inline scope, so let's skip to the next
// semicolon. Inline scopes include inline if's, abstract
// methods etc.
$nextToken = $phpcsFile->findNext(T_SEMICOLON, $i, $scopeCloser);
if ($nextToken !== false) {
$i = $nextToken;
}
}
continue;
}
// If this is a HEREDOC then we need to ignore it as the
// whitespace before the contents within the HEREDOC are
// considered part of the content.
if ($tokens[$i]['code'] === T_START_HEREDOC) {
$inHereDoc = true;
continue;
} else if ($inHereDoc === true) {
if ($tokens[$i]['code'] === T_END_HEREDOC) {
$inHereDoc = false;
}
continue;
}
if ($tokens[$i]['column'] === 1) {
// We started a newline.
$newline = true;
}
if ($newline === true && $tokens[$i]['code'] !== T_WHITESPACE) {
// If we started a newline and we find a token that is not
// whitespace, then this must be the first token on the line that
// must be indented.
$newline = false;
$firstToken = $i;
$column = $tokens[$firstToken]['column'];
// Special case for non-PHP code.
if ($tokens[$firstToken]['code'] === T_INLINE_HTML) {
$trimmedContentLength
= strlen(ltrim($tokens[$firstToken]['content']));
if ($trimmedContentLength === 0) {
continue;
}
$contentLength = strlen($tokens[$firstToken]['content']);
$column = ($contentLength - $trimmedContentLength + 1);
}
// Check to see if this constant string spans multiple lines.
// If so, then make sure that the strings on lines other than the
// first line are indented appropriately, based on their whitespace.
if (in_array($tokens[$firstToken]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) {
if (in_array($tokens[($firstToken - 1)]['code'], PHP_CodeSniffer_Tokens::$stringTokens) === true) {
// If we find a string that directly follows another string
// then its just a string that spans multiple lines, so we
// don't need to check for indenting.
continue;
}
}
// This is a special condition for T_DOC_COMMENT and C-style
// comments, which contain whitespace between each line.
$comments = array(
T_COMMENT,
T_DOC_COMMENT
);
if (in_array($tokens[$firstToken]['code'], $comments) === true) {
$content = trim($tokens[$firstToken]['content']);
if (preg_match('|^/\*|', $content) !== 0) {
// Check to see if the end of the comment is on the same line
// as the start of the comment. If it is, then we don't
// have to worry about opening a comment.
if (preg_match('|\*/$|', $content) === 0) {
// We don't have to calculate the column for the
// start of the comment as there is a whitespace
// token before it.
$commentOpen = true;
}
} else if ($commentOpen === true) {
if ($content === '') {
// We are in a comment, but this line has nothing on it
// so let's skip it.
continue;
}
$contentLength = strlen($tokens[$firstToken]['content']);
$trimmedContentLength
= strlen(ltrim($tokens[$firstToken]['content']));
$column = ($contentLength - $trimmedContentLength + 1);
if (preg_match('|\*/$|', $content) !== 0) {
$commentOpen = false;
}
}//end if
}//end if
// The token at the start of the line, needs to have its' column
// greater than the relative indent we set above. If it is less,
// an error should be shown.
if ($column !== $indent) {
if ($this->exact === true || $column < $indent) {
$error = 'Line indented incorrectly; expected ';
if ($this->exact === false) {
$error .= 'at least ';
}
$error .= ($indent - 1).' spaces, found ';
$error .= ($column - 1);
$phpcsFile->addError($error, $firstToken);
}
}
}//end if
}//end for
}//end process()
/**
* Calculates the expected indent of a token.
*
* @param array $tokens The stack of tokens for this file.
* @param int $stackPtr The position of the token to get indent for.
*
* @return int
*/
protected function calculateExpectedIndent(array $tokens, $stackPtr)
{
$conditionStack = array();
// Empty conditions array (top level structure).
if (empty($tokens[$stackPtr]['conditions']) === true) {
return 1;
}
$tokenConditions = $tokens[$stackPtr]['conditions'];
foreach ($tokenConditions as $id => $condition) {
// If it's an indenting scope ie. it's not in our array of
// scopes that don't indent, add it to our condition stack.
if (in_array($condition, $this->nonIndentingScopes) === false) {
$conditionStack[$id] = $condition;
}
}
return ((count($conditionStack) * $this->indent) + 1);
}//end calculateExpectedIndent()
}//end class
?>
splitbrain-dokuwiki-d6c824b/_cs/README 0000664 0000000 0000000 00000000713 11343270035 0017546 0 ustar 00root root 0000000 0000000 This directory contains the Coding Standard tests to be used with PHP
CodeSniffer on DokuWiki's code.
1. Install PHP CodeSniffer:
#> pear install PHP_CodeSniffer
2. Link the Coding Standard to the CodeSniffer directory:
#> ln -s /path/to/dokuwiki/_cs/DokuWiki /usr/share/pear/PHP/CodeSniffer/Standards/DokuWiki
3. Set DokuWiki to be the default standard:
#> phpcs --config-set default_standard DokuWiki
The coding standard is work in progress.
splitbrain-dokuwiki-d6c824b/_test/ 0000775 0000000 0000000 00000000000 11343270035 0017237 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_test/README 0000664 0000000 0000000 00000005666 11343270035 0020134 0 ustar 00root root 0000000 0000000 --------------------------------------------------------------------------------
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.
splitbrain-dokuwiki-d6c824b/_test/cases/ 0000775 0000000 0000000 00000000000 11343270035 0020335 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_test/cases/inc/ 0000775 0000000 0000000 00000000000 11343270035 0021106 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_test/cases/inc/auth_aclcheck.test.php 0000664 0000000 0000000 00000026720 11343270035 0025362 0 ustar 00root root 0000000 0000000 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 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/auth_admincheck.test.php 0000664 0000000 0000000 00000003145 11343270035 0025707 0 ustar 00root root 0000000 0000000 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);
// admin or manager groups
$this->assertEqual(auth_ismanager('jill', array('admin'),false), true);
$this->assertEqual(auth_ismanager('jill', array('managers'),false), true);
}
function test_isadmin(){
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);
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/auth_nameencode.test.php 0000664 0000000 0000000 00000002345 11343270035 0025720 0 ustar 00root root 0000000 0000000 assertEqual(auth_nameencode($in),$out);
}
function test_quote(){
$in = 'hey"you';
$out = 'hey%22you';
$this->assertEqual(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);
}
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);
}
function test_groupskipon(){
$in = '@hey$you';
$out = '@hey%24you';
$this->assertEqual(auth_nameencode($in,true),$out);
}
function test_groupskipoff(){
$in = '@hey$you';
$out = '%40hey%24you';
$this->assertEqual(auth_nameencode($in),$out);
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/auth_password.test.php 0000664 0000000 0000000 00000002566 11343270035 0025471 0 ustar 00root root 0000000 0000000 '$1$abcdefgh$SYbjm2AEvSoHG7Xapi8so.',
'apr1' => '$apr1$abcdefgh$C/GzYTF4kOVByYLEoD5X4.',
'md5' => '8fa22d62408e5351553acdd91c6b7003',
'sha1' => 'b456d3b0efd105d613744ffd549514ecafcfc7e1',
'ssha' => '{SSHA}QMHG+uC7bHNYKkmoLbNsNI38/dJhYmNk',
'crypt' => 'ablvoGr1hvZ5k',
'mysql' => '4a1fa3780bd6fd55',
'my411' => '*e5929347e25f82e19e4ebe92f1dc6b6e7c2dbd29',
);
function test_cryptPassword(){
foreach($this->passes as $method => $hash){
$info = "testing method $method";
$this->signal('failinfo',$info);
$this->assertEqual(auth_cryptPassword('foo'.$method,$method,'abcdefgh'),$hash);
}
}
function test_verifyPassword(){
foreach($this->passes as $method => $hash){
$info = "testing method $method";
$this->signal('failinfo',$info);
$this->assertTrue(auth_verifyPassword('foo'.$method,$hash));
}
}
function test_verifyPassword_nohash(){
$this->assertTrue(auth_verifyPassword('foo','$1$$n1rTiFE0nRifwV/43bVon/'));
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/common_clientip.test.php 0000664 0000000 0000000 00000012670 11343270035 0025762 0 ustar 00root root 0000000 0000000 assertEqual(clientIP(),$out);
}
function test_proxy1_all(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_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);
}
function test_proxy2_all(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_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);
}
function test_proxyhops_all(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_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);
}
function test_simple_single(){
$_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(true),$out);
}
function test_proxy1_single(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_SERVER['HTTP_X_REAL_IP'] = '77.77.77.77';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '';
$out = '77.77.77.77';
$this->assertEqual(clientIP(true),$out);
}
function test_proxy2_single(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '77.77.77.77';
$out = '77.77.77.77';
$this->assertEqual(clientIP(true),$out);
}
function test_proxyhops_single(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_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);
}
function test_local_all(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_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);
}
function test_local1_single(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '127.0.0.1';
$out = '123.123.123.123';
$this->assertEqual(clientIP(true),$out);
}
function test_local2_single(){
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '123.123.123.123';
$out = '123.123.123.123';
$this->assertEqual(clientIP(true),$out);
}
function test_local3_single(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_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);
}
function test_local4_single(){
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '192.168.0.5';
$out = '192.168.0.5';
$this->assertEqual(clientIP(true),$out);
}
function test_garbage_all(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = 'some garbage, or something, 222';
$out = '123.123.123.123';
$this->assertEqual(clientIP(),$out);
}
function test_garbage_single(){
$_SERVER['REMOTE_ADDR'] = '123.123.123.123';
$_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);
}
function test_garbageonly_all(){
$_SERVER['REMOTE_ADDR'] = 'argh';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = 'some garbage, or something, 222';
$out = '0.0.0.0';
$this->assertEqual(clientIP(),$out);
}
function test_garbageonly_single(){
$_SERVER['REMOTE_ADDR'] = 'argh';
$_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);
}
function test_malicious(){
$_SERVER['REMOTE_ADDR'] = '';
$_SERVER['HTTP_X_REAL_IP'] = '';
$_SERVER['HTTP_X_FORWARDED_FOR'] = '';
$out = '0.0.0.0';
$this->assertEqual(clientIP(),$out);
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/common_obfuscate.test.php 0000664 0000000 0000000 00000001435 11343270035 0026123 0 ustar 00root root 0000000 0000000 assertEqual(obfuscate('jon-doe@example.com'), 'jon-doe@example.com');
}
function test_hex(){
global $conf;
$conf['mailguard'] = 'hex';
$this->assertEqual(obfuscate('jon-doe@example.com'),
'jon-doe@example.com');
}
function test_visible(){
global $conf;
$conf['mailguard'] = 'visible';
$this->assertEqual(obfuscate('jon-doe@example.com'), 'jon [dash] doe [at] example [dot] com');
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/form_form.test.php 0000664 0000000 0000000 00000010231 11343270035 0024560 0 ustar 00root root 0000000 0000000 'dw__testform', 'action' => '/test'));
$form->startFieldset('Test');
$form->addHidden('summary', 'changes &c');
$form->addElement(form_makeTextField('t', 'v', 'Text', 'text__id', 'block'));
$form->addElement(form_makeCheckboxField('r', '1', 'Check', 'check__id', 'simple'));
$form->addElement(form_makeButton('submit', 'save', 'Save', array('accesskey'=>'s')));
$form->addElement(form_makeButton('submit', 'cancel', 'Cancel'));
$form->endFieldset();
return $form;
}
function _realoutput() {
global $lang;
$realoutput = '\n";
return $realoutput;
}
function _ignoreTagWS($data){
return preg_replace('/>\s+','><',$data);
}
function test_form_print() {
$form = $this->_testform();
ob_start();
$form->printForm();
$output = ob_get_contents();
ob_end_clean();
$form->addHidden('sectok', getSecurityToken());
$this->assertEqual($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',
'_text'=>'Text',
'_class'=>'block',
'id'=>'text__id',
'name'=>'t',
'value'=>'v',
'class'=>'edit'));
$e2 =& $form->getElementAt(99);
$this->assertEqual($e2, array('_elem'=>'closefieldset'));
}
function test_find_element_by_type() {
$form = $this->_testform();
$this->assertEqual($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->assertFalse($form->findElementById('dw__testform'));
}
function test_find_element_by_attribute() {
$form = $this->_testform();
$this->assertEqual($form->findElementByAttribute('value','Cancel'), 4);
$this->assertFalse($form->findElementByAttribute('name','cancel'));
}
function test_close_fieldset() {
$form = new Doku_Form(array('id' => 'dw__testform', 'action' => '/test'));
$form->startFieldset('Test');
$form->addHidden('summary', 'changes &c');
$form->addElement(form_makeTextField('t', 'v', 'Text', 'text__id', 'block'));
$form->addElement(form_makeCheckboxField('r', '1', 'Check', 'check__id', 'simple'));
$form->addElement(form_makeButton('submit', 'save', 'Save', array('accesskey'=>'s')));
$form->addElement(form_makeButton('submit', 'cancel', 'Cancel'));
ob_start();
$form->printForm();
$output = ob_get_contents();
ob_end_clean();
$this->assertEqual($this->_ignoreTagWS($output),$this->_ignoreTagWS($this->_realoutput()));
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/html_hilight.test.php 0000664 0000000 0000000 00000005106 11343270035 0025253 0 ustar 00root root 0000000 0000000 assertPattern(
'/Foo bar<\/span> Foo/',
html_hilight($html,'bar')
);
}
function testHighlightTwoWords() {
$html = 'Foo bar Foo php Foo';
$this->assertPattern(
'/Foo bar<\/span> Foo php<\/span> Foo/',
html_hilight($html,array('bar','php'))
);
}
function testHighlightTwoWordsHtml() {
$html = 'Foo barFoo php Foo';
$this->assertPattern(
'/Foo bar<\/span><\/b> Foo<\/i> 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 $_GET[\'bar\'] Foo',
html_hilight($html,'$_GET[\'bar\']')
);
}
function testMatchAttribute() {
$html = 'Foo bar Foo';
$this->assertPattern(
'/Foo bar<\/b> Foo/',
html_hilight($html,'class="x"')
);
}
function testMatchAttributeWord() {
$html = 'Foo bar Foo';
$this->assertEqual(
'Foo bar 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/')
);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/init_fullpath.test.php 0000664 0000000 0000000 00000007304 11343270035 0025443 0 ustar 00root root 0000000 0000000 '/foo/bar/baz',
'/foo//bar/baz' => '/foo/bar/baz',
'/foo/../bar/baz' => '/bar/baz',
'/foo/./bar/baz' => '/foo/bar/baz',
'/foo/bar/..' => '/foo',
'/foo/bar/../../../baz' => '/baz',
'foo/bar/baz' => '/absolute/path/foo/bar/baz',
'foo//bar/baz' => '/absolute/path/foo/bar/baz',
'foo/../bar/baz' => '/absolute/path/bar/baz',
'foo/./bar/baz' => '/absolute/path/foo/bar/baz',
'foo/bar/..' => '/absolute/path/foo',
'foo/bar/../../../baz' => '/absolute/baz',
);
foreach($tests as $from => $to){
$info = "Testing '$from' resulted in '".fullpath($from)."'";
$this->signal('failinfo',$info);
$this->assertEqual(fullpath($from),$to);
}
$_SERVER['SCRIPT_FILENAME'] = $base;
unset($GLOBALS['DOKU_UNITTEST_ASSUME_WINDOWS']);
}
function test_windows_paths(){
$base = $_SERVER['SCRIPT_FILENAME'];
$_SERVER['SCRIPT_FILENAME'] = '/absolute/path/self.php';
$GLOBALS['DOKU_UNITTEST_ASSUME_WINDOWS'] = true;
// paths to check
$tests = array(
'c:foo/bar/baz' => 'c:/foo/bar/baz',
'c:foo//bar/baz' => 'c:/foo/bar/baz',
'c:foo/../bar/baz' => 'c:/bar/baz',
'c:foo/./bar/baz' => 'c:/foo/bar/baz',
'c:foo/bar/..' => 'c:/foo',
'c:foo/bar/../../../baz' => 'c:/baz',
'c:/foo/bar/baz' => 'c:/foo/bar/baz',
'c:/foo//bar/baz' => 'c:/foo/bar/baz',
'c:/foo/../bar/baz' => 'c:/bar/baz',
'c:/foo/./bar/baz' => 'c:/foo/bar/baz',
'c:/foo/bar/..' => 'c:/foo',
'c:/foo/bar/../../../baz' => 'c:/baz',
'c:\\foo\\bar\\baz' => 'c:/foo/bar/baz',
'c:\\foo\\\\bar\\baz' => 'c:/foo/bar/baz',
'c:\\foo\\..\\bar\\baz' => 'c:/bar/baz',
'c:\\foo\\.\\bar\\baz' => 'c:/foo/bar/baz',
'c:\\foo\\bar\\..' => 'c:/foo',
'c:\\foo\\bar\\..\\..\\..\\baz' => 'c:/baz',
'\\\\server\\share/foo/bar/baz' => '\\\\server\\share/foo/bar/baz',
'\\\\server\\share/foo//bar/baz' => '\\\\server\\share/foo/bar/baz',
'\\\\server\\share/foo/../bar/baz' => '\\\\server\\share/bar/baz',
'\\\\server\\share/foo/./bar/baz' => '\\\\server\\share/foo/bar/baz',
'\\\\server\\share/foo/bar/..' => '\\\\server\\share/foo',
'\\\\server\\share/foo/bar/../../../baz' => '\\\\server\\share/baz',
);
foreach($tests as $from => $to){
$info = "Testing '$from' resulted in '".fullpath($from)."'";
$this->signal('failinfo',$info);
$this->assertEqual(fullpath($from),$to);
}
$_SERVER['SCRIPT_FILENAME'] = $base;
unset($GLOBALS['DOKU_UNITTEST_ASSUME_WINDOWS']);
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/init_getbaseurl.test.php 0000664 0000000 0000000 00000023767 11343270035 0025774 0 ustar 00root root 0000000 0000000
*/
function test1(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['HTTP_HOST'] = 'xerxes.my.home';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php?do=debug';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = null;
$_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
}
/**
* Apache, CGI, mod_userdir, subdirectory
*
* data provided by Hilko Bengen
*/
function test2(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/var/www/localhost';
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_FILENAME'] = '/usr/lib/cgi-bin/php4';
$_SERVER['REQUEST_URI'] = '/~bengen/dokuwiki/doku.php?do=debug';
$_SERVER['SCRIPT_NAME'] = '/cgi-bin/php4';
$_SERVER['PATH_INFO'] = '/~bengen/dokuwiki/doku.php';
$_SERVER['PATH_TRANSLATED'] = '/home/bengen/public_html/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/~bengen/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/~bengen/dokuwiki/');
}
/**
* Apache, FastCGI, mod_userdir, subdirectory
*
* data provided by Hilko Bengen
*/
function test3(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/var/www/localhost';
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_FILENAME'] = '/var/run/php-fastcgi/fcgi-bin/bengen/php4';
$_SERVER['REQUEST_URI'] = '/~bengen/dokuwiki/doku.php?do=debug';
$_SERVER['SCRIPT_NAME'] = '/fcgi-bin/php4-bengen';
$_SERVER['PATH_INFO'] = '/~bengen/dokuwiki/doku.php';
$_SERVER['PATH_TRANSLATED'] = '/home/bengen/public_html/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/~bengen/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/~bengen/dokuwiki/');
}
/**
* Apache, mod_php, mod_userdir, subdirectory
*
* data provided by Hilko Bengen
*/
function test4(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/var/www/localhost';
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_FILENAME'] = '/home/bengen/public_html/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/~bengen/dokuwiki/doku.php?do=debug';
$_SERVER['SCRIPT_NAME'] = '/~bengen/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = null;
$_SERVER['PATH_TRANSLATED'] = '/home/bengen/public_html/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/~bengen/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/~bengen/dokuwiki/');
}
/**
* IIS
*
* data provided by David Mach
*/
function test5(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = null;
$_SERVER['HTTP_HOST'] = 'intranet';
$_SERVER['SCRIPT_FILENAME'] = null;
$_SERVER['REQUEST_URI'] = null;
$_SERVER['SCRIPT_NAME'] = '/wiki/doku.php';
$_SERVER['PATH_INFO'] = '/wiki/doku.php';
$_SERVER['PATH_TRANSLATED'] = 'C:\\Inetpub\\wwwroot\\wiki\\doku.php';
$_SERVER['PHP_SELF'] = '/wiki/doku.php';
$this->assertEqual(getBaseURL(),'/wiki/');
}
/**
* Apache 2, mod_php, real URL rewriting, useslash (bug #292)
*
* data provided by Ted
*/
function test6(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/home/websites/wiki/htdocs';
$_SERVER['HTTP_HOST'] = 'wiki.linuxwan.net';
$_SERVER['SCRIPT_FILENAME'] = '/home/websites/wiki/htdocs/doku.php';
$_SERVER['REQUEST_URI'] = '/wiki/syntax?do=debug';
$_SERVER['SCRIPT_NAME'] = '/wiki/syntax';
$_SERVER['PATH_INFO'] = null;
$_SERVER['PATH_TRANSLATED'] = null;
$_SERVER['PHP_SELF'] = '/wiki/syntax';
$this->assertEqual(getBaseURL(),'/');
}
/**
* lighttpd, fastcgi
*
* data provided by Andreas Gohr
*/
function test7(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php?do=debug';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = '';
$_SERVER['PATH_TRANSLATED'] = null;
$_SERVER['PHP_SELF'] = '';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
}
/**
* Apache, mod_php, Pseudo URL rewrite, useslash
*
* data provided by Andreas Gohr
*/
function test8(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['HTTP_HOST'] = 'xerxes.my.home';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/wiki/syntax?do=debug';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = '/wiki/syntax';
$_SERVER['PATH_TRANSLATED'] = '/var/www/wiki/syntax';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki/syntax';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
}
/**
* Apache, mod_php, real URL rewrite, useslash
*
* data provided by Andreas Gohr
*/
function test9(){
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$conf['canonical'] = 0;
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['HTTP_HOST'] = 'xerxes.my.home';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/wiki/syntax?do=debug';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = null;
$_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php';
$this->assertEqual(getBaseURL(),'/dokuwiki/');
}
/**
* Possible user settings of $conf['baseurl'] & absolute baseURL required
*
* data provided by Andreas Gohr
*/
function test10(){
// values for $conf['baseurl'] and expected results
$tests = array(
'http://www.mysite.com' => 'http://www.mysite.com/dokuwiki/',
'http://www.mysite.com/' => 'http://www.mysite.com/dokuwiki/',
'http://www.mysite.com/path/to/wiki' => 'http://www.mysite.com/path/to/wiki/dokuwiki/',
'http://www.mysite.com/path/to/wiki/' => 'http://www.mysite.com/path/to/wiki/dokuwiki/',
);
global $conf;
$conf['basedir'] = '';
$conf['baseurl'] = '';
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['HTTP_HOST'] = 'xerxes.my.home';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/wiki/syntax?do=debug';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = null;
$_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php';
foreach ($tests as $test => $correct_result) {
$conf['baseurl'] = $test;
$this->assertEqual(getBaseURL(true),$correct_result);
}
}
/**
* Possible user settings of $conf['baseurl'] & absolute baseURL required
*
* data provided by Andreas Gohr
*/
function test11(){
// values for $conf['baseurl'] and expected results
$tests = array(
'http://www.mysite.com' => 'http://www.mysite.com/dokuwiki/',
'http://www.mysite.com/' => 'http://www.mysite.com/dokuwiki/',
'http://www.mysite.com/path/to/wiki' => 'http://www.mysite.com/path/to/wiki/dokuwiki/',
'http://www.mysite.com/path/to/wiki/' => 'http://www.mysite.com/path/to/wiki/dokuwiki/',
);
global $conf;
$conf['basedir'] = '/dokuwiki';
$conf['baseurl'] = '';
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['HTTP_HOST'] = 'xerxes.my.home';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/wiki/syntax?do=debug';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['PATH_INFO'] = null;
$_SERVER['PATH_TRANSLATED'] = '/var/www/dokuwiki/doku.php';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php';
foreach ($tests as $test => $correct_result) {
$conf['baseurl'] = $test;
$this->assertEqual(getBaseURL(true),$correct_result);
}
}
}
//Setup VIM: ex: et ts=2 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/mail_isvalid.test.php 0000664 0000000 0000000 00000010057 11343270035 0025235 0 ustar 00root root 0000000 0000000 @example.com', false); // Disallowed Characters
$tests[] = array('test@.', false);
$tests[] = array('test@example.', false);
$tests[] = array('test@.org', false);
$tests[] = array('12345678901234567890123456789012345678901234567890123456789012345@example.com', false); // 64 characters is maximum length for local part. This is 65.
$tests[] = array('test@123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.com', false); // 255 characters is maximum length for domain. This is 256.
$tests[] = array('test@example', false);
$tests[] = array('test@[123.123.123.123', false);
$tests[] = array('test@123.123.123.123]', false);
foreach($tests as $test){
$info = 'Testing '.$test[0];
$this->signal('failinfo',$info);
if($test[1]){
$this->assertTrue((bool) mail_isvalid($test[0]));
}else{
$this->assertFalse((bool) mail_isvalid($test[0]));
}
}
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/mail_quoted_printable_encode.php 0000664 0000000 0000000 00000003202 11343270035 0027474 0 ustar 00root root 0000000 0000000 assertEqual(mail_quotedprintable_encode($in),$out);
}
function test_spaceend(){
$in = "hello \nhello";
$out = "hello=20\nhello";
$this->assertEqual(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);
}
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);
}
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);
}
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);
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/mail_send.php 0000664 0000000 0000000 00000003353 11343270035 0023556 0 ustar 00root root 0000000 0000000 ',
'dokuwiki1@spam.la, dokuwiki2@spam.la',
'Test User 1 , Test User 2 '
);
$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" ',
'subject' => 'mailtest 3-'.$run,
'body' => "Mailtest run 3-$run using to: $ad from: \"Foo Bar\" ",
);
$this->assertTrue((bool) _mail_send_action($data));
}
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/pageutils_clean_id.test.php 0000664 0000000 0000000 00000010655 11343270035 0026417 0 ustar 00root root 0000000 0000000 assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
$conf['useslash'] = 1;
$tests = array();
$tests[] = array('page/page',false,'page:page');
$this->teardown();
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
}
function test_sepchar(){
// we test multiple cases here
// format: $id, $ascii, $correct_output
$tests = array();
global $conf;
$conf['sepchar'] = '-';
$conf['deaccent'] = 1;
$tests[] = array('pa-ge',false,'pa-ge');
$tests[] = array('pa%ge',false,'pa-ge');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
}
function test_deaccent_keep(){
// we test multiple cases here
// format: $id, $ascii, $correct_output
$tests = array();
global $conf;
$conf['sepchar'] = '_';
$conf['deaccent'] = 0;
$tests[] = array('pà ge',false,'pà ge');
$tests[] = array('pagÄ–',false,'pagÄ—');
$tests[] = array('pagĒēĔĕĖėĘęĚě',false,'pagēēĕĕėėęęěě');
$tests[] = array('Úš',false,'Úš');
$tests[] = array('ښ侧化并곦à¦à´ˆÎ²',false,'ښ侧化并곦à¦à´ˆÎ²');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
}
function test_deaccent_romanize(){
// we test multiple cases here
// format: $id, $ascii, $correct_output
$tests = array();
global $conf;
$conf['sepchar'] = '_';
$conf['deaccent'] = 2;
$tests[] = array('pà ge',false,'page');
$tests[] = array('pagÄ–',false,'page');
$tests[] = array('pagĒēĔĕĖėĘęĚě',false,'pageeeeeeeeee');
$tests[] = array('Úš',false,'Úš');
$tests[] = array('ښ侧化并곦à¦à´ˆÎ²',false,'ښ侧化并곦à¦à´ˆÎ²');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
}
function test_deaccent_ascii(){
// we test multiple cases here
// format: $id, $ascii, $correct_output
$tests = array();
global $conf;
$conf['sepchar'] = '_';
$conf['deaccent'] = 0;
$tests[] = array('pà ge',true,'page');
$tests[] = array('pagÄ–',true,'page');
$tests[] = array('pagĒēĔĕĖėĘęĚě',true,'pageeeeeeeeee');
$tests[] = array('Úš',true,'');
$tests[] = array('ښ侧化并곦à¦à´ˆÎ²',true,'');
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
$conf['deaccent'] = 1;
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
$conf['deaccent'] = 2;
foreach($tests as $test){
$this->assertEqual(cleanID($test[0],$test[1]),$test[2]);
}
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/pageutils_getid.test.php 0000664 0000000 0000000 00000007613 11343270035 0025755 0 ustar 00root root 0000000 0000000
*/
function test1(){
global $conf;
$conf['basedir'] = '//';
$conf['userewrite'] = 2;
$conf['deaccent'] = 0; // the default (1) gives me strange exceptions
$_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');
}
/**
* getID with internal mediafile, urlrewrite=2, no basedir set, apache, mod_php
*/
function test2(){
global $conf;
$conf['basedir'] = '';
$conf['userewrite'] = '2';
$conf['baseurl'] = '';
$conf['useslash'] = '1';
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['HTTP_HOST'] = 'xerxes.my.home';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/lib/exe/detail.php';
$_SERVER['PHP_SELF'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png';
$_SERVER['REQUEST_URI'] = '/dokuwiki/lib/exe/detail.php/wiki/discussion/button-dw.png?id=test&debug=1';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/lib/exe/detail.php';
$_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');
}
/**
* getID with given id in url and userewrite=2, no basedir set, dokuwiki not in document root.
*/
function test3() {
global $conf;
$conf['basedir'] = '';
$conf['userewrite'] = '2';
$conf['baseurl'] = '';
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['SCRIPT_FILENAME'] = '/usr/share/dokuwiki/doku.php';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/wiki:dokuwiki';
$_SERVER['PATH_INFO'] = '/wiki:dokuwiki';
$_SERVER['PATH_TRANSLATED'] = '/var/www/wiki:dokuwiki';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/wiki:dokuwiki';
$this->assertEqual(getID(), 'wiki:dokuwiki');
}
/**
* getID with given id in url and userewrite=2, no basedir set, Apache and CGI.
*/
function test4() {
global $conf;
$conf['basedir'] = '';
$conf['userewrite'] = '2';
$conf['baseurl'] = '';
$_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';
$_SERVER['REQUEST_URI'] = '/doku.php/wiki/dokuwiki';
$_SERVER['PATH_INFO'] = '/wiki/dokuwiki';
$_SERVER['PATH_TRANSLATED'] = '/var/www/vhosts/example.com/htdocs/doku.php';
$_SERVER['PHP_SELF'] = '/doku.php/wiki/dokuwiki';
$this->assertEqual(getID(), 'wiki:dokuwiki');
}
/**
* getID with given id / in url and userewrite=2, no basedir set, Apache and CGI.
*/
function test5() {
global $conf;
$conf['basedir'] = '';
$conf['userewrite'] = '2';
$conf['baseurl'] = '';
$_SERVER['DOCUMENT_ROOT'] = '/var/www/';
$_SERVER['SCRIPT_FILENAME'] = '/var/www/dokuwiki/doku.php';
$_SERVER['SCRIPT_NAME'] = '/dokuwiki/doku.php';
$_SERVER['REQUEST_URI'] = '/dokuwiki/doku.php/?do=debug';
$_SERVER['PATH_INFO'] = '/';
$_SERVER['PATH_TRANSLATED'] = '/var/www/index.html';
$_SERVER['PHP_SELF'] = '/dokuwiki/doku.php/';
$this->assertEqual(getID(), 'start');
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/pageutils_resolve_id.test.php 0000664 0000000 0000000 00000003040 11343270035 0027002 0 ustar 00root root 0000000 0000000 assertEqual(resolve_id($test[0],$test[1]),$test[2]);
}
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/pageutils_resolve_pageid.test.php 0000664 0000000 0000000 00000004074 11343270035 0027647 0 ustar 00root root 0000000 0000000 assertEqual($page,$test[2]);
}
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/ 0000775 0000000 0000000 00000000000 11343270035 0022402 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/.htaccess 0000664 0000000 0000000 00000000105 11343270035 0024174 0 ustar 00root root 0000000 0000000 ## no access to the inc directory
order allow,deny
allow from all
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/lexer.group.php 0000664 0000000 0000000 00000000560 11343270035 0025366 0 ustar 00root root 0000000 0000000 GroupTest('LexerGroupTest');
$this->addTestFile(dirname(__FILE__).'/lexer.test.php');
}
}
?>
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/lexer.test.php 0000664 0000000 0000000 00000052623 11343270035 0025220 0 ustar 00root root 0000000 0000000 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("(?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 = "aaabcdeee";
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("", DOKU_LEXER_ENTER, strpos($doc,''))
);
$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("", DOKU_LEXER_EXIT, strpos($doc,''))
);
$handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern("", "ignore", "caught");
$lexer->addExitPattern("", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookaheadEqual() {
$doc = "aaabcdeee";
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("", DOKU_LEXER_ENTER, strpos($doc,''))
);
$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("", DOKU_LEXER_EXIT, strpos($doc,''))
);
$handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('(?=.*)', "ignore", "caught");
$lexer->addExitPattern("", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookaheadNotEqual() {
$doc = "aaabcdeee";
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("", DOKU_LEXER_ENTER, strpos($doc,''))
);
$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("", DOKU_LEXER_EXIT, strpos($doc,''))
);
$handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('(?!foo)', "ignore", "caught");
$lexer->addExitPattern("", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookbehindEqual() {
$doc = "aaabcdeee";
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("", DOKU_LEXER_ENTER, strpos($doc,''))
);
$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("", DOKU_LEXER_EXIT, strpos($doc,''))
);
$handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('', "ignore", "caught");
$lexer->addExitPattern("(?<=d)", "caught");
$lexer->addSpecialPattern('b','caught','special');
$lexer->mapHandler('special','caught');
$lexer->addPattern('c','caught');
$this->assertTrue($lexer->parse($doc));
$handler->tally();
}
function testIndexLookbehindNotEqual() {
$doc = "aaabcdeee";
$handler = &new MockTestParserByteIndex($this);
$handler->setReturnValue("ignore", true);
$handler->setReturnValue("caught", true);
$handler->expectArgumentsAt(
0,
"caught",
array("", DOKU_LEXER_ENTER, strpos($doc,''))
);
$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("", DOKU_LEXER_EXIT, strpos($doc,''))
);
$handler->expectCallCount("caught", 5);
$lexer = &new Doku_Lexer($handler, "ignore");
$lexer->addEntryPattern('', "ignore", "caught");
$lexer->addExitPattern("(?", "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();
}
}
?>
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser.group.php 0000664 0000000 0000000 00000002174 11343270035 0025546 0 ustar 00root root 0000000 0000000 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');
}
}
?>
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser.inc.php 0000664 0000000 0000000 00000002116 11343270035 0025157 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser');
}
function setup() {
$this->P = & new Doku_Parser();
$this->H = & new Doku_Handler();
$this->P->Handler = & $this->H;
}
function tearDown() {
unset($this->P);
unset($this->H);
}
}
function stripByteIndex($call) {
unset($call[2]);
if ($call[0] == "nest") {
$call[1][0] = array_map('stripByteIndex',$call[1][0]);
}
return $call;
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_eol.test.php 0000664 0000000 0000000 00000007015 11343270035 0026227 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Eol');
}
function testEol() {
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("Foo\nBar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("Foo".DOKU_PARSER_EOL."Bar".DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEolMultiple() {
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("Foo\n\nbar\nFoo");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("Foo")),
array('p_close',array()),
array('p_open',array()),
array('cdata',array("bar".DOKU_PARSER_EOL."Foo".DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testWinEol() {
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("Foo\r\nBar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("Foo".DOKU_PARSER_EOL."Bar".DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testLinebreak() {
$this->P->addMode('linebreak',new Doku_Parser_Mode_Linebreak());
$this->P->parse('Foo\\\\ Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nFoo")),
array('linebreak',array()),
array('cdata',array("Bar\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testLinebreakPlusEol() {
$this->P->addMode('linebreak',new Doku_Parser_Mode_Linebreak());
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse('Foo\\\\'."\n\n".'Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("Foo")),
array('linebreak',array()),
array('p_close',array()),
array('p_open',array()),
array('cdata',array("Bar".DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testLinebreakInvalid() {
$this->P->addMode('linebreak',new Doku_Parser_Mode_Linebreak());
$this->P->parse('Foo\\\\Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo\\\\Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_footnote.test.php 0000664 0000000 0000000 00000035442 11343270035 0027312 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Footnote');
}
function setup() {
parent::setup();
$this->P->addMode('footnote',new Doku_Parser_Mode_Footnote());
}
function testFootnote() {
$this->P->parse('Foo (( testing )) Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' testing ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotAFootnote() {
$this->P->parse("Foo (( testing\n Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nFoo (( testing\n Bar\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteLinefeed() {
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("Foo (( testing\ntesting )) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array('Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(" testing\ntesting ")),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'.DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteNested() {
$this->P->parse('Foo (( x((y))z )) Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' x((y')),
array('footnote_close',array()),
))),
array('cdata',array('z )) Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteEol() {
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("Foo \nX(( test\ning ))Y\n Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array('Foo '.DOKU_PARSER_EOL.'X')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(" test\ning ")),
array('footnote_close',array()),
))),
array('cdata',array('Y'.DOKU_PARSER_EOL.' Bar'.DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteStrong() {
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse('Foo (( **testing** )) Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' ')),
array('strong_open',array()),
array('cdata',array('testing')),
array('strong_close',array()),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteHr() {
$this->P->addMode('hr',new Doku_Parser_Mode_HR());
$this->P->parse("Foo (( \n ---- \n )) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' ')),
array('hr',array()),
array('cdata',array("\n ")),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteCode() {
$this->P->addMode('code',new Doku_Parser_Mode_Code());
$this->P->parse("Foo (( Test )) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' ')),
array('code',array('Test',null,null)),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnotePreformatted() {
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->parse("Foo (( \n Test\n )) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' ')),
array('preformatted',array('Test')),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnotePreformattedEol() {
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("Foo (( \n Test\n )) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array('Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' ')),
array('preformatted',array('Test')),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'.DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteUnformatted() {
$this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
$this->P->parse("Foo (( Test )) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' ')),
array('unformatted',array('Test')),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteNotHeader() {
$this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
$this->P->parse("Foo (( \n====Test====\n )) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(" \n====Test====\n ")),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteTable() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse("Foo ((
| Row 0 Col 1 | Row 0 Col 2 | Row 0 Col 3 |
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
)) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('table_open',array(3, 2, 8)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(123)),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteList() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse("Foo ((
*A
* B
* C
)) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteQuote() {
$this->P->addMode('quote',new Doku_Parser_Mode_Quote());
$this->P->parse("Foo ((
> def
>>ghi
)) Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('nest', array ( array (
array('footnote_open',array()),
array('quote_open',array()),
array('cdata',array(" def")),
array('quote_open',array()),
array('cdata',array("ghi")),
array('quote_close',array()),
array('quote_close',array()),
array('cdata',array(' ')),
array('footnote_close',array()),
))),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testFootnoteNesting() {
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse("(( a ** (( b )) ** c ))");
$calls = array(
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n")),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array(' a ')),
array('strong_open',array()),
array('cdata',array(' (( b ')),
array('footnote_close',array()),
))),
array('cdata',array(" ")),
array('strong_close',array()),
array('cdata',array(" c ))\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_formatting.test.php 0000664 0000000 0000000 00000037167 11343270035 0027635 0 ustar 00root root 0000000 0000000 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'."\n")),
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\n")),
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'."\n")),
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'."\n")),
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'."\n")),
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'."\n")),
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'."\n")),
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\n")),
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'."\n")),
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\n")),
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\n")),
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("\n")),
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'."\n")),
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\n")),
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'."\n")),
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\n")),
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 bar 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'."\n")),
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 bar def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc bar def\n")),
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 bar 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'."\n")),
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 bar def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc bar def\n")),
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 bar 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'."\n")),
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 bar def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc bar def\n")),
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'."\n")),
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'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_headers.test.php 0000664 0000000 0000000 00000025665 11343270035 0027076 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Headers');
}
function testHeader1() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ====== Header ====== \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader2() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ===== Header ===== \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',2,6)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader3() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ==== Header ==== \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',3,6)),
array('section_open',array(3)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader4() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n === Header === \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',4,6)),
array('section_open',array(4)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader5() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n == Header == \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',5,6)),
array('section_open',array(5)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader2UnevenSmaller() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ===== Header == \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',2,6)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader2UnevenBigger() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ===== Header =========== \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',2,6)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeaderLarge() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ======= Header ======= \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeaderSmall() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n= Header =\n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n= Header =\n def\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader1Mixed() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n====== == Header == ======\n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('== Header ==',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeader5Mixed() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n== ====== Header ====== ==\n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('====== Header ======',5,6)),
array('section_open',array(5)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeaderMultiline() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n== ====== Header\n ====== ==\n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n== ====== Header\n")),
array('p_close',array()),
array('header',array('',1,23)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
# function testNoToc() {
# $this->P->addMode('notoc',new Doku_Parser_Mode_NoToc());
# $this->P->parse('abc ~~NOTOC~~ def');
# $this->assertFalse($this->H->meta['toc']);
# }
function testHeader1Eol() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("abc \n ====== Header ====== \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array('abc '.DOKU_PARSER_EOL)),
array('p_close',array()),
array('header',array('Header',1, 6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array(' def'.DOKU_PARSER_EOL)),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testHeaderMulti2() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("abc \n ====== Header ====== \n def abc \n ===== Header2 ===== \n def");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc \n")),
array('p_close',array()),
array('header',array('Header',1,6)),
array('section_open',array(1)),
array('p_open',array()),
array('cdata',array("\n def abc \n")),
array('p_close',array()),
array('section_close',array()),
array('header',array('Header2',2,39)),
array('section_open',array(2)),
array('p_open',array()),
array('cdata',array("\n def\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array())
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_i18n.test.php 0000664 0000000 0000000 00000015524 11343270035 0026233 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_i18n');
}
function testFormatting() {
$formats = array (
'strong', 'emphasis', 'underline', 'monospace',
'subscript', 'superscript', 'deleted',
);
foreach ( $formats as $format ) {
$this->P->addMode($format,new Doku_Parser_Mode_Formatting($format));
}
$this->P->parse("I**ñ**t__ë__r//n//âtiôn''à ''lizætiøn");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nI")),
array('strong_open',array()),
array('cdata',array('ñ')),
array('strong_close',array()),
array('cdata',array('t')),
array('underline_open',array()),
array('cdata',array('ë')),
array('underline_close',array()),
array('cdata',array('r')),
array('emphasis_open',array()),
array('cdata',array('n')),
array('emphasis_close',array()),
array('cdata',array('â')),
array('superscript_open',array()),
array('cdata',array('t')),
array('superscript_close',array()),
array('cdata',array('i')),
array('subscript_open',array()),
array('cdata',array('ô')),
array('subscript_close',array()),
array('cdata',array('n')),
array('monospace_open',array()),
array('cdata',array('Ã ')),
array('monospace_close',array()),
array('cdata',array('liz')),
array('deleted_open',array()),
array('cdata',array('æ')),
array('deleted_close',array()),
array('cdata',array("tiøn\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testHeader() {
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->parse("Foo\n ==== Iñtërnâtiônà lizætiøn ==== \n Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nFoo\n")),
array('p_close',array()),
array('header',array('Iñtërnâtiônà lizætiøn',3,5)),
array('section_open',array(3)),
array('p_open',array()),
array('cdata',array("\n Bar\n")),
array('p_close',array()),
array('section_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTable() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
| Row 0 Col 1 | Iñtërnâtiônà lizætiøn | Row 0 Col 3 |
| Row 1 Col 1 | Iñtërnâtiônà lizætiøn | Row 1 Col 3 |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Iñtërnâtiônà lizætiøn ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Iñtërnâtiônà lizætiøn ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(153)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testAcronym() {
$t = array('Iñtërnâtiônà lizætiøn');
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym($t));
$this->P->parse("Foo Iñtërnâtiônà lizætiøn Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nFoo ")),
array('acronym',array('Iñtërnâtiônà lizætiøn')),
array('cdata',array(" Bar\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testInterwiki() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[wp>Iñtërnâtiônà lizætiøn|Iñtërnâtiônà lizætiøn]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('interwikilink',array('wp>Iñtërnâtiônà lizætiøn','Iñtërnâtiônà lizætiøn','wp','Iñtërnâtiônà lizætiøn')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLink() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[x:Iñtërnâtiônà lizætiøn:y:foo_bar:z|Iñtërnâtiônà lizætiøn]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internallink',array('x:Iñtërnâtiônà lizætiøn:y:foo_bar:z','Iñtërnâtiônà lizætiøn')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_links.test.php 0000664 0000000 0000000 00000057025 11343270035 0026576 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Links');
}
function testExternalLinkSimple() {
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
$this->P->parse("Foo http://www.google.com Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externallink',array('http://www.google.com', NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalLinkCase() {
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
$this->P->parse("Foo HTTP://WWW.GOOGLE.COM Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externallink',array('HTTP://WWW.GOOGLE.COM', NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalLinkJavascript() {
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
$this->P->parse("Foo javascript:alert('XSS'); Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nFoo javascript:alert('XSS'); Bar\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalWWWLink() {
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
$this->P->parse("Foo www.google.com Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externallink',array('http://www.google.com', 'www.google.com')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalFTPLink() {
$this->P->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
$this->P->parse("Foo ftp.sunsite.com Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externallink',array('ftp://ftp.sunsite.com', 'ftp.sunsite.com')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEmail() {
/* $this->fail('The emaillink mode seems to cause php 5.0.5 to segfault');
return; //FIXME: is this still true?*/
$this->P->addMode('emaillink',new Doku_Parser_Mode_Emaillink());
$this->P->parse("Foo Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('emaillink',array('bugs@php.net', NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEmailRFC2822() {
$this->P->addMode('emaillink',new Doku_Parser_Mode_Emaillink());
$this->P->parse("Foo <~fix+bug's.for/ev{e}r@php.net> Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('emaillink',array("~fix+bug's.for/ev{e}r@php.net", NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEmailCase() {
$this->P->addMode('emaillink',new Doku_Parser_Mode_Emaillink());
$this->P->parse("Foo Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('emaillink',array('bugs@pHp.net', NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkOneChar() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[l]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internallink',array('l',NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkNamespaceNoTitle() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[foo:bar]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internallink',array('foo:bar',NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkNamespace() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[x:1:y:foo_bar:z|Test]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internallink',array('x:1:y:foo_bar:z','Test')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkSectionRef() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[wiki:syntax#internal|Syntax]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internallink',array('wiki:syntax#internal','Syntax')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testExternalInInternalLink() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[http://www.google.com|Google]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externallink',array('http://www.google.com','Google')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInterwikiLink() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[iw>somepage|Some Page]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('interwikilink',array('iw>somepage','Some Page','iw','somepage')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInterwikiLinkCase() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[IW>somepage|Some Page]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('interwikilink',array('IW>somepage','Some Page','iw','somepage')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInterwikiPedia() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[wp>Callback_(computer_science)|callbacks]] Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('interwikilink',array('wp>Callback_(computer_science)','callbacks','wp','Callback_(computer_science)')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testCamelCase() {
$this->P->addMode('camelcaselink',new Doku_Parser_Mode_CamelCaseLink());
$this->P->parse("Foo FooBar Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('camelcaselink',array('FooBar')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testFileLink() {
$this->P->addMode('filelink',new Doku_Parser_Mode_FileLink());
$this->P->parse('Foo file://temp/file.txt Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('filelink',array('file://temp/file.txt ',NULL)),
array('cdata',array('Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testFileLinkInternal() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse('Foo [[file://temp/file.txt|Some File]] Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externallink',array('file://temp/file.txt','Some File')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testWindowsShareLink() {
$this->P->addMode('windowssharelink',new Doku_Parser_Mode_WindowsShareLink());
$this->P->parse('Foo \\\server\share Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('windowssharelink',array('\\\server\share',NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testWindowsShareLinkInternal() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse('Foo [[\\\server\share|My Documents]] Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('windowssharelink',array('\\\server\share','My Documents')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternal() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{img.gif}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('img.gif',NULL,NULL,NULL,NULL,'cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalLinkOnly() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{img.gif?linkonly}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('img.gif',NULL,NULL,NULL,NULL,'cache','linkonly')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaNotImage() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{foo.txt?10x10|Some File}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('foo.txt','Some File',null,10,10,'cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalLAlign() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{img.gif }} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('img.gif',NULL,'left',NULL,NULL,'cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalRAlign() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{ img.gif}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('img.gif',NULL,'right',NULL,NULL,'cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalCenter() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{ img.gif }} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('img.gif',NULL,'center',NULL,NULL,'cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalParams() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{img.gif?50x100nocache}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('img.gif',NULL,NULL,'50','100','nocache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInternalTitle() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{img.gif?50x100|Some Image}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',array('img.gif','Some Image',NULL,'50','100','cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaExternal() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{http://www.google.com/img.gif}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externalmedia',array('http://www.google.com/img.gif',NULL,NULL,NULL,NULL,'cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaExternalParams() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{http://www.google.com/img.gif?50x100nocache}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externalmedia',array('http://www.google.com/img.gif',NULL,NULL,'50','100','nocache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaExternalTitle() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{http://www.google.com/img.gif?50x100|Some Image}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('externalmedia',
array('http://www.google.com/img.gif','Some Image',NULL,'50','100','cache','details')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInInternalLink() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[x:1:y:foo_bar:z|{{img.gif?10x20nocache|Some Image}}]] Bar");
$image = array(
'type'=>'internalmedia',
'src'=>'img.gif',
'title'=>'Some Image',
'align'=>NULL,
'width'=>10,
'height'=>20,
'cache'=>'nocache',
'linking'=>'details',
);
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internallink',array('x:1:y:foo_bar:z',$image)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaNoImageInInternalLink() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[x:1:y:foo_bar:z|{{foo.txt?10x20nocache|Some Image}}]] Bar");
$image = array(
'type'=>'internalmedia',
'src'=>'foo.txt',
'title'=>'Some Image',
'align'=>NULL,
'width'=>10,
'height'=>20,
'cache'=>'nocache',
'linking'=>'details',
);
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internallink',array('x:1:y:foo_bar:z',$image)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testMediaInEmailLink() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[foo@example.com|{{img.gif?10x20nocache|Some Image}}]] Bar");
$image = array(
'type'=>'internalmedia',
'src'=>'img.gif',
'title'=>'Some Image',
'align'=>NULL,
'width'=>10,
'height'=>20,
'cache'=>'nocache',
'linking'=>'details',
);
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('emaillink',array('foo@example.com',$image)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testNestedMedia() {
$this->P->addMode('media',new Doku_Parser_Mode_Media());
$this->P->parse('Foo {{img.gif|{{foo.gif|{{bar.gif|Bar}}}}}} Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('internalmedia',
array('img.gif','{{foo.gif|{{bar.gif|Bar',NULL,NULL,NULL,'cache','details')),
array('cdata',array('}}}} Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_lists.test.php 0000664 0000000 0000000 00000035463 11343270035 0026616 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Lists');
}
function testUnorderedList() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse('
*A
* B
* C
');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testOrderedList() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse('
-A
- B
- C
');
$calls = array (
array('document_start',array()),
array('listo_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
array('listo_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listo_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listo_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMixedList() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse('
-A
* B
- C
');
$calls = array (
array('document_start',array()),
array('listo_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listo_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListWinEOL() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse("\r\n *A\r\n * B\r\n * C\r\n");
$calls = array (
array('document_start',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testOrderedListWinEOL() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse("\r\n -A\r\n - B\r\n - C\r\n");
$calls = array (
array('document_start',array()),
array('listo_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
array('listo_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listo_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listo_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testNotAList() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse("Foo -bar *foo Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nFoo -bar *foo Bar\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListParagraph() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse('Foo
*A
* B
* C
Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("Foo")),
array('p_close',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('p_open',array()),
array('cdata',array("Bar".DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - formatting able to spread across list items
// Problem is fixing it would mean a major rewrite of lists
function testUnorderedListStrong() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse('
***A**
*** B
* C**
');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('strong_open',array()),
array('cdata',array("A")),
array('strong_close',array()),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('strong_open',array()),
array('cdata',array(" B\n * C")),
array('strong_close',array()),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - unformatted able to spread across list items
// Problem is fixing it would mean a major rewrite of lists
function testUnorderedListUnformatted() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
$this->P->parse('
*%%A%%
*%% B
* C%%
');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('unformatted',array("A")),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('unformatted',array(" B\n * C")),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListLinebreak() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->addMode('linebreak',new Doku_Parser_Mode_Linebreak());
$this->P->parse('
*A\\\\ D
* B
* C
');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('linebreak',array()),
array('cdata',array("D")),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' C')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListLinebreak2() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->addMode('linebreak',new Doku_Parser_Mode_Linebreak());
$this->P->parse('
*A\\\\
* B
');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array("A")),
array('linebreak',array()),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(' B')),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testUnorderedListFootnote() {
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->addMode('footnote',new Doku_Parser_Mode_Footnote());
$this->P->parse('
*((A))
*(( B
* C ))
');
$calls = array (
array('document_start',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('nest', array( array(
array('footnote_open',array()),
array('cdata',array("A")),
array('footnote_close',array())
))),
array('listcontent_close',array()),
array('listu_open',array()),
array('listitem_open',array(2)),
array('listcontent_open',array()),
array('nest', array( array(
array('footnote_open',array()),
array('cdata',array(" B")),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(" C )) ")),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('cdata',array("\n\n")),
array('footnote_close',array())
))),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('document_end',array())
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_preformatted.test.php 0000664 0000000 0000000 00000021575 11343270035 0030153 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Preformatted');
}
function testFile() {
$this->P->addMode('file',new Doku_Parser_Mode_File());
$this->P->parse('Foo testing Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('p_close',array()),
array('file',array('testing',null,null)),
array('p_open',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCode() {
$this->P->addMode('code',new Doku_Parser_Mode_Code());
$this->P->parse('Foo testing Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('p_close',array()),
array('code',array('testing', null, null)),
array('p_open',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCodeWhitespace() {
$this->P->addMode('code',new Doku_Parser_Mode_Code());
$this->P->parse("Foo testing Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('p_close',array()),
array('code',array('testing', null, null)),
array('p_open',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCodeLang() {
$this->P->addMode('code',new Doku_Parser_Mode_Code());
$this->P->parse("Foo testing Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('p_close',array()),
array('code',array('testing', 'php', null)),
array('p_open',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformatted() {
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->parse("F oo\n x \n y \nBar\n");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nF oo")),
array('p_close',array()),
array('preformatted',array("x \n y ")),
array('p_open',array()),
array('cdata',array('Bar'."\n\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedWinEOL() {
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->parse("F oo\r\n x \r\n y \r\nBar\r\n");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nF oo")),
array('p_close',array()),
array('preformatted',array("x \n y ")),
array('p_open',array()),
array('cdata',array('Bar'."\n\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedTab() {
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->parse("F oo\n\tx\t\n\t\ty\t\nBar\n");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nF oo")),
array('p_close',array()),
array('preformatted',array("x\t\n\ty\t")),
array('p_open',array()),
array('cdata',array("Bar\n\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedTabWinEOL() {
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->parse("F oo\r\n\tx\t\r\n\t\ty\t\r\nBar\r\n");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nF oo")),
array('p_close',array()),
array('preformatted',array("x\t\n\ty\t")),
array('p_open',array()),
array('cdata',array("Bar\n\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedList() {
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$this->P->parse(" - x \n * y \nF oo\n x \n y \n -X\n *Y\nBar\n");
$calls = array (
array('document_start',array()),
array('listo_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(" x ")),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listo_close',array()),
array('listu_open',array()),
array('listitem_open',array(1)),
array('listcontent_open',array()),
array('cdata',array(" y ")),
array('listcontent_close',array()),
array('listitem_close',array()),
array('listu_close',array()),
array('p_open',array()),
array('cdata',array("F oo")),
array('p_close',array()),
array('preformatted',array("x \n y \n-X\n*Y")),
array('p_open',array()),
array('cdata',array("Bar\n\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
// test for php
function testPHP() {
$this->P->addMode('php',new Doku_Parser_Mode_PHP());
$this->P->parse('Foo testing Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('php',array('testing')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
// test with for HTML
function testHTML() {
$this->P->addMode('html',new Doku_Parser_Mode_HTML());
$this->P->parse('Foo testing Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('html',array('testing')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPreformattedPlusHeaderAndEol() {
// Note that EOL must come after preformatted!
$this->P->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
$this->P->addMode('header',new Doku_Parser_Mode_Header());
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("F oo\n ==Test==\n y \nBar\n");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("F oo")),
array('p_close',array()),
array('preformatted',array("==Test==\n y ")),
array('p_open',array()),
array('cdata',array('Bar')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_quote.test.php 0000664 0000000 0000000 00000006640 11343270035 0026610 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Quote');
}
function testQuote() {
$this->P->addMode('quote',new Doku_Parser_Mode_Quote());
$this->P->parse("abc\n> def\n>>ghi\nklm");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc")),
array('p_close',array()),
array('quote_open',array()),
array('cdata',array(" def")),
array('quote_open',array()),
array('cdata',array("ghi")),
array('quote_close',array()),
array('quote_close',array()),
array('p_open',array()),
array('cdata',array("klm\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testQuoteWinCr() {
$this->P->addMode('quote',new Doku_Parser_Mode_Quote());
$this->P->parse("abc\r\n> def\r\n>>ghi\r\nklm");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc")),
array('p_close',array()),
array('quote_open',array()),
array('cdata',array(" def")),
array('quote_open',array()),
array('cdata',array("ghi")),
array('quote_close',array()),
array('quote_close',array()),
array('p_open',array()),
array('cdata',array("klm\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testQuoteMinumumContext() {
$this->P->addMode('quote',new Doku_Parser_Mode_Quote());
$this->P->parse("\n> def\n>>ghi\n ");
$calls = array (
array('document_start',array()),
array('quote_open',array()),
array('cdata',array(" def")),
array('quote_open',array()),
array('cdata',array("ghi")),
array('quote_close',array()),
array('quote_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testQuoteEol() {
$this->P->addMode('quote',new Doku_Parser_Mode_Quote());
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse("abc\n> def\n>>ghi\nklm");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("abc")),
array('p_close',array()),
array('quote_open',array()),
array('cdata',array(" def")),
array('quote_open',array()),
array('cdata',array("ghi")),
array('quote_close',array()),
array('quote_close',array()),
array('p_open',array()),
array('cdata',array("klm".DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_quotes.test.php 0000664 0000000 0000000 00000022242 11343270035 0026767 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Quotes');
}
function testSingleQuoteOpening() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("Foo 'hello Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('singlequoteopening',array()),
array('cdata',array('hello Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuoteOpeningSpecial() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("Foo said:'hello Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo said:')),
array('singlequoteopening',array()),
array('cdata',array('hello Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuoteClosing() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("Foo hello' Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo hello')),
array('singlequoteclosing',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuoteClosingSpecial() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("Foo hello') Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo hello')),
array('singlequoteclosing',array()),
array('cdata',array(') Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuotes() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("Foo 'hello' Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('singlequoteopening',array()),
array('cdata',array('hello')),
array('singlequoteclosing',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testApostrophe() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("hey it's fine weather today");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'hey it')),
array('apostrophe',array()),
array('cdata',array('s fine weather today'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleQuotesSpecial() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse("Foo ('hello') Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo (')),
array('singlequoteopening',array()),
array('cdata',array('hello')),
array('singlequoteclosing',array()),
array('cdata',array(') Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteOpening() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse('Foo "hello Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('doublequoteopening',array()),
array('cdata',array('hello Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteOpeningSpecial() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse('Foo said:"hello Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo said:')),
array('doublequoteopening',array()),
array('cdata',array('hello Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteClosing() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse('Foo hello" Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo hello')),
array('doublequoteclosing',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuoteClosingSpecial() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse('Foo hello") Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo hello')),
array('doublequoteclosing',array()),
array('cdata',array(') Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuotes() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse('Foo "hello" Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('doublequoteopening',array()),
array('cdata',array('hello')),
array('doublequoteclosing',array()),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testDoubleQuotesSpecial() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse('Foo ("hello") Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo (')),
array('doublequoteopening',array()),
array('cdata',array('hello')),
array('doublequoteclosing',array()),
array('cdata',array(') Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testAllQuotes() {
$this->P->addMode('quotes',new Doku_Parser_Mode_Quotes());
$this->P->parse('There was written "He thought \'It\'s a man\'s world\'".');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'There was written ')),
array('doublequoteopening',array()),
array('cdata',array('He thought ')),
array('singlequoteopening',array()),
array('cdata',array('It')),
array('apostrophe',array()),
array('cdata',array('s a man')),
array('apostrophe',array()),
array('cdata',array('s world')),
array('singlequoteclosing',array()),
array('doublequoteclosing',array()),
array('cdata',array(".\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_replacements.test.php 0000664 0000000 0000000 00000032045 11343270035 0030133 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Replacements');
}
function testSingleAcronym() {
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym(array('FOOBAR')));
$this->P->parse('abc FOOBAR xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('acronym',array('FOOBAR')),
array('cdata',array(' xyz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testAlmostAnAcronym() {
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym(array('FOOBAR')));
$this->P->parse('abcFOOBARxyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abcFOOBARxyz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testPickAcronymCorrectly() {
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym(array('FOO')));
$this->P->parse('FOOBAR FOO');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'FOOBAR ')),
array('acronym',array('FOO')),
array('cdata',array("\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleAcronyms() {
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym(array('FOO','BAR')));
$this->P->parse('abc FOO def BAR xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('acronym',array('FOO')),
array('cdata',array(' def ')),
array('acronym',array('BAR')),
array('cdata',array(' xyz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleAcronymsWithSubset1() {
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym(array('FOO','A.FOO','FOO.1','A.FOO.1')));
$this->P->parse('FOO A.FOO FOO.1 A.FOO.1');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n")),
array('acronym',array('FOO')),
array('cdata',array(" ")),
array('acronym',array('A.FOO')),
array('cdata',array(" ")),
array('acronym',array('FOO.1')),
array('cdata',array(" ")),
array('acronym',array('A.FOO.1')),
array('cdata',array("\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleAcronymsWithSubset2() {
$this->P->addMode('acronym',new Doku_Parser_Mode_Acronym(array('A.FOO.1','FOO.1','A.FOO','FOO')));
$this->P->parse('FOO A.FOO FOO.1 A.FOO.1');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n")),
array('acronym',array('FOO')),
array('cdata',array(" ")),
array('acronym',array('A.FOO')),
array('cdata',array(" ")),
array('acronym',array('FOO.1')),
array('cdata',array(" ")),
array('acronym',array('A.FOO.1')),
array('cdata',array("\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleSmileyFail() {
$this->P->addMode('smiley',new Doku_Parser_Mode_Smiley(array(':-)')));
$this->P->parse('abc:-)xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc:-)xyz\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleSmiley() {
$this->P->addMode('smiley',new Doku_Parser_Mode_Smiley(array(':-)')));
$this->P->parse('abc :-) xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('smiley',array(':-)')),
array('cdata',array(' xyz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleSmileysFail() {
$this->P->addMode('smiley',new Doku_Parser_Mode_Smiley(array(':-)','^_^')));
$this->P->parse('abc:-)x^_^yz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc:-)x^_^yz\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleSmileys() {
$this->P->addMode('smiley',new Doku_Parser_Mode_Smiley(array(':-)','^_^')));
$this->P->parse('abc :-) x ^_^ yz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('smiley',array(':-)')),
array('cdata',array(' x ')),
array('smiley',array('^_^')),
array('cdata',array(' yz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testBackslashSmileyFail() {
// This smiley is really :-\\ but escaping makes like interesting
$this->P->addMode('smiley',new Doku_Parser_Mode_Smiley(array(':-\\\\')));
$this->P->parse('abc:-\\\xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\nabc".':-\\\\'."xyz\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testBackslashSmiley() {
// This smiley is really :-\\ but escaping makes like interesting
$this->P->addMode('smiley',new Doku_Parser_Mode_Smiley(array(':-\\\\')));
$this->P->parse('abc :-\\\ xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('smiley',array(':-\\\\')),
array('cdata',array(' xyz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleWordblock() {
$this->P->addMode('wordblock',new Doku_Parser_Mode_Wordblock(array('CAT')));
$this->P->parse('abc CAT xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('wordblock',array('CAT')),
array('cdata',array(' xyz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testWordblockCase() {
$this->P->addMode('wordblock',new Doku_Parser_Mode_Wordblock(array('CAT')));
$this->P->parse('abc cat xyz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('wordblock',array('cat')),
array('cdata',array(' xyz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleWordblock() {
$this->P->addMode('wordblock',new Doku_Parser_Mode_Wordblock(array('CAT','dog')));
$this->P->parse('abc cat x DOG yz');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'abc ')),
array('wordblock',array('cat')),
array('cdata',array(' x ')),
array('wordblock',array('DOG')),
array('cdata',array(' yz'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testSingleEntity() {
$this->P->addMode('entity',new Doku_Parser_Mode_Entity(array('->')));
$this->P->parse('x -> y');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'x ')),
array('entity',array('->')),
array('cdata',array(' y'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultipleEntities() {
$this->P->addMode('entity',new Doku_Parser_Mode_Entity(array('->','<-')));
$this->P->parse('x -> y <- z');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'x ')),
array('entity',array('->')),
array('cdata',array(' y ')),
array('entity',array('<-')),
array('cdata',array(' z'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultiplyEntity() {
$this->P->addMode('multiplyentity',new Doku_Parser_Mode_MultiplyEntity());
$this->P->parse('Foo 10x20 Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('multiplyentity',array(10,20)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testMultiplyEntityHex() {
// the multiply entity pattern should not match hex numbers, eg. 0x123
$this->P->addMode('multiplyentity',new Doku_Parser_Mode_MultiplyEntity());
$this->P->parse('Foo 0x123 Bar');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo 0x123 Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testHR() {
$this->P->addMode('hr',new Doku_Parser_Mode_HR());
$this->P->parse("Foo \n ---- \n Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('p_close',array()),
array('hr',array()),
array('p_open',array()),
array('cdata',array("\n Bar\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testHREol() {
$this->P->addMode('hr',new Doku_Parser_Mode_HR());
$this->P->parse("Foo \n----\n Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('p_close',array()),
array('hr',array()),
array('p_open',array()),
array('cdata',array("\n Bar\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_table.test.php 0000664 0000000 0000000 00000055355 11343270035 0026551 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Table');
}
function testTable() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
| Row 0 Col 1 | Row 0 Col 2 | Row 0 Col 3 |
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(121)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableWinEOL() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse("\r\nabc\r\n| Row 0 Col 1 | Row 0 Col 2 | Row 0 Col 3 |\r\n| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |\r\ndef");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(121)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testEmptyTable() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
|
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(0, 1, 6)),
array('tablerow_open',array()),
array('tablerow_close',array()),
array('table_close',array(7)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableHeaders() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
^ X | Y ^ Z |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 1, 6)),
array('tablerow_open',array()),
array('tableheader_open',array(1,NULL,1)),
array('cdata',array(' X ')),
array('tableheader_close',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' Y ')),
array('tablecell_close',array()),
array('tableheader_open',array(1,NULL,1)),
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
array('table_close',array(19)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellAlignment() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
| X | Y ^ Z |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 1, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'right',1)),
array('cdata',array(' X ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Y ')),
array('tablecell_close',array()),
array('tableheader_open',array(1,'center',1)),
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
array('table_close',array(23)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellSpan() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
| d || e |
| f ^ ^|
||||
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 3, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(2,'right',1)),
array('cdata',array(' d ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' e ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' f ')),
array('tablecell_close',array()),
array('tableheader_open',array(2,NULL,1)),
array('cdata',array(' ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablerow_close',array()),
array('table_close',array(31)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellRowSpan() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
| a | c:::||
|:::^ d | e|
|b ^ ::: |:::f|
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 3, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,NULL,2)),
array('cdata',array(' a ')),
array('tablecell_close',array()),
array('tablecell_open',array(2,'right',1)),
array('cdata',array(' c:::')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tableheader_open',array(1,'left',2)),
array('cdata',array(' d ')),
array('tableheader_close',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' e')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array('b ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(':::f')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(51)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellAlignmentFormatting() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse('
abc
| **X** | Y ^ Z |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 1, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'right',1)),
array('cdata',array(' ')),
array('strong_open',array()),
array('cdata',array('X')),
array('strong_close',array()),
array('cdata',array(' ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Y ')),
array('tablecell_close',array()),
array('tableheader_open',array(1,'center',1)),
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
array('table_close',array(27)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableEol() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('eol',new Doku_Parser_Mode_Eol());
$this->P->parse('
abc
| Row 0 Col 1 | Row 0 Col 2 | Row 0 Col 3 |
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array(DOKU_PARSER_EOL."abc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(121)),
array('p_open',array()),
array('cdata',array('def'.DOKU_PARSER_EOL)),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - formatting able to spread across cols
// Problem is fixing it would mean a major rewrite of table handling
function testTableStrong() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('strong',new Doku_Parser_Mode_Formatting('strong'));
$this->P->parse('
abc
| **Row 0 Col 1** | **Row 0 Col 2 | Row 0 Col 3** |
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
array('strong_open',array()),
array('cdata',array('Row 0 Col 1')),
array('strong_close',array()),
array('cdata',array(' ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
array('strong_open',array()),
array('cdata',array('Row 0 Col 2 | Row 0 Col 3')),
array('strong_close',array()),
array('cdata',array(' ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(129)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - unformatted able to spread across cols
// Problem is fixing it would mean a major rewrite of table handling
function testTableUnformatted() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
$this->P->parse('
abc
| Row 0 Col 1 | Row 0 Col 2 | Row 0 Col 3 |
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
array('unformatted',array('Row 0 Col 1')),
array('cdata',array(' ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
array('unformatted',array('Row 0 Col 2 | Row 0 Col 3')),
array('cdata',array(' ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(155)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableLinebreak() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('linebreak',new Doku_Parser_Mode_Linebreak());
$this->P->parse('
abc
| Row 0\\\\ Col 1 | Row 0 Col 2 | Row 0 Col 3 |
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0')),
array('linebreak',array()),
array('cdata',array('Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 0 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(123)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
// This is really a failing test - footnote able to spread across cols
// Problem is fixing it would mean a major rewrite of table handling
function testTableFootnote() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->addMode('footnote',new Doku_Parser_Mode_Footnote());
$this->P->parse('
abc
| ((Row 0 Col 1)) | ((Row 0 Col 2 | Row 0 Col 3)) |
| Row 1 Col 1 | Row 1 Col 2 | Row 1 Col 3 |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array('Row 0 Col 1')),
array('footnote_close',array()),
))),
array('cdata',array(' ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' ')),
array('nest', array ( array (
array('footnote_open',array()),
array('cdata',array('Row 0 Col 2 | Row 0 Col 3')),
array('footnote_close',array()),
))),
array('cdata',array(' ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 1 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 2 ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,'left',1)),
array('cdata',array(' Row 1 Col 3 ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(129)),
array('p_open',array()),
array('cdata',array('def'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripbyteindex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/parser_unformatted.test.php 0000664 0000000 0000000 00000002627 11343270035 0030004 0 ustar 00root root 0000000 0000000 UnitTestCase('TestOfDoku_Parser_Unformatted');
}
function testNowiki() {
$this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
$this->P->parse("Foo testing Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('unformatted',array('testing')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testDoublePercent() {
$this->P->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
$this->P->parse("Foo %%testing%% Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('unformatted',array('testing')),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
}
splitbrain-dokuwiki-d6c824b/_test/cases/inc/parser/xhtml_htmlphp.test.php 0000664 0000000 0000000 00000013013 11343270035 0026757 0 ustar 00root root 0000000 0000000 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('bold','
<b>bold</b>
');
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('bold','
bold
');
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('bold','
<b>bold</b>
');
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('bold','bold');
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('echo(1+1);','
echo(1+1);
');
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('echo(1+1);','
2
');
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('echo(1+1);','
";
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_PaintFooter() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
break;
case DW_TESTS_OUTPUT_HTML:
default:
$footer = <<
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 single test case
if (isset($_GET['case'])) {
TestManager::runTestCase($_GET['case'], TEST_CASES, 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();
} else {
/* no group specified, so list them all */
DW_TESTS_PaintGroupTestList();
}
DW_TESTS_PaintFooter();
splitbrain-dokuwiki-d6c824b/_test/lib/ 0000775 0000000 0000000 00000000000 11343270035 0020005 5 ustar 00root root 0000000 0000000 splitbrain-dokuwiki-d6c824b/_test/lib/cli_reporter.php 0000664 0000000 0000000 00000006342 11343270035 0023214 0 ustar 00root root 0000000 0000000 ");
}
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 = '';
}
}
/**
* 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");
}
}
}
splitbrain-dokuwiki-d6c824b/_test/lib/mock_functions.php 0000664 0000000 0000000 00000045544 11343270035 0023553 0 ustar 00root root 0000000 0000000 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);
}
}
splitbrain-dokuwiki-d6c824b/_test/lib/rss_writer_class.php 0000664 0000000 0000000 00000030424 11343270035 0024111 0 ustar 00root root 0000000 0000000 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_propertieserror=("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);
}
};
}
splitbrain-dokuwiki-d6c824b/_test/lib/testmanager.php 0000664 0000000 0000000 00000036733 11343270035 0023044 0 ustar 00root root 0000000 0000000 $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 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 = '.') {
$base = TEST_GROUPS . DIRECTORY_SEPARATOR;
$file_list =& $this->_getTestFileList($directory);
$testcases = array();
foreach ($file_list as $testcase_file) {
$case = str_replace($this->_testcase_extension, '',$testcase_file);
$case = str_replace($base, '', $case);
$case = str_replace(DIRECTORY_SEPARATOR, ':', $case);
$testcases[$testcase_file] = $case;
}
return $testcases;
}
function &_getTestFileList($directory = '.') {
return $this->_getRecursiveFileList($directory,
array(&$this, '_isTestCaseFile'));
}
function &getGroupTestList($directory = '.') {
$manager =& new TestManager();
return $manager->_getTestGroupList($directory);
}
function &_getTestGroupFileList($directory = '.') {
return $this->_getRecursiveFileList($directory,
array(&$this, '_isTestGroupFile'));
}
function &_getTestGroupList($directory = '.') {
$base = TEST_GROUPS . DIRECTORY_SEPARATOR;
$file_list =& $this->_getTestGroupFileList($directory);
$grouptests = array();
foreach ($file_list as $grouptest_file) {
$group = str_replace($this->_grouptest_extension, '',$grouptest_file);
$group = str_replace($base, '', $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";
}
}
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 "