Skip to content

Commit

Permalink
Add tests for TextHelper::autoLink()
Browse files Browse the repository at this point in the history
Add tests for email addresses embedded in urls.

Refs #2403
  • Loading branch information
markstory committed Nov 30, 2013
1 parent 155c758 commit bbe4c65
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/Cake/Test/Case/View/Helper/TextHelperTest.php
Expand Up @@ -142,7 +142,27 @@ public function testAutoLink() {
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)';
$result = $this->Text->autoLink($text);
$this->assertEquals($expected, $result);
}

/**
* Test mixing URLs and Email addresses in one confusing string.
*
* @return void
*/
public function testAutoLinkMixed() {
$text = 'Text with a url/email http://example.com/store?email=mark@example.com and email.';
$expected = 'Text with a url/email <a href="http://example.com/store?email=mark@example.com">' .
'http://example.com/store?email=mark@example.com</a> and email.';
$result = $this->Text->autoLink($text);
$this->assertEquals($expected, $result);
}

/**
* test autoLink() and options.
*
* @return void
*/
public function testAutoLinkOptions() {
$text = 'This is a test text with URL http://www.cakephp.org';
$expected = 'This is a test text with URL <a href="http://www.cakephp.org" class="link">http://www.cakephp.org</a>';
$result = $this->Text->autoLink($text, array('class' => 'link'));
Expand Down Expand Up @@ -246,7 +266,7 @@ public static function autoLinkProvider() {
array(
'Text with a partial http://www.küchenschöhn-not-working.de URL',
'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL'
)
),
);
}

Expand Down

0 comments on commit bbe4c65

Please sign in to comment.