|
20 | 20 | */
|
21 | 21 | class VoidModel extends Table {
|
22 | 22 |
|
23 |
| - /** |
24 |
| - * name property |
25 |
| - * |
26 |
| - * @var string 'TheVoid' |
27 |
| - */ |
28 |
| - public $name = 'VoidModel'; |
| 23 | + /** |
| 24 | + * name property |
| 25 | + * |
| 26 | + * @var string 'TheVoid' |
| 27 | + */ |
| 28 | + public $name = 'VoidModel'; |
29 | 29 |
|
30 |
| - /** |
31 |
| - * useTable property |
32 |
| - * |
33 |
| - * @var bool false |
34 |
| - */ |
35 |
| - public $useTable = false; |
| 30 | + /** |
| 31 | + * useTable property |
| 32 | + * |
| 33 | + * @var bool false |
| 34 | + */ |
| 35 | + public $useTable = false; |
36 | 36 |
|
37 |
| - /** |
38 |
| - * Initialize |
39 |
| - * |
40 |
| - * @param array $config |
41 |
| - * @return void |
42 |
| - */ |
43 |
| - public function initialize(array $config) { |
44 |
| - parent::initialize($config); |
45 |
| - $this->addBehavior('Burzum/HtmlPurifier.HtmlPurifier', [ |
46 |
| - 'fields' => ['field1'] |
47 |
| - ]); |
48 |
| - } |
| 37 | + /** |
| 38 | + * Initialize |
| 39 | + * |
| 40 | + * @param array $config |
| 41 | + * @return void |
| 42 | + */ |
| 43 | + public function initialize(array $config) |
| 44 | + { |
| 45 | + parent::initialize($config); |
| 46 | + $this->addBehavior('Burzum/HtmlPurifier.HtmlPurifier', [ |
| 47 | + 'fields' => ['field1'] |
| 48 | + ]); |
| 49 | + } |
49 | 50 | }
|
50 | 51 |
|
51 | 52 | /**
|
52 | 53 | * HtmlPurifierBehaviorTest
|
53 | 54 | */
|
54 | 55 | class HtmlPurifierBehaviorTest extends TestCase {
|
55 | 56 |
|
56 |
| -/** |
57 |
| - * Holds the instance of the table |
58 |
| - * |
59 |
| - * @var mixed |
60 |
| - */ |
61 |
| - public $Article = null; |
62 |
| - |
63 | 57 | /**
|
64 | 58 | * Fixtures
|
65 | 59 | *
|
66 | 60 | * @var array
|
67 | 61 | */
|
68 |
| - public $fixtures = []; |
| 62 | + public $fixtures = []; |
69 | 63 |
|
70 | 64 | /**
|
71 | 65 | * startTest
|
72 | 66 | *
|
73 | 67 | * @return void
|
74 | 68 | */
|
75 |
| - public function setUp() { |
76 |
| - parent::setUp(); |
| 69 | + public function setUp() |
| 70 | + { |
| 71 | + parent::setUp(); |
77 | 72 |
|
78 |
| - Purifier::config('default', [ |
79 |
| - 'HTML.AllowedElements' => 'a, em, blockquote, p, strong, pre, code, span,ul,ol,li,img', |
80 |
| - 'HTML.AllowedAttributes' => 'a.href, a.title, img.src, img.alt, *.style', |
81 |
| - 'CSS.AllowedProperties' => 'text-decoration', |
82 |
| - 'HTML.TidyLevel' => 'heavy', |
83 |
| - 'HTML.Doctype' => 'XHTML 1.0 Transitional' |
84 |
| - ]); |
| 73 | + Purifier::config('default', [ |
| 74 | + 'HTML.AllowedElements' => 'a, em, blockquote, p, strong, pre, code, span,ul,ol,li,img', |
| 75 | + 'HTML.AllowedAttributes' => 'a.href, a.title, img.src, img.alt, *.style', |
| 76 | + 'CSS.AllowedProperties' => 'text-decoration', |
| 77 | + 'HTML.TidyLevel' => 'heavy', |
| 78 | + 'HTML.Doctype' => 'XHTML 1.0 Transitional' |
| 79 | + ]); |
85 | 80 |
|
86 |
| - $this->table = new VoidModel(); |
87 |
| - } |
| 81 | + $this->table = new VoidModel(); |
| 82 | + } |
88 | 83 |
|
89 | 84 | /**
|
90 | 85 | * endTest
|
91 | 86 | *
|
92 | 87 | * @return void
|
93 | 88 | */
|
94 |
| - public function tearDown() { |
95 |
| - unset($this->table); |
96 |
| - } |
| 89 | + public function tearDown() |
| 90 | + { |
| 91 | + unset($this->table); |
| 92 | + } |
97 | 93 |
|
98 | 94 | /**
|
99 | 95 | * configureUploadValidation
|
100 | 96 | *
|
101 | 97 | * @return void
|
102 | 98 | */
|
103 |
| - public function testBeforeMarshal() { |
104 |
| - $html = '<p style="font-weight: bold;"><script>alert("alert!");</script><span style="text-decoration: line-through;" _mce_style="text-decoration: line-through;">shsfhshs</span></p><p><strong>sdhsdhds</strong></p><p><em>shsdh</em><span style="text-decoration: underline;" _mce_style="text-decoration: underline;">dsh</span></p><ul><li>sdgsgssgd</li><li>sdgdsg</li><li>sdgsdgsg</li><li>sdgdg<br></li></ul>'; |
105 |
| - $expected = '<p><span style="text-decoration:line-through;">shsfhshs</span></p><p><strong>sdhsdhds</strong></p><p><em>shsdh</em><span style="text-decoration:underline;">dsh</span></p><ul><li>sdgsgssgd</li><li>sdgdsg</li><li>sdgsdgsg</li><li>sdgdg</li></ul>'; |
106 |
| - $event = new Event('Model.beforeMarshal'); |
107 |
| - $data = new \ArrayObject([ |
108 |
| - 'field1' => $html, |
109 |
| - 'field2' => '<b>Don\'t change me!</b>' |
110 |
| - ]); |
111 |
| - $options = new \ArrayObject(); |
112 |
| - $this->table->behaviors()->HtmlPurifier->beforeMarshal($event, $data, $options); |
113 |
| - $this->assertEquals($data['field1'], $expected); |
114 |
| - $this->assertEquals($data['field2'], '<b>Don\'t change me!</b>'); |
115 |
| - } |
| 99 | + public function testBeforeMarshal() |
| 100 | + { |
| 101 | + $html = '<p style="font-weight: bold;"><script>alert("alert!");</script><span style="text-decoration: line-through;" _mce_style="text-decoration: line-through;">shsfhshs</span></p><p><strong>sdhsdhds</strong></p><p><em>shsdh</em><span style="text-decoration: underline;" _mce_style="text-decoration: underline;">dsh</span></p><ul><li>sdgsgssgd</li><li>sdgdsg</li><li>sdgsdgsg</li><li>sdgdg<br></li></ul>'; |
| 102 | + $expected = '<p><span style="text-decoration:line-through;">shsfhshs</span></p><p><strong>sdhsdhds</strong></p><p><em>shsdh</em><span style="text-decoration:underline;">dsh</span></p><ul><li>sdgsgssgd</li><li>sdgdsg</li><li>sdgsdgsg</li><li>sdgdg</li></ul>'; |
| 103 | + $event = new Event('Model.beforeMarshal'); |
| 104 | + $data = new \ArrayObject([ |
| 105 | + 'field1' => $html, |
| 106 | + 'field2' => '<b>Don\'t change me!</b>' |
| 107 | + ]); |
| 108 | + $options = new \ArrayObject(); |
| 109 | + $this->table->behaviors()->HtmlPurifier->beforeMarshal($event, $data, $options); |
| 110 | + $this->assertEquals($data['field1'], $expected); |
| 111 | + $this->assertEquals($data['field2'], '<b>Don\'t change me!</b>'); |
| 112 | + } |
116 | 113 | }
|
0 commit comments