@@ -85,25 +85,43 @@ public function testString(): void
8585 self ::assertSame ('tom ' , Filters::stripped ('tom ' ));
8686 self ::assertSame ('abc& ' , Filters::string ('abc& ' ));
8787 self ::assertSame (['abc& ' , '1 ' ], Filters::string (['abc& ' , 1 ]));
88+ }
8889
90+ public function testStringFilter (): void
91+ {
8992 // quotes
90- self :: assertSame ("O\'Reilly? " , Filters::quotes ("O'Reilly? " ));
93+ $ this -> assertSame ("O\'Reilly? " , Filters::quotes ("O'Reilly? " ));
9194
9295 // email
93- self :: assertSame ('' , Filters::email ([]));
96+ $ this -> assertSame ('' , Filters::email ([]));
9497
9598 // 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 ' ));
98101
99102 // 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 ' ));
101111 }
102112
103113 public function testNl2br (): void
104114 {
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 ));
107125 }
108126
109127 public function testClearXXX (): void
@@ -218,11 +236,20 @@ public function testEncodeOrClearTag(): void
218236 $ this ->assertSame ('abc.com%3Fa%3D7%2B9%26b%3D%E4%BD%A0 ' ,
219237 Filters::encoded ('abc.com?a=7+9&b=你 ' , FILTER_FLAG_ENCODE_HIGH ));
220238
239+ // url
221240 $ this ->assertSame ('' , Filters::url ('' ));
222241 $ this ->assertSame ('abc.com?a=7+9 ' , Filters::url ('abc.com?a=7+9 ' ));
223242 $ this ->assertSame ('abc.com?a=7+9&b= ' , Filters::url ('abc.com?a=7+9&b=你 ' ));
224243
244+ // email
225245 $ this ->assertSame ('' , Filters::email ('' ));
226246 $ this ->assertSame ('abc@email.com ' , Filters::email ('abc@email.com ' ));
227247 }
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+ }
228255}
0 commit comments