From: Raghubansh Kumar Date: Tue, 9 Oct 2007 12:42:47 +0000 (+0000) Subject: New testcases for strip_tags() function X-Git-Tag: RELEASE_2_0_0a1~1622 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=adda3af3cba1ea4805ca33ed8dae267afa4bfdb4;p=php New testcases for strip_tags() function --- diff --git a/ext/standard/tests/strings/strip_tags_basic1.phpt b/ext/standard/tests/strings/strip_tags_basic1.phpt new file mode 100644 index 0000000000..e08bf4bc1e --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_basic1.phpt @@ -0,0 +1,106 @@ +--TEST-- +Test strip_tags() function : basic functionality - with default arguments +--INI-- +set short_open_tag = on +--FILE-- +hello", + 'hello', + "", + '', + "", + '', + "<% echo hello %>", + '<% echo hello %>', + "", + '', + "hello

world

", + 'hello

world

', + "", + '' +); + + +// Calling strip_tags() with default arguments +// loop through the $string_array to test strip_tags on various inputs +$iteration = 1; +foreach($string_array as $string) +{ + echo "-- Iteration $iteration --\n"; + var_dump( strip_tags($string) ); + $iteration++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : basic functionality *** +-- Iteration 1 -- +string(5) "hello" +-- Iteration 2 -- +string(5) "hello" +-- Iteration 3 -- +string(0) "" +-- Iteration 4 -- +string(0) "" +-- Iteration 5 -- +string(0) "" +-- Iteration 6 -- +string(0) "" +-- Iteration 7 -- +string(0) "" +-- Iteration 8 -- +string(0) "" +-- Iteration 9 -- +string(12) " echo hello " +-- Iteration 10 -- +string(12) " echo hello " +-- Iteration 11 -- +string(10) "helloworld" +-- Iteration 12 -- +string(10) "helloworld" +-- Iteration 13 -- +string(0) "" +-- Iteration 14 -- +string(0) "" +Done +--UEXPECTF-- +*** Testing strip_tags() : basic functionality *** +-- Iteration 1 -- +unicode(5) "hello" +-- Iteration 2 -- +unicode(5) "hello" +-- Iteration 3 -- +unicode(0) "" +-- Iteration 4 -- +unicode(0) "" +-- Iteration 5 -- +unicode(0) "" +-- Iteration 6 -- +unicode(0) "" +-- Iteration 7 -- +unicode(0) "" +-- Iteration 8 -- +unicode(0) "" +-- Iteration 9 -- +unicode(12) " echo hello " +-- Iteration 10 -- +unicode(12) " echo hello " +-- Iteration 11 -- +unicode(10) "helloworld" +-- Iteration 12 -- +unicode(10) "helloworld" +-- Iteration 13 -- +unicode(0) "" +-- Iteration 14 -- +unicode(0) "" +Done diff --git a/ext/standard/tests/strings/strip_tags_basic2.phpt b/ext/standard/tests/strings/strip_tags_basic2.phpt new file mode 100644 index 0000000000..2d3e012217 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_basic2.phpt @@ -0,0 +1,82 @@ +--TEST-- +Test strip_tags() function : basic functionality - with all arguments +--INI-- +set short_open_tag = on +--FILE-- +

hello

worldOther text"; + +$allowed_tags_array=array( + "", + '', + "

", + '

', + "", + '', + "

+--EXPECTF-- +*** Testing strip_tags() : basic functionality *** +-- Iteration 1 -- +string(33) "helloworldOther text" +-- Iteration 2 -- +string(33) "helloworldOther text" +-- Iteration 3 -- +string(27) "

hello

worldOther text" +-- Iteration 4 -- +string(27) "

hello

worldOther text" +-- Iteration 5 -- +string(44) "helloworld
Other text" +-- Iteration 6 -- +string(44) "helloworldOther text" +-- Iteration 7 -- +string(20) "helloworldOther text" +-- Iteration 8 -- +string(20) "helloworldOther text" +-- Iteration 9 -- +string(64) "

hello

