Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

58 lines
1.4KB

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