@@ -14,63 +14,55 @@ require __DIR__ . '/../bootstrap.php';
1414
1515
1616test ('' , function () {
17- Html::$ xhtml = true ;
1817 $ 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 ());
2221 Assert::same ('' , $ el ->endTag ());
2322});
2423
2524
2625test ('' , function () {
27- Html::$ xhtml = true ;
2826 $ 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 ());
3129 Assert::same ('' , $ el ->endTag ());
3230});
3331
3432
3533test ('' , function () {
36- Html::$ xhtml = true ;
3734 $ 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 ));
4340
4441 unset($ el ->accesskey );
45- Assert::same ('<img / > ' , (string ) $ el );
42+ Assert::same ('<img> ' , (string ) $ el );
4643});
4744
4845
4946test ('' , function () {
50- Html::$ xhtml = true ;
5147 $ 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 ' ));
5854});
5955
6056
6157test ('' , function () {
6258 $ 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 ;
6859 Assert::same ('<img src="image.gif" alt=""> ' , (string ) $ el );
60+ Assert::same ('<img src="image.gif" alt=""> ' , $ el ->startTag ());
61+ Assert::same ('' , $ el ->endTag ());
6962});
7063
7164
7265test ('' , function () {
73- Html::$ xhtml = false ;
7466 $ el = Html::el ('img ' )->setSrc ('image.gif ' )->setAlt ('alt1 ' )->setAlt ('alt2 ' );
7567 Assert::same ('<img src="image.gif" alt="alt2"> ' , (string ) $ el );
7668 Assert::same ('image.gif ' , $ el ->getSrc ());
@@ -104,10 +96,6 @@ test('small & big numbers', function () {
10496
10597
10698test ('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 ;
11199 Assert::same ('<a one= \'" \' two=" \'" three="<>" four="&amp;"></a> ' , (string ) Html::el ('a ' )->one ('" ' )->two ("' " )->three ('<> ' )->four ('& ' ));
112100 Assert::same ('<a one="``xx "></a> ' , (string ) Html::el ('a ' )->one ('``xx ' )); // mXSS
113101});
0 commit comments