2007-06-24 21:35:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/InjectorHarness.php';
|
|
|
|
require_once 'HTMLPurifier/Injector/Linkify.php';
|
|
|
|
|
|
|
|
class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
|
|
|
|
{
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
parent::setup();
|
2007-08-08 05:38:52 +00:00
|
|
|
$this->config->set('AutoFormat', 'Linkify', true);
|
2007-06-24 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2007-08-08 05:38:52 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
function testIgnoreURLInATag() {
|
2007-06-24 21:35:34 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<a>http://example.com/</a>'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-06-28 13:06:15 +00:00
|
|
|
function testNeeded() {
|
2007-08-08 05:38:52 +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
|
|
|
}
|
|
|
|
|
2007-06-24 21:35:34 +00:00
|
|
|
}
|
|
|
|
|