Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
transformed parser unit tests to phpunit
- Loading branch information
Showing
15 changed files
with
3,647 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* @version $Id: parser.inc.php,v 1.2 2005/03/25 21:00:22 harryf Exp $ | ||
* @package Doku | ||
* @subpackage Tests | ||
*/ | ||
|
||
/** | ||
* Includes | ||
*/ | ||
require_once DOKU_INC . 'inc/init.php'; | ||
require_once DOKU_INC . 'inc/confutils.php'; | ||
require_once DOKU_INC . 'inc/parser/parser.php'; | ||
require_once DOKU_INC . 'inc/parser/handler.php'; | ||
require_once DOKU_INC . 'inc/events.php'; | ||
require_once DOKU_INC . 'inc/mail.php'; | ||
|
||
/** | ||
* @package Doku | ||
* @subpackage Tests | ||
*/ | ||
abstract class TestOfDoku_Parser extends PHPUnit_Framework_TestCase { | ||
|
||
var $P; | ||
var $H; | ||
|
||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
require_once 'parser.inc.php'; | ||
|
||
class TestOfDoku_Parser_Eol extends TestOfDoku_Parser { | ||
|
||
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")), | ||
array('p_close',array()), | ||
array('document_end',array()), | ||
); | ||
$this->assertEquals(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")), | ||
array('p_close',array()), | ||
array('document_end',array()), | ||
); | ||
$this->assertEquals(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")), | ||
array('p_close',array()), | ||
array('document_end',array()), | ||
); | ||
$this->assertEquals(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")), | ||
array('p_close',array()), | ||
array('document_end',array()), | ||
); | ||
$this->assertEquals(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")), | ||
array('p_close',array()), | ||
array('document_end',array()), | ||
); | ||
$this->assertEquals(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')), | ||
array('p_close',array()), | ||
array('document_end',array()), | ||
); | ||
$this->assertEquals(array_map('stripByteIndex',$this->H->calls),$calls); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.