Improve auto-paragraph to preserve newlines and handle edge-cases better.
[htmlpurifier.git] / tests / HTMLPurifier / AttrValidator_ErrorsTest.php
blobd3242c0650e940c5880051d2287d4cade2fd05a9
1 <?php
3 class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
6 protected function invoke($input) {
7 $validator = new HTMLPurifier_AttrValidator();
8 $validator->validateToken($input, $this->config, $this->context);
11 function testAttributesTransformedGlobalPre() {
12 $this->config->set('HTML', 'DefinitionID',
13 'HTMLPurifier_AttrValidator_ErrorsTest::testAttributesTransformedGlobalPre');
14 $def = $this->config->getHTMLDefinition(true);
15 generate_mock_once('HTMLPurifier_AttrTransform');
16 $transform = new HTMLPurifier_AttrTransformMock();
17 $input = array('original' => 'value');
18 $output = array('class' => 'value'); // must be valid
19 $transform->setReturnValue('transform', $output, array($input, new AnythingExpectation(), new AnythingExpectation()));
20 $def->info_attr_transform_pre[] = $transform;
21 $this->expectErrorCollection(E_NOTICE, 'AttrValidator: Attributes transformed', $input, $output);
22 $token = new HTMLPurifier_Token_Start('span', $input, 1);
23 $this->invoke($token);
26 function testAttributesTransformedLocalPre() {
27 $this->config->set('HTML', 'TidyLevel', 'heavy');
28 $input = array('align' => 'right');
29 $output = array('style' => 'text-align:right;');
30 $this->expectErrorCollection(E_NOTICE, 'AttrValidator: Attributes transformed', $input, $output);
31 $token = new HTMLPurifier_Token_Start('p', $input, 1);
32 $this->invoke($token);
35 // too lazy to check for global post and global pre
37 function testAttributeRemoved() {
38 $this->expectErrorCollection(E_ERROR, 'AttrValidator: Attribute removed');
39 $this->expectContext('CurrentAttr', 'foobar');
40 $token = new HTMLPurifier_Token_Start('p', array('foobar' => 'right'), 1);
41 $this->expectContext('CurrentToken', $token);
42 $this->invoke($token);