worldOther text" +Done +--UEXPECTF-- +*** Testing strip_tags() : basic functionality *** +-- Iteration 1 -- +unicode(33) "helloworldOther text" +-- Iteration 2 -- +unicode(33) "helloworldOther text" +-- Iteration 3 -- +unicode(27) "

hello

worldOther text" +-- Iteration 4 -- +unicode(27) "

hello

worldOther text" +-- Iteration 5 -- +unicode(44) "helloworldOther text" +-- Iteration 6 -- +unicode(44) "helloworldOther text" +-- Iteration 7 -- +unicode(20) "helloworldOther text" +-- Iteration 8 -- +unicode(20) "helloworldOther text" +-- Iteration 9 -- +unicode(64) "

hello

worldOther text" +Done diff --git a/ext/standard/tests/strings/strip_tags_error.phpt b/ext/standard/tests/strings/strip_tags_error.phpt new file mode 100644 index 0000000000..0fb2674d65 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_error.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test strip_tags() function : error conditions +--INI-- +set short_open_tag = on +--FILE-- +hello"; +$allowable_tags = ""; +$extra_arg = 10; +var_dump( strip_tags($str, $allowable_tags, $extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : error conditions *** + +-- Testing strip_tags() function with Zero arguments -- + +Warning: strip_tags() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing strip_tags() function with more than expected no. of arguments -- + +Warning: strip_tags() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing strip_tags() : error conditions *** + +-- Testing strip_tags() function with Zero arguments -- + +Warning: strip_tags() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing strip_tags() function with more than expected no. of arguments -- + +Warning: strip_tags() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/strings/strip_tags_variation1.phpt b/ext/standard/tests/strings/strip_tags_variation1.phpt new file mode 100644 index 0000000000..76334a5737 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation1.phpt @@ -0,0 +1,226 @@ +--TEST-- +Test strip_tags() function : usage variations - unexpected values for 'str' argument +--INI-- +set short_open_tag = on +--FILE-- + 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new classA(), + + // undefined data + @$undefined_var, + + // unset data + @$unset_var, + + // resource variable + $fp + +); + +// loop through each element of the array for allowable_tags +$iterator = 1; +foreach($values as $value) { + echo "-- Iteration $iterator --\n"; + var_dump( strip_tags($value) ); + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(1) "0" +-- Iteration 2 -- +string(1) "1" +-- Iteration 3 -- +string(5) "12345" +-- Iteration 4 -- +string(5) "-2345" +-- Iteration 5 -- +string(4) "10.5" +-- Iteration 6 -- +string(5) "-10.5" +-- Iteration 7 -- +string(12) "105000000000" +-- Iteration 8 -- +string(7) "1.06E-9" +-- Iteration 9 -- +string(3) "0.5" +-- Iteration 10 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +string(0) "" +-- Iteration 16 -- +string(0) "" +-- Iteration 17 -- +string(1) "1" +-- Iteration 18 -- +string(0) "" +-- Iteration 19 -- +string(1) "1" +-- Iteration 20 -- +string(0) "" +-- Iteration 21 -- +string(0) "" +-- Iteration 22 -- +string(0) "" +-- Iteration 23 -- +string(14) "Class A object" +-- Iteration 24 -- +string(0) "" +-- Iteration 25 -- +string(0) "" +-- Iteration 26 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(1) "0" +-- Iteration 2 -- +unicode(1) "1" +-- Iteration 3 -- +unicode(5) "12345" +-- Iteration 4 -- +unicode(5) "-2345" +-- Iteration 5 -- +unicode(4) "10.5" +-- Iteration 6 -- +unicode(5) "-10.5" +-- Iteration 7 -- +unicode(12) "105000000000" +-- Iteration 8 -- +unicode(7) "1.06E-9" +-- Iteration 9 -- +unicode(3) "0.5" +-- Iteration 10 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +unicode(0) "" +-- Iteration 16 -- +unicode(0) "" +-- Iteration 17 -- +unicode(1) "1" +-- Iteration 18 -- +unicode(0) "" +-- Iteration 19 -- +unicode(1) "1" +-- Iteration 20 -- +unicode(0) "" +-- Iteration 21 -- +unicode(0) "" +-- Iteration 22 -- +unicode(0) "" +-- Iteration 23 -- +unicode(14) "Class A object" +-- Iteration 24 -- +unicode(0) "" +-- Iteration 25 -- +unicode(0) "" +-- Iteration 26 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/strings/strip_tags_variation10.phpt b/ext/standard/tests/strings/strip_tags_variation10.phpt new file mode 100644 index 0000000000..aa6ff3c8c6 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation10.phpt @@ -0,0 +1,70 @@ +--TEST-- +Test strip_tags() function : usage variations - single quoted strings +--INI-- +set short_open_tag = on +--FILE-- + \$ -> This represents the dollar sign', + '\t\r\v The quick brown fo\fx jumped over the lazy dog

', + 'This is a hyper text tag', + 'hello world\\t?>', + '

This is a paragraph

', + 'This is \ta text in bold letters\r\s\malong with slashes\n' +); + +$quotes = "

+--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(51) " \$ -> This represents the dollar sign" +-- Iteration 2 -- +string(63) "\t\r\v The quick brown fo\fx jumped over the lazy dog

" +-- Iteration 3 -- +string(31) "
This is a hyper text tag" +-- Iteration 4 -- +string(0) "" +-- Iteration 5 -- +string(26) "

This is a paragraph

" +-- Iteration 6 -- +string(65) "This is \ta text in bold letters\r\s\malong with slashes\n" +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(51) " \$ -> This represents the dollar sign" +-- Iteration 2 -- +unicode(63) "\t\r\v The quick brown fo\fx jumped over the lazy dog

" +-- Iteration 3 -- +unicode(31) "This is a hyper text tag" +-- Iteration 4 -- +unicode(0) "" +-- Iteration 5 -- +unicode(26) "

This is a paragraph

" +-- Iteration 6 -- +unicode(65) "This is \ta text in bold letters\r\s\malong with slashes\n" +Done diff --git a/ext/standard/tests/strings/strip_tags_variation2.phpt b/ext/standard/tests/strings/strip_tags_variation2.phpt new file mode 100644 index 0000000000..8205769224 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation2.phpt @@ -0,0 +1,228 @@ +--TEST-- +Test strip_tags() function : usage variations - unexpected values for 'allowable_tags' +--INI-- +set short_open_tag = on +--FILE-- +hello

world

"; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//get a resource variable +$fp = fopen(__FILE__, "r"); + +//get a class +class classA{ + public function __toString(){ + return "Class A Object"; + } +} + +//array of values to iterate over +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.5e10, + 10.6E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new classA(), + + // undefined data + @$undefined_var, + + // unset data + @$unset_var, + + // resource variable + $fp +); + +// loop through each element of the array for allowable_tags +$iterator = 1; +foreach($values as $value) { + echo "-- Iteration $iterator --\n"; + var_dump( strip_tags($string, $value) ); + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(10) "helloworld" +-- Iteration 2 -- +string(10) "helloworld" +-- Iteration 3 -- +string(10) "helloworld" +-- Iteration 4 -- +string(10) "helloworld" +-- Iteration 5 -- +string(10) "helloworld" +-- Iteration 6 -- +string(10) "helloworld" +-- Iteration 7 -- +string(10) "helloworld" +-- Iteration 8 -- +string(10) "helloworld" +-- Iteration 9 -- +string(10) "helloworld" +-- Iteration 10 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +string(10) "helloworld" +-- Iteration 16 -- +string(10) "helloworld" +-- Iteration 17 -- +string(10) "helloworld" +-- Iteration 18 -- +string(10) "helloworld" +-- Iteration 19 -- +string(10) "helloworld" +-- Iteration 20 -- +string(10) "helloworld" +-- Iteration 21 -- +string(10) "helloworld" +-- Iteration 22 -- +string(10) "helloworld" +-- Iteration 23 -- +string(10) "helloworld" +-- Iteration 24 -- +string(10) "helloworld" +-- Iteration 25 -- +string(10) "helloworld" +-- Iteration 26 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(10) "helloworld" +-- Iteration 2 -- +unicode(10) "helloworld" +-- Iteration 3 -- +unicode(10) "helloworld" +-- Iteration 4 -- +unicode(10) "helloworld" +-- Iteration 5 -- +unicode(10) "helloworld" +-- Iteration 6 -- +unicode(10) "helloworld" +-- Iteration 7 -- +unicode(10) "helloworld" +-- Iteration 8 -- +unicode(10) "helloworld" +-- Iteration 9 -- +unicode(10) "helloworld" +-- Iteration 10 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +unicode(10) "helloworld" +-- Iteration 16 -- +unicode(10) "helloworld" +-- Iteration 17 -- +unicode(10) "helloworld" +-- Iteration 18 -- +unicode(10) "helloworld" +-- Iteration 19 -- +unicode(10) "helloworld" +-- Iteration 20 -- +unicode(10) "helloworld" +-- Iteration 21 -- +unicode(10) "helloworld" +-- Iteration 22 -- +unicode(10) "helloworld" +-- Iteration 23 -- +unicode(10) "helloworld" +-- Iteration 24 -- +unicode(10) "helloworld" +-- Iteration 25 -- +unicode(10) "helloworld" +-- Iteration 26 -- + +Warning: strip_tags() expects parameter 2 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/strings/strip_tags_variation3.phpt b/ext/standard/tests/strings/strip_tags_variation3.phpt new file mode 100644 index 0000000000..1e971b82bf --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation3.phpt @@ -0,0 +1,226 @@ +--TEST-- +Test strip_tags() function : usage variations - unexpected values for both 'str' and 'allowable_tags' +--INI-- +set short_open_tag = on +--FILE-- + 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new classA(), + + // undefined data + @$undefined_var, + + // unset data + @$unset_var, + + // resource variable + $fp + +); + +// loop through each element of the array for allowable_tags +$iterator = 1; +foreach($values as $value) { + echo "-- Iteration $iterator --\n"; + var_dump( strip_tags($value, $value) ); + $iterator++; +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(1) "0" +-- Iteration 2 -- +string(1) "1" +-- Iteration 3 -- +string(5) "12345" +-- Iteration 4 -- +string(5) "-2345" +-- Iteration 5 -- +string(4) "10.5" +-- Iteration 6 -- +string(5) "-10.5" +-- Iteration 7 -- +string(12) "105000000000" +-- Iteration 8 -- +string(7) "1.06E-9" +-- Iteration 9 -- +string(3) "0.5" +-- Iteration 10 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +string(0) "" +-- Iteration 16 -- +string(0) "" +-- Iteration 17 -- +string(1) "1" +-- Iteration 18 -- +string(0) "" +-- Iteration 19 -- +string(1) "1" +-- Iteration 20 -- +string(0) "" +-- Iteration 21 -- +string(0) "" +-- Iteration 22 -- +string(0) "" +-- Iteration 23 -- +string(14) "Class A object" +-- Iteration 24 -- +string(0) "" +-- Iteration 25 -- +string(0) "" +-- Iteration 26 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(1) "0" +-- Iteration 2 -- +unicode(1) "1" +-- Iteration 3 -- +unicode(5) "12345" +-- Iteration 4 -- +unicode(5) "-2345" +-- Iteration 5 -- +unicode(4) "10.5" +-- Iteration 6 -- +unicode(5) "-10.5" +-- Iteration 7 -- +unicode(12) "105000000000" +-- Iteration 8 -- +unicode(7) "1.06E-9" +-- Iteration 9 -- +unicode(3) "0.5" +-- Iteration 10 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +unicode(0) "" +-- Iteration 16 -- +unicode(0) "" +-- Iteration 17 -- +unicode(1) "1" +-- Iteration 18 -- +unicode(0) "" +-- Iteration 19 -- +unicode(1) "1" +-- Iteration 20 -- +unicode(0) "" +-- Iteration 21 -- +unicode(0) "" +-- Iteration 22 -- +unicode(0) "" +-- Iteration 23 -- +unicode(14) "Class A object" +-- Iteration 24 -- +unicode(0) "" +-- Iteration 25 -- +unicode(0) "" +-- Iteration 26 -- + +Warning: strip_tags() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/strings/strip_tags_variation4.phpt b/ext/standard/tests/strings/strip_tags_variation4.phpt new file mode 100644 index 0000000000..9ab3ccc539 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation4.phpt @@ -0,0 +1,101 @@ +--TEST-- +Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags' +--INI-- +set short_open_tag = on +--FILE-- +hello \t\tworld... strip_tags_test", + 'hello \t\tworld... strip_tags_test', + "<%?php hello\t world?%>", + '<%?php hello\t world?%>', + "<>hello<>", + '<>hello<>', + "HtMl text", + 'HtMl text', + "I am not a valid html text", + 'I am not a valid html text', + "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&", + 'I am a quoted (\") string with special chars like \$,\!,\@,\%,\&', +); + +//valid html and php tags +$quotes = "

"; + +//loop through the various elements of strings array to test strip_tags() functionality +$iterator = 1; +foreach($strings as $string_value) +{ + echo "-- Iteration $iterator --\n"; + var_dump( strip_tags($string_value, $quotes) ); + $iterator++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(32) "hello world... strip_tags_test" +-- Iteration 2 -- +string(34) "hello \t\tworld... strip_tags_test" +-- Iteration 3 -- +string(0) "" +-- Iteration 4 -- +string(0) "" +-- Iteration 5 -- +string(18) "hello" +-- Iteration 6 -- +string(18) "hello" +-- Iteration 7 -- +string(9) "HtMl text" +-- Iteration 8 -- +string(9) "HtMl text" +-- Iteration 9 -- +string(26) "I am not a valid html text" +-- Iteration 10 -- +string(26) "I am not a valid html text" +-- Iteration 11 -- +string(62) "I am a quoted (") string with special chars like $,\!,\@,\%,\&" +-- Iteration 12 -- +string(64) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&" +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(32) "hello world... strip_tags_test" +-- Iteration 2 -- +unicode(34) "hello \t\tworld... strip_tags_test" +-- Iteration 3 -- +unicode(0) "" +-- Iteration 4 -- +unicode(0) "" +-- Iteration 5 -- +unicode(5) "hello" +-- Iteration 6 -- +unicode(5) "hello" +-- Iteration 7 -- +unicode(9) "HtMl text" +-- Iteration 8 -- +unicode(9) "HtMl text" +-- Iteration 9 -- +unicode(26) "I am not a valid html text" +-- Iteration 10 -- +unicode(26) "I am not a valid html text" +-- Iteration 11 -- +unicode(62) "I am a quoted (") string with special chars like $,\!,\@,\%,\&" +-- Iteration 12 -- +unicode(64) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&" +Done diff --git a/ext/standard/tests/strings/strip_tags_variation5.phpt b/ext/standard/tests/strings/strip_tags_variation5.phpt new file mode 100644 index 0000000000..5018f84fee --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation5.phpt @@ -0,0 +1,131 @@ +--TEST-- +Test strip_tags() function : usage variations - heredoc strings +--INI-- +set short_open_tag = on +--FILE-- +hello world +

13 < 25

+ +This is a double quoted string +EOT; + +// here doc with diferent whitespaces +$diff_whitespaces = <<hello\r world\t +1111\t\t != 2222\v\v + +EOT; + +// here doc with numeric values +$numeric_string = <<11 < 12. 123 >22 +

string

1111\t 0000\t = 0000\n +EOT; + +// heredoc with quote chars & slash +$quote_char_string = <<This's a string with quotes: +"strings in double quote"; +'strings in single quote'; +this\line is single quoted /with\slashes +EOT; + +$res_heredoc_strings = array( + //heredoc strings + $null_string, + $blank_line, + $multiline_string, + $diff_whitespaces, + $numeric_string, + $quote_char_string +); + +// initialize the second argument +$quotes = "
+--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(0) "" +-- Iteration 2 -- +string(0) "" +-- Iteration 3 -- +string(67) "hello world +13 < 25 + +This is a double quoted string" +-- Iteration 4 -- +string(44) "hello + world +1111 != 2222 +" +-- Iteration 5 -- +string(56) "11 < 12. 123 >22 +string 1111 0000 = 0000 +" +-- Iteration 6 -- +string(150) "This's a string with quotes: +"strings in double quote"; +'strings in single quote'; +this\line is single quoted /with\slashes " +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(0) "" +-- Iteration 2 -- +unicode(0) "" +-- Iteration 3 -- +unicode(67) "hello world +13 < 25 + +This is a double quoted string" +-- Iteration 4 -- +unicode(44) "hello + world +1111 != 2222 +" +-- Iteration 5 -- +unicode(56) "11 < 12. 123 >22 +string 1111 0000 = 0000 +" +-- Iteration 6 -- +unicode(150) "This's a string with quotes: +"strings in double quote"; +'strings in single quote'; +this\line is single quoted /with\slashes " +Done diff --git a/ext/standard/tests/strings/strip_tags_variation6.phpt b/ext/standard/tests/strings/strip_tags_variation6.phpt new file mode 100644 index 0000000000..da50518c48 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation6.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test strip_tags() function : usage variations - binary safe checking +--INI-- +set short_open_tag = on +--FILE-- + I am html string ".chr(0)."", + " I am html string\0 ", + b"I am html string", + "I am html string".decbin(65)."" +); + +//loop through the strings array to check if strip_tags() is binary safe +$iterator = 1; +foreach($strings as $value) +{ + echo "-- Iteration $iterator --\n"; + var_dump( strip_tags($value) ); + $iterator++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(18) " I am html string " +-- Iteration 2 -- +string(18) " I am html string " +-- Iteration 3 -- +string(16) "I am html string" +-- Iteration 4 -- +string(23) "I am html string1000001" +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(18) " I am html string " +-- Iteration 2 -- +unicode(18) " I am html string " +-- Iteration 3 -- +string(16) "I am html string" +-- Iteration 4 -- +unicode(23) "I am html string1000001" +Done diff --git a/ext/standard/tests/strings/strip_tags_variation7.phpt b/ext/standard/tests/strings/strip_tags_variation7.phpt new file mode 100644 index 0000000000..e75e942d6b --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation7.phpt @@ -0,0 +1,99 @@ +--TEST-- +Test strip_tags() function : usage variations - invalid values for 'str' and 'allowable_tags' +--INI-- +set short_open_tag = on +--FILE-- +hello \t\tworld... strip_tags_test", + 'hello \t\tworld... strip_tags_test', + "<%?php hello\t world?%>", + '<%?php hello\t world?%>', + "<>hello<>", + '<>hello<>', + "HtMl text", + 'HtMl text', + "I am not a valid html text", + 'I am not a valid html text', + "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&", + 'I am a quoted (\") string with special chars like \$,\!,\@,\%,\&', +); + +$quotes = "<%?<>"; + +//loop through the various elements of strings array to test strip_tags() functionality +$iterator = 1; +foreach($strings as $string_value) +{ + echo "-- Iteration $iterator --\n"; + var_dump( strip_tags($string_value, $quotes) ); + $iterator++; +} + +echo "Done"; +?> +--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(43) "hello world... strip_tags_test" +-- Iteration 2 -- +string(45) "hello \t\tworld... strip_tags_test" +-- Iteration 3 -- +string(0) "" +-- Iteration 4 -- +string(0) "" +-- Iteration 5 -- +string(18) "hello" +-- Iteration 6 -- +string(18) "hello" +-- Iteration 7 -- +string(9) "HtMl text" +-- Iteration 8 -- +string(9) "HtMl text" +-- Iteration 9 -- +string(37) "I am not a valid html text" +-- Iteration 10 -- +string(37) "I am not a valid html text" +-- Iteration 11 -- +string(73) "I am a quoted (") string with special chars like $,\!,\@,\%,\&" +-- Iteration 12 -- +string(75) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&" +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(43) "hello world... strip_tags_test" +-- Iteration 2 -- +unicode(45) "hello \t\tworld... strip_tags_test" +-- Iteration 3 -- +unicode(0) "" +-- Iteration 4 -- +unicode(0) "" +-- Iteration 5 -- +unicode(5) "hello" +-- Iteration 6 -- +unicode(5) "hello" +-- Iteration 7 -- +unicode(9) "HtMl text" +-- Iteration 8 -- +unicode(9) "HtMl text" +-- Iteration 9 -- +unicode(37) "I am not a valid html text" +-- Iteration 10 -- +unicode(37) "I am not a valid html text" +-- Iteration 11 -- +unicode(73) "I am a quoted (") string with special chars like $,\!,\@,\%,\&" +-- Iteration 12 -- +unicode(75) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&" +Done diff --git a/ext/standard/tests/strings/strip_tags_variation8.phpt b/ext/standard/tests/strings/strip_tags_variation8.phpt new file mode 100644 index 0000000000..86591ac0e9 --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation8.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test strip_tags() function : usage variations - valid value for 'str' and invalid values for 'allowable_tags' +--INI-- +set short_open_tag = on +--FILE-- +hello \tworld...

strip_tags_test\v\f

"; + +$quotes = array ( + "", + '', + "", + '', + "<%?php", + '<%?php', + "<>", + '<>' +); + +//loop through the various elements of strings array to test strip_tags() functionality +$iterator = 1; +foreach($quotes as $string_value) +{ + echo "-- Iteration $iterator --\n"; + var_dump( strip_tags($strings, $string_value) ); + $iterator++; +} + +echo "Done"; +--EXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +string(33) "hello world... strip_tags_test " +-- Iteration 2 -- +string(33) "hello world... strip_tags_test " +-- Iteration 3 -- +string(33) "hello world... strip_tags_test " +-- Iteration 4 -- +string(33) "hello world... strip_tags_test " +-- Iteration 5 -- +string(33) "hello world... strip_tags_test " +-- Iteration 6 -- +string(33) "hello world... strip_tags_test " +-- Iteration 7 -- +string(46) "hello world... strip_tags_test " +-- Iteration 8 -- +string(46) "hello world... strip_tags_test " +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(33) "hello world... strip_tags_test " +-- Iteration 2 -- +unicode(33) "hello world... strip_tags_test " +-- Iteration 3 -- +unicode(33) "hello world... strip_tags_test " +-- Iteration 4 -- +unicode(33) "hello world... strip_tags_test " +-- Iteration 5 -- +unicode(33) "hello world... strip_tags_test " +-- Iteration 6 -- +unicode(33) "hello world... strip_tags_test " +-- Iteration 7 -- +unicode(46) "hello world... strip_tags_test " +-- Iteration 8 -- +unicode(46) "hello world... strip_tags_test " +Done diff --git a/ext/standard/tests/strings/strip_tags_variation9.phpt b/ext/standard/tests/strings/strip_tags_variation9.phpt new file mode 100644 index 0000000000..d70ea893cf --- /dev/null +++ b/ext/standard/tests/strings/strip_tags_variation9.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test strip_tags() function : usage variations - double quoted strings +--INI-- +set short_open_tag = on +--FILE-- + \$ -> This represents the dollar sign", + "\t\r\v The quick brown fo\fx jumped over the lazy dog

", + "This is a hyper text tag", + "hello world\\t?>", + "

This is a paragraph

", + "This is \ta text in bold letters\r\s\malong with slashes\n" +); + +$quotes = "

$ -> This represents the dollar sign" +-- Iteration 2 -- +string(59) " + The quick brown fo x jumped over the lazy dog

" +-- Iteration 3 -- +string(31) "
This is a hyper text tag" +-- Iteration 4 -- +string(0) "" +-- Iteration 5 -- +string(26) "

This is a paragraph

" +-- Iteration 6 -- +string(62) "This is a text in bold letters +\s\malong with slashes +" +Done +--UEXPECTF-- +*** Testing strip_tags() : usage variations *** +-- Iteration 1 -- +unicode(50) " $ -> This represents the dollar sign" +-- Iteration 2 -- +unicode(59) " + The quick brown fo x jumped over the lazy dog

" +-- Iteration 3 -- +unicode(31) "This is a hyper text tag" +-- Iteration 4 -- +unicode(0) "" +-- Iteration 5 -- +unicode(26) "

This is a paragraph

" +-- Iteration 6 -- +unicode(62) "This is a text in bold letters +\s\malong with slashes +" +Done