2006-11-22 18:55:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_ChildDef_ChameleonTest extends HTMLPurifier_ChildDefHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2007-11-25 02:24:39 +00:00
|
|
|
protected $isInline;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function setUp()
|
|
|
|
{
|
2007-08-06 06:22:23 +00:00
|
|
|
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);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testInlineAlwaysAllowed()
|
|
|
|
{
|
2007-08-06 06:22:23 +00:00
|
|
|
$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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testBlockNotAllowedInInline()
|
|
|
|
{
|
2007-08-06 06:22:23 +00:00
|
|
|
$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
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testBlockAllowedInNonInline()
|
|
|
|
{
|
2007-08-06 06:22:23 +00:00
|
|
|
$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
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2006-11-22 18:55:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|