ChameleonTest.php 931 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. class HTMLPurifier_ChildDef_ChameleonTest extends HTMLPurifier_ChildDefHarness
  3. {
  4. protected $isInline;
  5. function setUp() {
  6. parent::setUp();
  7. $this->obj = new HTMLPurifier_ChildDef_Chameleon(
  8. 'b | i', // allowed only when in inline context
  9. 'b | i | div' // allowed only when in block context
  10. );
  11. $this->context->register('IsInline', $this->isInline);
  12. }
  13. function testInlineAlwaysAllowed() {
  14. $this->isInline = true;
  15. $this->assertResult(
  16. '<b>Allowed.</b>'
  17. );
  18. }
  19. function testBlockNotAllowedInInline() {
  20. $this->isInline = true;
  21. $this->assertResult(
  22. '<div>Not allowed.</div>', ''
  23. );
  24. }
  25. function testBlockAllowedInNonInline() {
  26. $this->isInline = false;
  27. $this->assertResult(
  28. '<div>Allowed.</div>'
  29. );
  30. }
  31. }
  32. // vim: et sw=4 sts=4