From f2bbf30b71b15efa7a918944b4ffc74f8b1747a9 Mon Sep 17 00:00:00 2001 From: Guy Brand Date: Wed, 31 Jul 2013 11:38:44 +0200 Subject: Simple test cases for code and file token fix --- _test/tests/inc/parser/parser_code.test.php | 56 +++++++++++++++++++++++++++++ _test/tests/inc/parser/parser_file.test.php | 28 +++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 _test/tests/inc/parser/parser_code.test.php create mode 100644 _test/tests/inc/parser/parser_file.test.php (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/parser_code.test.php b/_test/tests/inc/parser/parser_code.test.php new file mode 100644 index 000000000..4f89b4826 --- /dev/null +++ b/_test/tests/inc/parser/parser_code.test.php @@ -0,0 +1,56 @@ +P->addMode('code',new Doku_Parser_Mode_Code()); + } + + function testCode() { + $this->P->parse('Foo Test Bar'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('p_close',array()), + array('code',array('Test',null,null)), + 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 testCodeBash() { + $this->P->parse('Foo Test Bar'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('p_close',array()), + array('code',array('Test','bash',null)), + 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 testCodeToken() { + $this->P->parse('Foo BarTest'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo Bar')), + array('p_close',array()), + array('code',array('Test',null,null)), + array('document_end',array()), + ); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + } +} + diff --git a/_test/tests/inc/parser/parser_file.test.php b/_test/tests/inc/parser/parser_file.test.php new file mode 100644 index 000000000..924b00382 --- /dev/null +++ b/_test/tests/inc/parser/parser_file.test.php @@ -0,0 +1,28 @@ +P->addMode('file',new Doku_Parser_Mode_File()); + } + + function testFile() { + $this->P->parse('Foo Test Bar'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('p_close',array()), + array('file',array('Test',null,null)), + 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); + } + +} + -- cgit v1.2.3 From fdd9bab63c332a19e213c2cf7c986b8b95e25af6 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 1 Aug 2013 11:37:00 +0200 Subject: increase test coverage for code and file code - test correct recognition of downloadable filename token file - test correct recognition of syntax name & downloadable filename tokens --- _test/tests/inc/parser/parser_code.test.php | 16 ++++++++++++++++ _test/tests/inc/parser/parser_file.test.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/parser_code.test.php b/_test/tests/inc/parser/parser_code.test.php index 4f89b4826..c50d2d328 100644 --- a/_test/tests/inc/parser/parser_code.test.php +++ b/_test/tests/inc/parser/parser_code.test.php @@ -40,6 +40,22 @@ class TestOfDoku_Parser_Code extends TestOfDoku_Parser { $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); } + function testCodeDownload() { + $this->P->parse('Foo Test Bar'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('p_close',array()), + array('code',array('Test','bash','script.sh')), + 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 testCodeToken() { $this->P->parse('Foo BarTest'); $calls = array ( diff --git a/_test/tests/inc/parser/parser_file.test.php b/_test/tests/inc/parser/parser_file.test.php index 924b00382..39bda8a58 100644 --- a/_test/tests/inc/parser/parser_file.test.php +++ b/_test/tests/inc/parser/parser_file.test.php @@ -24,5 +24,33 @@ class TestOfDoku_Parser_File extends TestOfDoku_Parser { $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); } + function testFileHighlightDownload() { + $this->P->parse('Foo Test Bar'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('p_close',array()), + array('file',array('Test','txt','test.txt')), + 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 testFileToken() { + $this->P->parse('Foo Test Bar'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo Test Bar')), + array('p_close',array()), + array('document_end',array()), + ); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + } + } -- cgit v1.2.3 From 0d9a72ff5d870d72772f5f6b4b83b8ee0b4a1f05 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 25 Sep 2013 18:16:00 +0200 Subject: added unittests for rowspans at first table row --- _test/tests/inc/parser/parser_table.test.php | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to '_test/tests/inc/parser') diff --git a/_test/tests/inc/parser/parser_table.test.php b/_test/tests/inc/parser/parser_table.test.php index 96789c38c..542a307b8 100644 --- a/_test/tests/inc/parser/parser_table.test.php +++ b/_test/tests/inc/parser/parser_table.test.php @@ -270,6 +270,64 @@ def'); ); $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); } + + function testCellRowSpanFirstRow() { + $this->P->addMode('table',new Doku_Parser_Mode_Table()); + $this->P->parse(' +abc +|::: ^ d:::^:::| ::: | +| b ^ e | | ::: | +|c ^ ::: | |:::| +def'); + + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n\nabc")), + array('p_close',array()), + array('table_open',array(4, 3, 6)), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array('')), + array('tablecell_close',array()), + array('tableheader_open',array(1,'right',1)), + array('cdata',array(' d:::')), + array('tableheader_close',array()), + array('tableheader_open',array(1,NULL,1)), + array('cdata',array('')), + array('tableheader_close',array()), + array('tablecell_open',array(1,NULL,3)), + array('cdata',array('')), + array('tablecell_close',array()), + array('tablerow_close',array()), + array('tablerow_open',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' b ')), + array('tablecell_close',array()), + array('tableheader_open',array(1,'left',2)), + array('cdata',array(' e ')), + array('tableheader_close',array()), + array('tablecell_open',array(1,NULL,1)), + 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('c ')), + array('tablecell_close',array()), + array('tablecell_open',array(1,NULL,1)), + array('cdata',array(' ')), + array('tablecell_close',array()), + array('tablerow_close',array()), + + array('table_close',array(69)), + array('p_open',array()), + array('cdata',array('def')), + array('p_close',array()), + array('document_end',array()), + ); + $this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls); + } function testCellAlignmentFormatting() { $this->P->addMode('table',new Doku_Parser_Mode_Table()); -- cgit v1.2.3