From ebc1bcb624811ad41141ebe0298b2b4f0450e71f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 27 Oct 2014 21:03:03 -0400 Subject: [PATCH] Add additional useful tests for autoLink() These new tests cover an important case that could easily be missed in the future. Links with URL's should not be re-linked. Refs #4998 --- .../Test/Case/View/Helper/TextHelperTest.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index 0c93e3085ae..c4e36aaa783 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -314,6 +314,16 @@ public function testAutoLinkUrlsOptions() { * @return void */ public function testAutoLinkUrlsEscape() { + $text = 'Text with a partial http://www.example.com link'; + $expected = 'Text with a partial http://www.example.com link'; + $result = $this->Text->autoLinkUrls($text, array('escape' => false)); + $this->assertEquals($expected, $result); + + $text = 'Text with a partial www.example.com link'; + $expected = 'Text with a partial www.example.com link'; + $result = $this->Text->autoLinkUrls($text, array('escape' => false)); + $this->assertEquals($expected, $result); + $text = 'Text with a partial link link'; $expected = 'Text with a partial link link'; $result = $this->Text->autoLinkUrls($text, array('escape' => false)); @@ -331,22 +341,22 @@ public function testAutoLinkUrlsEscape() { $text = 'Text with a url www.not-working-www.com and more'; $expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more'; - $result = $this->Text->autoLinkUrls($text); + $result = $this->Text->autoLinkUrls($text, array('escape' => true)); $this->assertEquals($expected, $result); $text = 'Text with a url www.not-working-www.com and more'; $expected = 'Text with a url www.not-working-www.com and more'; - $result = $this->Text->autoLinkUrls($text); + $result = $this->Text->autoLinkUrls($text, array('escape' => false)); $this->assertEquals($expected, $result); $text = 'Text with a url http://www.not-working-www.com and more'; $expected = 'Text with a url http://www.not-working-www.com and more'; - $result = $this->Text->autoLinkUrls($text); + $result = $this->Text->autoLinkUrls($text, array('escape' => false)); $this->assertEquals($expected, $result); $text = 'Text with a url http://www.www.not-working-www.com and more'; $expected = 'Text with a url http://www.www.not-working-www.com and more'; - $result = $this->Text->autoLinkUrls($text); + $result = $this->Text->autoLinkUrls($text, array('escape' => false)); $this->assertEquals($expected, $result); }