Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit fd6cbfb

Browse files
author
Florian Krämer
committed
Fuck PSR2
1 parent d0c7982 commit fd6cbfb

File tree

3 files changed

+83
-83
lines changed

3 files changed

+83
-83
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Contributing to this Plugin
3838
Please feel free to contribute to the plugin with new issues, requests, unit tests and code fixes or new features. If you want to contribute some code, create a feature branch from develop, and send us your pull request. Unit tests for new features and issues detected are mandatory to keep quality high.
3939

4040
* Pull requests must be send to the ```develop``` branch.
41-
* Contributions must follow the [PSR2-**R** coding standard recommendation](https://github.com/php-fig-rectified/fig-rectified-standards).
41+
* Contributions must follow the [PSR2 coding standard recommendation](https://github.com/php-fig-rectified/fig-rectified-standards).
4242
* [Unit tests](http://book.cakephp.org/3.0/en/development/testing.html) are required.
4343

4444
License

tests/TestCase/Case/Model/Behavior/HtmlPurifierBehaviorTest.php

Lines changed: 56 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -20,97 +20,94 @@
2020
*/
2121
class VoidModel extends Table {
2222

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';
2929

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;
3636

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+
}
4950
}
5051

5152
/**
5253
* HtmlPurifierBehaviorTest
5354
*/
5455
class HtmlPurifierBehaviorTest extends TestCase {
5556

56-
/**
57-
* Holds the instance of the table
58-
*
59-
* @var mixed
60-
*/
61-
public $Article = null;
62-
6357
/**
6458
* Fixtures
6559
*
6660
* @var array
6761
*/
68-
public $fixtures = [];
62+
public $fixtures = [];
6963

7064
/**
7165
* startTest
7266
*
7367
* @return void
7468
*/
75-
public function setUp() {
76-
parent::setUp();
69+
public function setUp()
70+
{
71+
parent::setUp();
7772

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+
]);
8580

86-
$this->table = new VoidModel();
87-
}
81+
$this->table = new VoidModel();
82+
}
8883

8984
/**
9085
* endTest
9186
*
9287
* @return void
9388
*/
94-
public function tearDown() {
95-
unset($this->table);
96-
}
89+
public function tearDown()
90+
{
91+
unset($this->table);
92+
}
9793

9894
/**
9995
* configureUploadValidation
10096
*
10197
* @return void
10298
*/
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+
}
116113
}

tests/TestCase/Case/View/Helper/HtmlPurifierHelperTest.php

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,49 @@ class HtmlHelperTest extends TestCase {
1414
*
1515
* @var object
1616
*/
17-
public $Purifier = null;
17+
public $Purifier = null;
1818

1919
/**
2020
* setUp method
2121
*
2222
* @return void
2323
*/
24-
public function setUp() {
25-
parent::setUp();
26-
$this->View = new View();
27-
$this->Purifier = new HtmlPurifierHelper($this->View);
28-
29-
Purifier::config('default', [
30-
'HTML.AllowedElements' => 'a, em, blockquote, p, strong, pre, code, span,ul,ol,li,img',
31-
'HTML.AllowedAttributes' => 'a.href, a.title, img.src, img.alt, *.style',
32-
'CSS.AllowedProperties' => 'text-decoration',
33-
'HTML.TidyLevel' => 'heavy',
34-
'HTML.Doctype' => 'XHTML 1.0 Transitional'
35-
]);
36-
}
24+
public function setUp()
25+
{
26+
parent::setUp();
27+
$this->View = new View();
28+
$this->Purifier = new HtmlPurifierHelper($this->View);
29+
30+
Purifier::config('default', [
31+
'HTML.AllowedElements' => 'a, em, blockquote, p, strong, pre, code, span,ul,ol,li,img',
32+
'HTML.AllowedAttributes' => 'a.href, a.title, img.src, img.alt, *.style',
33+
'CSS.AllowedProperties' => 'text-decoration',
34+
'HTML.TidyLevel' => 'heavy',
35+
'HTML.Doctype' => 'XHTML 1.0 Transitional'
36+
]);
37+
}
3738

3839
/**
3940
* tearDown method
4041
*
4142
* @return void
4243
*/
43-
public function tearDown() {
44-
parent::tearDown();
45-
unset($this->Purifier, $this->View);
46-
}
44+
public function tearDown()
45+
{
46+
parent::tearDown();
47+
unset($this->Purifier, $this->View);
48+
}
4749

4850
/**
4951
* testCleanSomeTinyMceOutput
5052
*
5153
* @return void
5254
*/
53-
public function testCleanSomeTinyMceOutput() {
54-
$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>';
55-
$html = $this->Purifier->clean($html, 'default');
56-
$this->assertEquals($html, '<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>');
57-
}
55+
public function testCleanSomeTinyMceOutput()
56+
{
57+
$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>';
58+
$html = $this->Purifier->clean($html, 'default');
59+
$this->assertEquals($html, '<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>');
60+
}
5861

5962
}

0 commit comments

Comments
 (0)