mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-14 01:08:41 +00:00
eaabccdd9b
- Removed HTMLPurifier_Error - Documentation updates - Removed more copy() methods in favor of clone - HTMLPurifier::getInstance() to HTMLPurifier::instance() - Fix InterchangeBuilder to use HTMLPURIFIER_PREFIX git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1689 48356398-32a2-884e-a903-53898d9a118a
47 lines
1.9 KiB
PHP
47 lines
1.9 KiB
PHP
<?php
|
|
|
|
class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
|
|
{
|
|
|
|
protected function invoke($input) {
|
|
$validator = new HTMLPurifier_AttrValidator();
|
|
$validator->validateToken($input, $this->config, $this->context);
|
|
}
|
|
|
|
function testAttributesTransformedGlobalPre() {
|
|
$this->config->set('HTML', 'DefinitionID',
|
|
'HTMLPurifier_AttrValidator_ErrorsTest::testAttributesTransformedGlobalPre');
|
|
$def = $this->config->getHTMLDefinition(true);
|
|
generate_mock_once('HTMLPurifier_AttrTransform');
|
|
$transform = new HTMLPurifier_AttrTransformMock();
|
|
$input = array('original' => 'value');
|
|
$output = array('class' => 'value'); // must be valid
|
|
$transform->setReturnValue('transform', $output, array($input, new AnythingExpectation(), new AnythingExpectation()));
|
|
$def->info_attr_transform_pre[] = $transform;
|
|
$this->expectErrorCollection(E_NOTICE, 'AttrValidator: Attributes transformed', $input, $output);
|
|
$token = new HTMLPurifier_Token_Start('span', $input, 1);
|
|
$this->invoke($token);
|
|
}
|
|
|
|
function testAttributesTransformedLocalPre() {
|
|
$this->config->set('HTML', 'TidyLevel', 'heavy');
|
|
$input = array('align' => 'right');
|
|
$output = array('style' => 'text-align:right;');
|
|
$this->expectErrorCollection(E_NOTICE, 'AttrValidator: Attributes transformed', $input, $output);
|
|
$token = new HTMLPurifier_Token_Start('p', $input, 1);
|
|
$this->invoke($token);
|
|
}
|
|
|
|
// too lazy to check for global post and global pre
|
|
|
|
function testAttributeRemoved() {
|
|
$this->expectErrorCollection(E_ERROR, 'AttrValidator: Attribute removed');
|
|
$this->expectContext('CurrentAttr', 'foobar');
|
|
$token = new HTMLPurifier_Token_Start('p', array('foobar' => 'right'), 1);
|
|
$this->expectContext('CurrentToken', $token);
|
|
$this->invoke($token);
|
|
}
|
|
|
|
}
|
|
|