From 7e20ef5dd685619cb20bf942329294daa97e0041 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 27 Jan 2016 15:49:52 -0700 Subject: [PATCH] Added start of Markdown tests --- tests/unit/Grav/Common/MarkdownTest.php | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/unit/Grav/Common/MarkdownTest.php diff --git a/tests/unit/Grav/Common/MarkdownTest.php b/tests/unit/Grav/Common/MarkdownTest.php new file mode 100644 index 000000000..9b08c5169 --- /dev/null +++ b/tests/unit/Grav/Common/MarkdownTest.php @@ -0,0 +1,74 @@ + false, + 'auto_line_breaks' => false, + 'auto_url_links' => false, + 'escape_markup' => false, + 'special_chars' => ['>' => 'gt', '<' => 'lt'], + ]; + $page = new \Grav\Common\Page\Page(); + + $this->parsedown = new Parsedown($page, $defaults); + } + + protected function _after() + { + } + + public function grav() + { + $grav = Fixtures::get('grav'); + return $grav; + } + + public function stripLeadingWhitespace($string) + { + return preg_replace('/^\s*(.*)/', '', $string); + } + + + public function testMarkdownSpecialProtocols() + { + $this->assertSame($this->parsedown->text('[mailto](mailto:user@domain.com)'), '

mailto

'); + $this->assertSame($this->parsedown->text('[xmpp](xmpp:xyx@domain.com)'), '

xmpp

'); + $this->assertSame($this->parsedown->text('[tel](tel:123-555-12345)'), '

tel

'); + $this->assertSame($this->parsedown->text('[sms](sms:123-555-12345)'), '

sms

'); + } + + public function testMarkdownReferenceLinks() + { + $sample = '[relative link][r_relative] + [r_relative]: ../03.assets#blah'; + $this->assertSame($this->parsedown->text($sample), '

relative link

'); + + $sample = '[absolute link][r_absolute] + [r_absolute]: /blog/focus-and-blur#blah'; + $this->assertSame($this->parsedown->text($sample), '

absolute link

'); + + $sample = '[external link][r_external] + [r_external]: http://www.cnn.com'; + $this->assertSame($this->parsedown->text($sample), '

external link

'); + } + + public function testMarkdownExternalLinks() + { + $this->assertSame($this->parsedown->text('[cnn.com](http://www.cnn.com)'), '

cnn.com

'); + $this->assertSame($this->parsedown->text('[google.com](https://www.google.com)'), '

google.com

'); + } +}