@@ -14,63 +14,55 @@ require __DIR__ . '/../bootstrap.php';
14
14
15
15
16
16
test ('' , function () {
17
- Html::$ xhtml = true ;
18
17
$ el = Html::el ('img ' )->src ('image.gif ' )->alt ('' );
19
- Assert::same ('<img src="image.gif" alt="" / > ' , (string ) $ el );
20
- Assert::same ('<img src="image.gif" alt="" / > ' , $ el ->toHtml ());
21
- Assert::same ('<img src="image.gif" alt="" / > ' , $ el ->startTag ());
18
+ Assert::same ('<img src="image.gif" alt=""> ' , (string ) $ el );
19
+ Assert::same ('<img src="image.gif" alt=""> ' , $ el ->toHtml ());
20
+ Assert::same ('<img src="image.gif" alt=""> ' , $ el ->startTag ());
22
21
Assert::same ('' , $ el ->endTag ());
23
22
});
24
23
25
24
26
25
test ('' , function () {
27
- Html::$ xhtml = true ;
28
26
$ el = Html::el ('img ' )->setAttribute ('src ' , 'image.gif ' )->setAttribute ('alt ' , '' );
29
- Assert::same ('<img src="image.gif" alt="" / > ' , (string ) $ el );
30
- Assert::same ('<img src="image.gif" alt="" / > ' , $ el ->startTag ());
27
+ Assert::same ('<img src="image.gif" alt=""> ' , (string ) $ el );
28
+ Assert::same ('<img src="image.gif" alt=""> ' , $ el ->startTag ());
31
29
Assert::same ('' , $ el ->endTag ());
32
30
});
33
31
34
32
35
33
test ('' , function () {
36
- Html::$ xhtml = true ;
37
34
$ el = Html::el ('img ' )->accesskey (0 , true )->alt ('alt ' , false );
38
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el );
39
- Assert::same ('<img accesskey="0 1" / > ' , (string ) $ el ->accesskey (1 , true ));
40
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el ->accesskey (1 , false ));
41
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el ->accesskey (0 , true ));
42
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el ->accesskey (0 ));
35
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el );
36
+ Assert::same ('<img accesskey="0 1"> ' , (string ) $ el ->accesskey (1 , true ));
37
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el ->accesskey (1 , false ));
38
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el ->accesskey (0 , true ));
39
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el ->accesskey (0 ));
43
40
44
41
unset($ el ->accesskey );
45
- Assert::same ('<img / > ' , (string ) $ el );
42
+ Assert::same ('<img> ' , (string ) $ el );
46
43
});
47
44
48
45
49
46
test ('' , function () {
50
- Html::$ xhtml = true ;
51
47
$ el = Html::el ('img ' )->appendAttribute ('accesskey ' , 0 )->setAttribute ('alt ' , false );
52
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el );
53
- Assert::same ('<img accesskey="0 1" / > ' , (string ) $ el ->appendAttribute ('accesskey ' , 1 ));
54
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el ->appendAttribute ('accesskey ' , 1 , false ));
55
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el ->appendAttribute ('accesskey ' , 0 ));
56
- Assert::same ('<img accesskey="0" / > ' , (string ) $ el ->setAttribute ('accesskey ' , 0 ));
57
- Assert::same ('<img / > ' , (string ) $ el ->removeAttribute ('accesskey ' ));
48
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el );
49
+ Assert::same ('<img accesskey="0 1"> ' , (string ) $ el ->appendAttribute ('accesskey ' , 1 ));
50
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el ->appendAttribute ('accesskey ' , 1 , false ));
51
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el ->appendAttribute ('accesskey ' , 0 ));
52
+ Assert::same ('<img accesskey="0"> ' , (string ) $ el ->setAttribute ('accesskey ' , 0 ));
53
+ Assert::same ('<img> ' , (string ) $ el ->removeAttribute ('accesskey ' ));
58
54
});
59
55
60
56
61
57
test ('' , function () {
62
58
$ el = Html::el ('img ' )->src ('image.gif ' )->alt ('' )->setText ('any content ' );
63
- Assert::same ('<img src="image.gif" alt="" /> ' , (string ) $ el );
64
- Assert::same ('<img src="image.gif" alt="" /> ' , $ el ->startTag ());
65
- Assert::same ('' , $ el ->endTag ());
66
-
67
- Html::$ xhtml = false ;
68
59
Assert::same ('<img src="image.gif" alt=""> ' , (string ) $ el );
60
+ Assert::same ('<img src="image.gif" alt=""> ' , $ el ->startTag ());
61
+ Assert::same ('' , $ el ->endTag ());
69
62
});
70
63
71
64
72
65
test ('' , function () {
73
- Html::$ xhtml = false ;
74
66
$ el = Html::el ('img ' )->setSrc ('image.gif ' )->setAlt ('alt1 ' )->setAlt ('alt2 ' );
75
67
Assert::same ('<img src="image.gif" alt="alt2"> ' , (string ) $ el );
76
68
Assert::same ('image.gif ' , $ el ->getSrc ());
@@ -104,10 +96,6 @@ test('small & big numbers', function () {
104
96
105
97
106
98
test ('attributes escaping ' , function () {
107
- Html::$ xhtml = true ;
108
- Assert::same ('<a one= \'" \' two=" \'" three="<>" four="&amp;"></a> ' , (string ) Html::el ('a ' )->one ('" ' )->two ("' " )->three ('<> ' )->four ('& ' ));
109
-
110
- Html::$ xhtml = false ;
111
99
Assert::same ('<a one= \'" \' two=" \'" three="<>" four="&amp;"></a> ' , (string ) Html::el ('a ' )->one ('" ' )->two ("' " )->three ('<> ' )->four ('& ' ));
112
100
Assert::same ('<a one="``xx "></a> ' , (string ) Html::el ('a ' )->one ('``xx ' )); // mXSS
113
101
});
0 commit comments