2006-11-22 18:55:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_ChildDef_ChameleonTest extends HTMLPurifier_ChildDefHarness
|
|
|
|
{
|
|
|
|
|
2007-11-25 02:24:39 +00:00
|
|
|
protected $isInline;
|
2007-08-06 06:22:23 +00:00
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->obj = new HTMLPurifier_ChildDef_Chameleon(
|
|
|
|
'b | i', // allowed only when in inline context
|
|
|
|
'b | i | div' // allowed only when in block context
|
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
$this->context->register('IsInline', $this->isInline);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testInlineAlwaysAllowed() {
|
|
|
|
$this->isInline = true;
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult(
|
2007-08-06 06:22:23 +00:00
|
|
|
'<b>Allowed.</b>'
|
2006-11-22 18:55:15 +00:00
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testBlockNotAllowedInInline() {
|
|
|
|
$this->isInline = true;
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult(
|
2007-08-06 06:22:23 +00:00
|
|
|
'<div>Not allowed.</div>', ''
|
2006-11-22 18:55:15 +00:00
|
|
|
);
|
2007-08-06 06:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testBlockAllowedInNonInline() {
|
|
|
|
$this->isInline = false;
|
2006-11-22 18:55:15 +00:00
|
|
|
$this->assertResult(
|
2007-08-06 06:22:23 +00:00
|
|
|
'<div>Allowed.</div>'
|
2006-11-22 18:55:15 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|