diff options
Diffstat (limited to 'tests/formatter/BookmarkMarkdownFormatterTest.php')
-rw-r--r-- | tests/formatter/BookmarkMarkdownFormatterTest.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/formatter/BookmarkMarkdownFormatterTest.php b/tests/formatter/BookmarkMarkdownFormatterTest.php index ab6b4080..32f7b444 100644 --- a/tests/formatter/BookmarkMarkdownFormatterTest.php +++ b/tests/formatter/BookmarkMarkdownFormatterTest.php | |||
@@ -133,6 +133,49 @@ class BookmarkMarkdownFormatterTest extends TestCase | |||
133 | } | 133 | } |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Make sure that the description is properly formatted by the default formatter. | ||
137 | */ | ||
138 | public function testFormatDescriptionWithSearchHighlight() | ||
139 | { | ||
140 | $description = 'This a <strong>description</strong>'. PHP_EOL; | ||
141 | $description .= 'text https://sub.domain.tld?query=here&for=real#hash more text'. PHP_EOL; | ||
142 | $description .= 'Also, there is an #hashtag added'. PHP_EOL; | ||
143 | $description .= ' A N D KEEP SPACES ! '. PHP_EOL; | ||
144 | $description .= 'And [yet another link](https://other.domain.tld)'. PHP_EOL; | ||
145 | |||
146 | $bookmark = new Bookmark(); | ||
147 | $bookmark->setDescription($description); | ||
148 | $bookmark->addAdditionalContentEntry( | ||
149 | 'search_highlight', | ||
150 | ['description' => [ | ||
151 | ['start' => 18, 'end' => 26], // cription | ||
152 | ['start' => 49, 'end' => 52], // sub | ||
153 | ['start' => 84, 'end' => 88], // hash | ||
154 | ['start' => 118, 'end' => 123], // hasht | ||
155 | ['start' => 203, 'end' => 215], // other.domain | ||
156 | ]] | ||
157 | ); | ||
158 | |||
159 | $link = $this->formatter->format($bookmark); | ||
160 | |||
161 | $description = '<div class="markdown"><p>'; | ||
162 | $description .= 'This a <strong>des<span class="search-highlight">cription</span></strong><br />' . | ||
163 | PHP_EOL; | ||
164 | $url = 'https://sub.domain.tld?query=here&for=real#hash'; | ||
165 | $highlighted = 'https://<span class="search-highlight">sub</span>.domain.tld'; | ||
166 | $highlighted .= '?query=here&for=real#<span class="search-highlight">hash</span>'; | ||
167 | $description .= 'text <a href="'. $url .'">'. $highlighted .'</a> more text<br />'. PHP_EOL; | ||
168 | $description .= 'Also, there is an <a href="./add-tag/hashtag">#<span class="search-highlight">hasht</span>' . | ||
169 | 'ag</a> added<br />'. PHP_EOL; | ||
170 | $description .= 'A N D KEEP SPACES !<br />' . PHP_EOL; | ||
171 | $description .= 'And <a href="https://other.domain.tld">' . | ||
172 | '<span class="search-highlight">yet another link</span></a>'; | ||
173 | $description .= '</p></div>'; | ||
174 | |||
175 | $this->assertEquals($description, $link['description']); | ||
176 | } | ||
177 | |||
178 | /** | ||
136 | * Test formatting URL with an index_url set | 179 | * Test formatting URL with an index_url set |
137 | * It should prepend relative links. | 180 | * It should prepend relative links. |
138 | */ | 181 | */ |