* @license BSD */ namespace Domframework\Tests; use Domframework\Markdown; /** * Test the Markdown.php file */ class MarkdownTest extends \PHPUnit_Framework_TestCase { // TitleSeText public function testTitleSeText1() { $this->expectOutputString("

test

"); $md = new Markdown(); printf($md->html("test\n====\n"), true); } public function testTitleSeText2() { $this->expectOutputString("

test

"); $md = new Markdown(); printf($md->html("test\n----\n"), true); } // Titles Sharp public function testTitleSharp1() { $this->expectOutputString("

test

"); $md = new Markdown(); printf($md->html("# test #")); } public function testTitleSharp2() { $this->expectOutputString("

test

"); $md = new Markdown(); printf($md->html("## test ##")); } public function testTitleSharp3() { $this->expectOutputString("

test

"); $md = new Markdown(); printf($md->html("### test ###")); } public function testTitleSharp4() { $this->expectOutputString("

test

"); $md = new Markdown(); printf($md->html("#### test ####")); } public function testTitleSharp5() { $this->expectOutputString("
test
"); $md = new Markdown(); printf($md->html("##### test #####")); } public function testTitleSharp6() { $this->expectOutputString("
test
"); $md = new Markdown(); printf($md->html("###### test #######")); } // Separator public function testSeparator1() { $this->expectOutputString("
"); $md = new Markdown(); printf($md->html("---\n"), true); } public function testSeparator2() { $this->expectOutputString("
"); $md = new Markdown(); printf($md->html("___\n"), true); } public function testSeparator3() { $this->expectOutputString("
"); $md = new Markdown(); printf($md->html("***\n"), true); } public function testSeparator4() { $this->expectOutputString("
"); $md = new Markdown(); printf($md->html("- - -\n"), true); } public function testSeparator5() { $this->expectOutputString("
"); $md = new Markdown(); printf($md->html("_ _ _\n"), true); } public function testSeparator6() { $this->expectOutputString("
"); $md = new Markdown(); printf($md->html("* * *\n"), true); } // Simple Text public function testSimpleText() { $this->expectOutputString("

text

"); $md = new Markdown(); printf($md->html("text"), true); } // Emphasis public function testEmphasisStrong1() { $this->expectOutputString("

text

"); $md = new Markdown(); printf($md->html("__text__")); } public function testEmphasisStrong2() { $this->expectOutputString("

text

"); $md = new Markdown(); printf($md->html("**text**")); } public function testEmphasisEM1() { $this->expectOutputString("

text

"); $md = new Markdown(); printf($md->html("_text_")); } public function testEmphasisEM2() { $this->expectOutputString("

file1.php or file2.php

"); $md = new Markdown(); printf($md->html("_file1.php_ or _file2.php_")); } public function testEmphasisEM3() { $this->expectOutputString("

text

"); $md = new Markdown(); printf($md->html("*text*")); } public function testEmphasisEM4() { $this->expectOutputString("

text or text2

"); $md = new Markdown(); printf($md->html("*text* or *text2*")); } // Unnumbered lists public function testUnnumbered1() { $this->expectOutputString(""); $md = new Markdown(); printf($md->html("* Case1\n* Case2\n* Case3"), true); } public function testUnnumbered2() { $this->expectOutputString(""); $md = new Markdown(); printf($md->html("- Case1\n- Case2\n- Case3"), true); } public function testUnnumbered3() { $this->expectOutputString(""); $md = new Markdown(); printf($md->html("+ Case1\n+ Case2\n+ Case3"), true); } public function testUnnumberredMultiline1() { $this->expectOutputString(""); $md = new Markdown(); printf($md->html("* line1 end * line2 end")); } public function testUnnumberedListMultiple1() { $this->expectOutputString(""); $md = new Markdown(); printf($md->html("* line1 * line2 * NEW lineA * NEW lineB * line3")); } // Numbered lists public function testNumbered1() { $this->expectOutputString("
  1. Case1
  2. Case2
  3. Case3
"); $md = new Markdown(); printf($md->html("1. Case1\n2. Case2\n3. Case3"), true); } // Code public function testCode1() { $this->expectOutputString("
test
    indent
base
"); $md = new Markdown(); printf($md->html(" test indent base")); } // Inline code public function testInlineCode1() { $this->expectOutputString("

code

"); $md = new Markdown(); printf($md->html("`code`")); } // Links public function testLinkHTTP1() { $this->expectOutputString( "

http://example.com

" ); $md = new Markdown(); printf($md->html("")); } public function testLinkHTTP2() { $this->expectOutputString( "

https://example.com

" ); $md = new Markdown(); printf($md->html("")); } public function testLinkHTTP3() { $this->expectOutputString( "

test@example.com

" ); $md = new Markdown(); printf($md->html("")); } public function testLinkHTTP4() { $this->expectOutputString( "

test_with_underscore@example.com

" ); $md = new Markdown(); printf($md->html("")); } // Chaining public function testChain1() { $this->expectOutputString("

t1

t2

"); $md = new Markdown(); printf($md->html("# t1\n## t2")); } public function testChainCode1() { $this->expectOutputString("

* OK
"); $md = new Markdown(); printf($md->html(" \n * OK")); } public function testChainCode2() { $this->expectOutputString("

* * * * * www-data OK
"); $md = new Markdown(); printf($md->html(" \n * * * * * www-data OK")); } public function testChainCode3() { $this->expectOutputString("

To write

* * * * * www-data OK
"); $md = new Markdown(); printf($md->html("To write * * * * * www-data OK")); } public function testUnnumberredAndText1() { $this->expectOutputString("

Hi

  • line1
  • line2 end
"); $md = new Markdown(); printf($md->html("Hi * line1 * line2 end")); } public function testCarriageReturn1() { $this->expectOutputString("

line1 line2

"); $md = new Markdown(); printf($md->html("line1\nline2\n")); } public function testCarriageReturn2() { $this->expectOutputString("

line1
line2

"); $md = new Markdown(); printf($md->html("line1 \nline2\n")); } public function testCarriageReturn3() { $this->expectOutputString("

line1 line2 line3.

"); $md = new Markdown(); printf($md->html("line1 line2 line3.")); } public function testHTMLSpecialChars1() { $this->expectOutputString("

toto&titi

"); $md = new Markdown(); printf($md->html("toto&titi")); } public function testHTMLSpecialChars2() { $this->expectOutputString("

totoétiti

"); $md = new Markdown(); printf($md->html("totoétiti")); } }