Fix #76, linkify includes dots at end of URL.
[htmlpurifier.git] / tests / HTMLPurifier / Injector / LinkifyTest.php
blob8eeac449c99d5b0a494f1f4ce449cacc9420a433
1 <?php
3 class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
6 public function setup()
8 parent::setup();
9 $this->config->set('AutoFormat.Linkify', true);
12 public function testLinkifyURLInRootNode()
14 $this->assertResult(
15 'http://example.com',
16 '<a href="http://example.com">http://example.com</a>'
20 public function testLinkifyURLInInlineNode()
22 $this->assertResult(
23 '<b>http://example.com</b>',
24 '<b><a href="http://example.com">http://example.com</a></b>'
28 public function testBasicUsageCase()
30 $this->assertResult(
31 'This URL http://example.com is what you need',
32 'This URL <a href="http://example.com">http://example.com</a> is what you need'
36 public function testIgnoreURLInATag()
38 $this->assertResult(
39 '<a>http://example.com/</a>'
43 public function testNeeded()
45 $this->config->set('HTML.Allowed', 'b');
46 $this->expectError('Cannot enable Linkify injector because a is not allowed');
47 $this->assertResult('http://example.com/');
50 public function testExcludes()
52 $this->assertResult('<a><span>http://example.com</span></a>');
55 public function testRegexIsSmart()
57 $this->assertResult('http://example.com/foo.', '<a href="http://example.com/foo">http://example.com/foo</a>.');
58 $this->assertResult('“http://example.com/foo”', '“<a href="http://example.com/foo">http://example.com/foo</a>”');
59 $this->assertResult('“http://example.com”', '“<a href="http://example.com">http://example.com</a>”');
60 $this->assertResult('(http://example.com/f(o)o)', '(<a href="http://example.com/f(o)o">http://example.com/f(o)o</a>)');
65 // vim: et sw=4 sts=4