diff --git a/Tests/markdownTest.php b/Tests/markdownTest.php new file mode 100644 index 0000000..d06becc --- /dev/null +++ b/Tests/markdownTest.php @@ -0,0 +1,233 @@ + */ + +/** Test the outputjson.php file */ +class test_markdown 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("

text

"); + $md = new markdown (); + printf ($md->html ("*text*")); + } + // 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); + } + + // Numbered lists + public function testNumbered1 () + { + $this->expectOutputString("
    +
  1. Case1
  2. +
  3. Case2
  4. +
  5. Case3
  6. +
"); + $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 ("")); + } +}