SwitchTest.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. class HTMLPurifier_AttrDef_SwitchTest extends HTMLPurifier_AttrDefHarness
  3. {
  4. protected $with, $without;
  5. function setUp() {
  6. parent::setUp();
  7. generate_mock_once('HTMLPurifier_AttrDef');
  8. $this->with = new HTMLPurifier_AttrDefMock();
  9. $this->without = new HTMLPurifier_AttrDefMock();
  10. $this->def = new HTMLPurifier_AttrDef_Switch('tag', $this->with, $this->without);
  11. }
  12. function testWith() {
  13. $token = new HTMLPurifier_Token_Start('tag');
  14. $this->context->register('CurrentToken', $token);
  15. $this->with->expectOnce('validate');
  16. $this->with->setReturnValue('validate', 'foo');
  17. $this->assertDef('bar', 'foo');
  18. }
  19. function testWithout() {
  20. $token = new HTMLPurifier_Token_Start('other-tag');
  21. $this->context->register('CurrentToken', $token);
  22. $this->without->expectOnce('validate');
  23. $this->without->setReturnValue('validate', 'foo');
  24. $this->assertDef('bar', 'foo');
  25. }
  26. }
  27. // vim: et sw=4 sts=4