Add markdown phpunit tests
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1506 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
233
Tests/markdownTest.php
Normal file
233
Tests/markdownTest.php
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/** DomFramework - Tests
|
||||
@package domframework
|
||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||
|
||||
/** Test the outputjson.php file */
|
||||
class test_markdown extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
// TitleSeText
|
||||
public function testTitleSeText1 ()
|
||||
{
|
||||
$this->expectOutputString("<h1>test</h1>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("test\n====\n"), TRUE);
|
||||
}
|
||||
|
||||
public function testTitleSeText2 ()
|
||||
{
|
||||
$this->expectOutputString("<h2>test</h2>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("test\n----\n"), TRUE);
|
||||
}
|
||||
|
||||
// Titles Sharp
|
||||
public function testTitleSharp1 ()
|
||||
{
|
||||
$this->expectOutputString("<h1>test</h1>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("# test #"));
|
||||
}
|
||||
|
||||
public function testTitleSharp2 ()
|
||||
{
|
||||
$this->expectOutputString("<h2>test</h2>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("## test ##"));
|
||||
}
|
||||
|
||||
public function testTitleSharp3 ()
|
||||
{
|
||||
$this->expectOutputString("<h3>test</h3>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("### test ###"));
|
||||
}
|
||||
|
||||
public function testTitleSharp4 ()
|
||||
{
|
||||
$this->expectOutputString("<h4>test</h4>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("#### test ####"));
|
||||
}
|
||||
|
||||
public function testTitleSharp5 ()
|
||||
{
|
||||
$this->expectOutputString("<h5>test</h5>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("##### test #####"));
|
||||
}
|
||||
|
||||
public function testTitleSharp6 ()
|
||||
{
|
||||
$this->expectOutputString("<h6>test</h6>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("###### test #######"));
|
||||
}
|
||||
|
||||
// Separator
|
||||
public function testSeparator1 ()
|
||||
{
|
||||
$this->expectOutputString("<hr/>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("---\n"), TRUE);
|
||||
}
|
||||
|
||||
public function testSeparator2 ()
|
||||
{
|
||||
$this->expectOutputString("<hr/>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("___\n"), TRUE);
|
||||
}
|
||||
|
||||
public function testSeparator3 ()
|
||||
{
|
||||
$this->expectOutputString("<hr/>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("***\n"), TRUE);
|
||||
}
|
||||
|
||||
public function testSeparator4 ()
|
||||
{
|
||||
$this->expectOutputString("<hr/>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("- - -\n"), TRUE);
|
||||
}
|
||||
|
||||
public function testSeparator5 ()
|
||||
{
|
||||
$this->expectOutputString("<hr/>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("_ _ _\n"), TRUE);
|
||||
}
|
||||
|
||||
public function testSeparator6 ()
|
||||
{
|
||||
$this->expectOutputString("<hr/>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("* * *\n"), TRUE);
|
||||
}
|
||||
|
||||
// Simple Text
|
||||
public function testSimpleText ()
|
||||
{
|
||||
$this->expectOutputString("<p>text</p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("text"), TRUE);
|
||||
}
|
||||
|
||||
// Emphasis
|
||||
public function testEmphasisStrong1 ()
|
||||
{
|
||||
$this->expectOutputString("<p><strong>text</strong></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("__text__"));
|
||||
}
|
||||
|
||||
public function testEmphasisStrong2 ()
|
||||
{
|
||||
$this->expectOutputString("<p><strong>text</strong></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("**text**"));
|
||||
}
|
||||
|
||||
public function testEmphasisEM1 ()
|
||||
{
|
||||
$this->expectOutputString("<p><em>text</em></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("_text_"));
|
||||
}
|
||||
|
||||
public function testEmphasisEM2 ()
|
||||
{
|
||||
$this->expectOutputString("<p><em>text</em></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("*text*"));
|
||||
}
|
||||
// Unnumbered lists
|
||||
public function testUnnumbered1 ()
|
||||
{
|
||||
$this->expectOutputString("<ul>
|
||||
<li>Case1</li>
|
||||
<li>Case2</li>
|
||||
<li>Case3</li>
|
||||
</ul>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("* Case1\n* Case2\n* Case3"), TRUE);
|
||||
}
|
||||
|
||||
public function testUnnumbered2 ()
|
||||
{
|
||||
$this->expectOutputString("<ul>
|
||||
<li>Case1</li>
|
||||
<li>Case2</li>
|
||||
<li>Case3</li>
|
||||
</ul>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("- Case1\n- Case2\n- Case3"), TRUE);
|
||||
}
|
||||
|
||||
public function testUnnumbered3 ()
|
||||
{
|
||||
$this->expectOutputString("<ul>
|
||||
<li>Case1</li>
|
||||
<li>Case2</li>
|
||||
<li>Case3</li>
|
||||
</ul>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("+ Case1\n+ Case2\n+ Case3"), TRUE);
|
||||
}
|
||||
|
||||
// Numbered lists
|
||||
public function testNumbered1 ()
|
||||
{
|
||||
$this->expectOutputString("<ol>
|
||||
<li>Case1</li>
|
||||
<li>Case2</li>
|
||||
<li>Case3</li>
|
||||
</ol>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("1. Case1\n2. Case2\n3. Case3"), TRUE);
|
||||
}
|
||||
|
||||
// Code
|
||||
public function testCode1 ()
|
||||
{
|
||||
$this->expectOutputString(" <pre><code>test
|
||||
indent
|
||||
base</code></pre>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html (" test
|
||||
indent
|
||||
base"));
|
||||
}
|
||||
|
||||
// Inline code
|
||||
public function testInlineCode1 ()
|
||||
{
|
||||
$this->expectOutputString("<p><code>code</code></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("`code`"));
|
||||
}
|
||||
|
||||
// Links
|
||||
public function testLinkHTTP1 ()
|
||||
{
|
||||
$this->expectOutputString("<p><a href='http://example.com'>http://example.com</a></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("<http://example.com>"));
|
||||
}
|
||||
|
||||
public function testLinkHTTP2 ()
|
||||
{
|
||||
$this->expectOutputString("<p><a href='https://example.com'>https://example.com</a></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("<https://example.com>"));
|
||||
}
|
||||
|
||||
public function testLinkHTTP3 ()
|
||||
{
|
||||
$this->expectOutputString("<p><a href='mailto://test@example.com'>test@example.com</a></p>");
|
||||
$md = new markdown ();
|
||||
printf ($md->html ("<test@example.com>"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user