2007-06-24 21:35:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setup()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
parent::setup();
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('AutoFormat.Linkify', true);
|
2007-06-24 21:35:34 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLinkifyURLInRootNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'http://example.com',
|
|
|
|
'<a href="http://example.com">http://example.com</a>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLinkifyURLInInlineNode()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<b>http://example.com</b>',
|
|
|
|
'<b><a href="http://example.com">http://example.com</a></b>'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testBasicUsageCase()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'This URL http://example.com is what you need',
|
|
|
|
'This URL <a href="http://example.com">http://example.com</a> is what you need'
|
|
|
|
);
|
2007-08-08 05:38:52 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testIgnoreURLInATag()
|
|
|
|
{
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<a>http://example.com/</a>'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testNeeded()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.Allowed', 'b');
|
2007-06-28 13:06:15 +00:00
|
|
|
$this->expectError('Cannot enable Linkify injector because a is not allowed');
|
2007-08-08 05:38:52 +00:00
|
|
|
$this->assertResult('http://example.com/');
|
2007-06-28 13:06:15 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testExcludes()
|
|
|
|
{
|
2009-06-10 22:11:34 +00:00
|
|
|
$this->assertResult('<a><span>http://example.com</span></a>');
|
|
|
|
}
|
|
|
|
|
2007-06-24 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|