2008-05-21 01:56:48 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrDef_SwitchTest extends HTMLPurifier_AttrDefHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-05-21 01:56:48 +00:00
|
|
|
protected $with, $without;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setUp()
|
|
|
|
{
|
2008-05-21 01:56:48 +00:00
|
|
|
parent::setUp();
|
|
|
|
generate_mock_once('HTMLPurifier_AttrDef');
|
|
|
|
$this->with = new HTMLPurifier_AttrDefMock();
|
|
|
|
$this->without = new HTMLPurifier_AttrDefMock();
|
|
|
|
$this->def = new HTMLPurifier_AttrDef_Switch('tag', $this->with, $this->without);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testWith()
|
|
|
|
{
|
2008-05-21 01:56:48 +00:00
|
|
|
$token = new HTMLPurifier_Token_Start('tag');
|
|
|
|
$this->context->register('CurrentToken', $token);
|
|
|
|
$this->with->expectOnce('validate');
|
2016-03-24 07:08:03 +00:00
|
|
|
$this->with->returns('validate', 'foo');
|
2008-05-21 01:56:48 +00:00
|
|
|
$this->assertDef('bar', 'foo');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testWithout()
|
|
|
|
{
|
2008-05-21 01:56:48 +00:00
|
|
|
$token = new HTMLPurifier_Token_Start('other-tag');
|
|
|
|
$this->context->register('CurrentToken', $token);
|
|
|
|
$this->without->expectOnce('validate');
|
2016-03-24 07:08:03 +00:00
|
|
|
$this->without->returns('validate', 'foo');
|
2008-05-21 01:56:48 +00:00
|
|
|
$this->assertDef('bar', 'foo');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-05-21 01:56:48 +00:00
|
|
|
}
|
2008-12-06 09:24:59 +00:00
|
|
|
|
|
|
|
// vim: et sw=4 sts=4
|