@@ -85,25 +85,43 @@ public function testString(): void
85
85
self ::assertSame ('tom ' , Filters::stripped ('tom ' ));
86
86
self ::assertSame ('abc& ' , Filters::string ('abc& ' ));
87
87
self ::assertSame (['abc& ' , '1 ' ], Filters::string (['abc& ' , 1 ]));
88
+ }
88
89
90
+ public function testStringFilter (): void
91
+ {
89
92
// quotes
90
- self :: assertSame ("O\'Reilly? " , Filters::quotes ("O'Reilly? " ));
93
+ $ this -> assertSame ("O\'Reilly? " , Filters::quotes ("O'Reilly? " ));
91
94
92
95
// email
93
- self :: assertSame ('' , Filters::email ([]));
96
+ $ this -> assertSame ('' , Filters::email ([]));
94
97
95
98
// url
96
- self :: assertSame ('' , Filters::url ([]));
97
- self :: assertSame ('abc/hi ' , Filters::url ('abc/hi ' ));
99
+ $ this -> assertSame ('' , Filters::url ([]));
100
+ $ this -> assertSame ('abc/hi ' , Filters::url ('abc/hi ' ));
98
101
99
102
// unsafeRaw
100
- self ::assertSame ('abc/hi ' , Filters::unsafeRaw ('abc/hi ' ));
103
+ $ this ->assertSame ('abc/hi ' , Filters::unsafeRaw ('abc/hi ' ));
104
+
105
+ // specialChars
106
+ $ this ->assertSame ('<a>link</a> hello, a & b ' , Filters::escape ('<a>link</a> hello, a & b ' ));
107
+ $ this ->assertSame ('abc ' , Filters::specialChars ('abc ' ));
108
+
109
+ // fullSpecialChars
110
+ $ this ->assertSame ('hello, a & b ' , Filters::fullSpecialChars ('hello, a & b ' ));
101
111
}
102
112
103
113
public function testNl2br (): void
104
114
{
105
- self ::assertSame ('a<br/>b ' , Filters::nl2br ("a \nb " ));
106
- self ::assertSame ('a<br/>b ' , Filters::nl2br ("a \r\nb " ));
115
+ $ this ->assertSame ('a<br/>b ' , Filters::nl2br ("a \nb " ));
116
+ $ this ->assertSame ('a<br/>b ' , Filters::nl2br ("a \r\nb " ));
117
+ }
118
+
119
+ public function testStringCut (): void
120
+ {
121
+ $ this ->assertSame ('cDE ' , Filters::stringCute ('abcDEFgh ' , 2 , 3 ));
122
+ $ this ->assertSame ('abcDEFgh ' , Filters::cut ('abcDEFgh ' ));
123
+ $ this ->assertSame ('cDEFgh ' , Filters::cut ('abcDEFgh ' , 2 ));
124
+ $ this ->assertSame ('abcDEFgh ' , Filters::cut ('abcDEFgh ' , 0 , 12 ));
107
125
}
108
126
109
127
public function testClearXXX (): void
@@ -218,11 +236,20 @@ public function testEncodeOrClearTag(): void
218
236
$ this ->assertSame ('abc.com%3Fa%3D7%2B9%26b%3D%E4%BD%A0 ' ,
219
237
Filters::encoded ('abc.com?a=7+9&b=你 ' , FILTER_FLAG_ENCODE_HIGH ));
220
238
239
+ // url
221
240
$ this ->assertSame ('' , Filters::url ('' ));
222
241
$ this ->assertSame ('abc.com?a=7+9 ' , Filters::url ('abc.com?a=7+9 ' ));
223
242
$ this ->assertSame ('abc.com?a=7+9&b= ' , Filters::url ('abc.com?a=7+9&b=你 ' ));
224
243
244
+ // email
225
245
$ this ->assertSame ('' , Filters::email ('' ));
226
246
$ this ->assertSame ('abc@email.com ' , Filters::email ('abc@email.com ' ));
227
247
}
248
+
249
+ public function testCallback (): void
250
+ {
251
+ $ this ->assertSame ('abc ' , Filters::callback ('ABC ' , 'strtolower ' ));
252
+ $ this ->assertSame ('abc ' , Filters::callback ('ABC ' , [Filters::class, 'lower ' ]));
253
+ $ this ->assertSame ('abc ' , Filters::callback ('ABC ' , Filters::class . ':: ' . 'lower ' ));
254
+ }
228
255
}
0 commit comments