GithubMarkdownTest.php
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @copyright Copyright (c) 2014 Carsten Brandt
* @license https://github.com/cebe/markdown/blob/master/LICENSE
* @link https://github.com/cebe/markdown#readme
*/
namespace cebe\markdown\tests;
use cebe\markdown\GithubMarkdown;
/**
* Test case for the github flavored markdown.
*
* @author Carsten Brandt <mail@cebe.cc>
* @group github
*/
class GithubMarkdownTest extends BaseMarkdownTest
{
public function createMarkdown()
{
return new GithubMarkdown();
}
public function getDataPaths()
{
return [
'markdown-data' => __DIR__ . '/markdown-data',
'github-data' => __DIR__ . '/github-data',
];
}
public function testNewlines()
{
$markdown = $this->createMarkdown();
$this->assertEquals("This is text<br />\nnewline\nnewline.", $markdown->parseParagraph("This is text \nnewline\nnewline."));
$markdown->enableNewlines = true;
$this->assertEquals("This is text<br />\nnewline<br />\nnewline.", $markdown->parseParagraph("This is text \nnewline\nnewline."));
$this->assertEquals("<p>This is text</p>\n<p>newline<br />\nnewline.</p>\n", $markdown->parse("This is text\n\nnewline\nnewline."));
}
public function dataFiles()
{
$files = parent::dataFiles();
foreach($files as $i => $f) {
// skip files that are different in github MD
if ($f[0] === 'markdown-data' && (
$f[1] === 'list-marker-in-paragraph' ||
$f[1] === 'dense-block-markers'
)) {
unset($files[$i]);
}
}
return $files;
}
public function testKeepZeroAlive()
{
$parser = $this->createMarkdown();
$this->assertEquals("0", $parser->parseParagraph("0"));
$this->assertEquals("<p>0</p>\n", $parser->parse("0"));
}
}