Release 1.6.1, merged in 931 to HEAD.
[htmlpurifier.git] / tests / HTMLPurifier / AttrTransform / EnumToCSSTest.php
blob565cee451f7b744b9b74aa35ce856c1e8cdd23be
1 <?php
3 require_once 'HTMLPurifier/AttrTransform/EnumToCSS.php';
4 require_once 'HTMLPurifier/AttrTransformHarness.php';
6 class HTMLPurifier_AttrTransform_EnumToCSSTest extends HTMLPurifier_AttrTransformHarness
9 function testRegular() {
11 $this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
12 'left' => 'text-align:left;',
13 'right' => 'text-align:right;'
14 ));
16 // leave empty arrays alone
17 $this->assertResult( array() );
19 // leave arrays without interesting stuff alone
20 $this->assertResult( array('style' => 'font-weight:bold;') );
22 // test each of the conversions
24 $this->assertResult(
25 array('align' => 'left'),
26 array('style' => 'text-align:left;')
29 $this->assertResult(
30 array('align' => 'right'),
31 array('style' => 'text-align:right;')
34 // drop garbage value
35 $this->assertResult(
36 array('align' => 'invalid'),
37 array()
40 // test CSS munging
41 $this->assertResult(
42 array('align' => 'left', 'style' => 'font-weight:bold;'),
43 array('style' => 'text-align:left;font-weight:bold;')
48 function testCaseInsensitive() {
50 $this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
51 'right' => 'text-align:right;'
52 ));
54 // test case insensitivity
55 $this->assertResult(
56 array('align' => 'RIGHT'),
57 array('style' => 'text-align:right;')
62 function testCaseSensitive() {
64 $this->obj = new HTMLPurifier_AttrTransform_EnumToCSS('align', array(
65 'right' => 'text-align:right;'
66 ), true);
68 // test case insensitivity
69 $this->assertResult(
70 array('align' => 'RIGHT'),
71 array()