git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1800 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
352 lines
7.7 KiB
PHP
352 lines
7.7 KiB
PHP
<?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>file1.php</em> or <em>file2.php</em></p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("_file1.php_ or _file2.php_"));
|
|
}
|
|
|
|
public function testEmphasisEM3 ()
|
|
{
|
|
$this->expectOutputString("<p><em>text</em></p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("*text*"));
|
|
}
|
|
|
|
public function testEmphasisEM4 ()
|
|
{
|
|
$this->expectOutputString("<p><em>text</em> or <em>text2</em></p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("*text* or *text2*"));
|
|
}
|
|
|
|
// 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);
|
|
}
|
|
|
|
public function testUnnumberredMultiline1 ()
|
|
{
|
|
$this->expectOutputString("<ul>
|
|
<li>line1 end</li>
|
|
<li>line2 end</li>
|
|
</ul>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("* line1
|
|
end
|
|
* line2
|
|
end"));
|
|
}
|
|
|
|
public function testUnnumberedListMultiple1 ()
|
|
{
|
|
$this->expectOutputString("<ul>
|
|
<li>line1</li>
|
|
<li>line2
|
|
<ul>
|
|
<li>NEW lineA</li>
|
|
<li>NEW lineB</li>
|
|
</ul>
|
|
</li>
|
|
<li>line3</li>
|
|
</ul>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("* line1
|
|
* line2
|
|
* NEW lineA
|
|
* NEW lineB
|
|
* line3"));
|
|
}
|
|
|
|
// 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>"));
|
|
}
|
|
|
|
// Chaining
|
|
public function testChain1 ()
|
|
{
|
|
$this->expectOutputString("<h1>t1</h1><h2>t2</h2>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("# t1\n## t2"));
|
|
}
|
|
|
|
public function testChainCode1 ()
|
|
{
|
|
$this->expectOutputString("<pre><code>
|
|
* OK</code></pre>");
|
|
$md = new markdown ();
|
|
printf ($md->html (" \n * OK"));
|
|
}
|
|
|
|
public function testUnnumberredAndText1 ()
|
|
{
|
|
$this->expectOutputString("<p>Hi</p>
|
|
<ul>
|
|
<li>line1</li>
|
|
<li>line2 end</li>
|
|
</ul>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("Hi
|
|
* line1
|
|
* line2
|
|
end"));
|
|
}
|
|
|
|
public function testCarriageReturn1 ()
|
|
{
|
|
$this->expectOutputString("<p>line1 line2</p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("line1\nline2\n"));
|
|
}
|
|
|
|
public function testCarriageReturn2 ()
|
|
{
|
|
$this->expectOutputString("<p>line1<br/>line2</p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("line1 \nline2\n"));
|
|
}
|
|
|
|
public function testCarriageReturn3 ()
|
|
{
|
|
$this->expectOutputString("<p>line1 line2 line3.</p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("line1
|
|
line2
|
|
line3."));
|
|
}
|
|
|
|
public function testHTMLSpecialChars1 ()
|
|
{
|
|
$this->expectOutputString("<p>toto&titi</p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("toto&titi"));
|
|
}
|
|
|
|
public function testHTMLSpecialChars2 ()
|
|
{
|
|
$this->expectOutputString("<p>totoétiti</p>");
|
|
$md = new markdown ();
|
|
printf ($md->html ("totoétiti"));
|
|
}
|
|
}
|