LinkifyTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
  3. {
  4. function setup() {
  5. parent::setup();
  6. $this->config->set('AutoFormat.Linkify', true);
  7. }
  8. function testLinkifyURLInRootNode() {
  9. $this->assertResult(
  10. 'http://example.com',
  11. '<a href="http://example.com">http://example.com</a>'
  12. );
  13. }
  14. function testLinkifyURLInInlineNode() {
  15. $this->assertResult(
  16. '<b>http://example.com</b>',
  17. '<b><a href="http://example.com">http://example.com</a></b>'
  18. );
  19. }
  20. function testBasicUsageCase() {
  21. $this->assertResult(
  22. 'This URL http://example.com is what you need',
  23. 'This URL <a href="http://example.com">http://example.com</a> is what you need'
  24. );
  25. }
  26. function testIgnoreURLInATag() {
  27. $this->assertResult(
  28. '<a>http://example.com/</a>'
  29. );
  30. }
  31. function testNeeded() {
  32. $this->config->set('HTML.Allowed', 'b');
  33. $this->expectError('Cannot enable Linkify injector because a is not allowed');
  34. $this->assertResult('http://example.com/');
  35. }
  36. function testExcludes() {
  37. $this->assertResult('<a><span>http://example.com</span></a>');
  38. }
  39. }
  40. // vim: et sw=4 sts=4