/
MarkdownTest.php
92 lines (81 loc) · 2.88 KB
/
MarkdownTest.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* Test cases for markdown handling within mantis
*
* @package Tests
* @subpackage String
* @copyright Copyright 2016 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/
# Includes
require_once( dirname( __FILE__, 2 ) . '/../../tests/TestConfig.php' );
require_once( dirname( __FILE__, 2 ) . '/core/MantisMarkdown.php' );
# MantisBT Core API
require_mantis_core();
/**
* Mantis markdown handling test cases
* @package Tests
* @subpackage Markdown
* @copyright Copyright 2016 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/
class MantisMarkdownTest extends PHPUnit\Framework\TestCase {
/**
* Test If string starts with hash character followed by letters
* @return void
*/
public function testHashLetters() {
$this->assertEquals( '<h1>hello</h1>', MantisMarkdown::convert_text( '# hello' ) );
$this->assertEquals( '<p>#hello</p>', MantisMarkdown::convert_text( '#hello' ) );
}
/**
* Test If string starts with hash character followed by number and letters
* @return void
*/
public function testHashNumberAny() {
$this->assertEquals( '<h1>1abcd</h1>', MantisMarkdown::convert_text( '# 1abcd' ) );
$this->assertEquals( '<p>#1abcd</p>', MantisMarkdown::convert_text( '#1abcd' ) );
}
/**
* Test If string starts with hash character followed by letters and numbers
* @return void
*/
public function testHashLettersAny() {
$this->assertEquals( '<h1>abcd1234</h1>', MantisMarkdown::convert_text( '# abcd1234' ) );
$this->assertEquals( '<p>#abcd1234</p>', MantisMarkdown::convert_text( '#abcd1234' ) );
}
/**
* Test If string starts with hash character followed by numbers
* since the class overrides the default Markdown parsing on Header
* then the methods should return the standard text.
* @return void
*/
public function testHashNumbers() {
$this->assertEquals( '<p>#1</p>', MantisMarkdown::convert_text( '#1' ) );
}
/**
* Test if table class attribute is defined
* @return void
*/
public function testTableClassDefined() {
$markdown_table = <<<EOD
| header |
| --- |
| cell |
EOD;
$this->assertTrue( false !== strpos( MantisMarkdown::convert_text( $markdown_table ), 'class="table table-nonfluid"' ));
}
}