kraghuba                Tue Oct  9 12:44:45 2007 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/standard/tests/strings strip_tags_basic1.phpt 
                                        strip_tags_variation6.phpt 
                                        strip_tags_basic2.phpt 
                                        strip_tags_variation7.phpt 
                                        strip_tags_variation8.phpt 
                                        strip_tags_variation9.phpt 
                                        strip_tags_error.phpt 
                                        strip_tags_variation1.phpt 
                                        strip_tags_variation2.phpt 
                                        strip_tags_variation3.phpt 
                                        strip_tags_variation4.phpt 
                                        strip_tags_variation10.phpt 
                                        strip_tags_variation5.phpt 
  Log:
  New testcases for strip_tags() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_basic1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_basic1.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_basic1.phpt
--TEST--
Test strip_tags() function : basic functionality - with default arguments
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string 
 * Source code: ext/standard/string.c
*/

echo "*** Testing strip_tags() : basic functionality ***\n";

// array of arguments 
$string_array = array (
  "<html>hello</html>",
  '<html>hello</html>',
  "<?php echo hello ?>",
  '<?php echo hello ?>',
  "<? echo hello ?>",
  '<? echo hello ?>',
  "<% echo hello %>",
  '<% echo hello %>',
  "<script language=\"PHP\"> echo hello </script>",
  '<script language=\"PHP\"> echo hello </script>',
  "<html><b>hello</b><p>world</p></html>",
  '<html><b>hello</b><p>world</p></html>',
  "<html><!-- COMMENT --></html>",
  '<html><!-- COMMENT --></html>'
);
  
                
// 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

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation6.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation6.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation6.phpt
--TEST--
Test strip_tags() function : usage variations - binary safe checking
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/

/*
 * testing whether strip_tags() is binary safe or not
*/

echo "*** Testing strip_tags() : usage variations ***\n";

//various string inputs
$strings = array (
  "<html> I am html string </html>".chr(0)."<?php I am php string ?>",
  "<html> I am html string\0 </html><?php I am php string ?>",
  b"<a>I am html string</a>",
  "<html>I am html string</html>".decbin(65)."<?php I am php string?>"
);

//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

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_basic2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_basic2.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_basic2.phpt
--TEST--
Test strip_tags() function : basic functionality - with all arguments
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/

echo "*** Testing strip_tags() : basic functionality ***\n";

// Calling strip_tags() with all possible arguments
$string = "<html><p>hello</p><b>world</b><a href=\"#fragment\">Other 
text</a></html><?php echo hello ?>";

$allowed_tags_array=array(
  "<html>",
  '<html>',
  "<p>",
  '<p>',
  "<a>",
  '<a>',
  "<?php",
  '<?php',
  "<html><p><a><?php"
);

// loop through the $string with various $allowed_tags_array to test strip_tags
// on various allowed tags
$iteration = 1;
foreach($allowed_tags_array as $tags)
{
  echo "-- Iteration $iteration --\n";
  var_dump( strip_tags($string, $tags) );
  $iteration++;
}

echo "Done";
?>
--EXPECTF--
*** Testing strip_tags() : basic functionality ***
-- Iteration 1 --
string(33) "<html>helloworldOther text</html>"
-- Iteration 2 --
string(33) "<html>helloworldOther text</html>"
-- Iteration 3 --
string(27) "<p>hello</p>worldOther text"
-- Iteration 4 --
string(27) "<p>hello</p>worldOther text"
-- Iteration 5 --
string(44) "helloworld<a href="#fragment">Other text</a>"
-- Iteration 6 --
string(44) "helloworld<a href="#fragment">Other text</a>"
-- Iteration 7 --
string(20) "helloworldOther text"
-- Iteration 8 --
string(20) "helloworldOther text"
-- Iteration 9 --
string(64) "<html><p>hello</p>world<a href="#fragment">Other text</a></html>"
Done
--UEXPECTF--
*** Testing strip_tags() : basic functionality ***
-- Iteration 1 --
unicode(33) "<html>helloworldOther text</html>"
-- Iteration 2 --
unicode(33) "<html>helloworldOther text</html>"
-- Iteration 3 --
unicode(27) "<p>hello</p>worldOther text"
-- Iteration 4 --
unicode(27) "<p>hello</p>worldOther text"
-- Iteration 5 --
unicode(44) "helloworld<a href="#fragment">Other text</a>"
-- Iteration 6 --
unicode(44) "helloworld<a href="#fragment">Other text</a>"
-- Iteration 7 --
unicode(20) "helloworldOther text"
-- Iteration 8 --
unicode(20) "helloworldOther text"
-- Iteration 9 --
unicode(64) "<html><p>hello</p>world<a href="#fragment">Other text</a></html>"
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation7.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation7.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation7.phpt
--TEST--
Test strip_tags() function : usage variations - invalid values for 'str' and 
'allowable_tags'
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving invalid values for $str and 
$allowable_tags argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

$strings = array (
  "<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>",
  '<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>',
  "<%?php hello\t world?%>",
  '<%?php hello\t world?%>',
  "<<htmL>>hello<</htmL>>",
  '<<htmL>>hello<</htmL>>',
  "<a.>HtMl text</.a>",
  '<a.>HtMl text</.a>',
  "<nnn>I am not a valid html text</nnn>",
  '<nnn>I am not a valid html text</nnn>',
  "<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>",
  '<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>',
);

$quotes = "<nnn><abc><%?<<html>>";

//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) "<abc>hello</abc>            world... strip_tags_test"
-- Iteration 2 --
string(45) "<abc>hello</abc> \t\tworld... strip_tags_test"
-- Iteration 3 --
string(0) ""
-- Iteration 4 --
string(0) ""
-- Iteration 5 --
string(18) "<htmL>hello</htmL>"
-- Iteration 6 --
string(18) "<htmL>hello</htmL>"
-- Iteration 7 --
string(9) "HtMl text"
-- Iteration 8 --
string(9) "HtMl text"
-- Iteration 9 --
string(37) "<nnn>I am not a valid html text</nnn>"
-- Iteration 10 --
string(37) "<nnn>I am not a valid html text</nnn>"
-- Iteration 11 --
string(73) "<nnn>I am a quoted (") string with special chars like 
$,\!,\@,\%,\&</nnn>"
-- Iteration 12 --
string(75) "<nnn>I am a quoted (\") string with special chars like 
\$,\!,\@,\%,\&</nnn>"
Done
--UEXPECTF--
*** Testing strip_tags() : usage variations ***
-- Iteration 1 --
unicode(43) "<abc>hello</abc>           world... strip_tags_test"
-- Iteration 2 --
unicode(45) "<abc>hello</abc> \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) "<nnn>I am not a valid html text</nnn>"
-- Iteration 10 --
unicode(37) "<nnn>I am not a valid html text</nnn>"
-- Iteration 11 --
unicode(73) "<nnn>I am a quoted (") string with special chars like 
$,\!,\@,\%,\&</nnn>"
-- Iteration 12 --
unicode(75) "<nnn>I am a quoted (\") string with special chars like 
\$,\!,\@,\%,\&</nnn>"
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation8.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation8.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation8.phpt
--TEST--
Test strip_tags() function : usage variations - valid value for 'str' and 
invalid values for 'allowable_tags'
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving valid value for $str and 
invalid values for $allowable_tags argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

$strings = "<html>hello</html> \tworld... <p>strip_tags_test\v\f</p><?php 
hello\t wo\rrld?>";

$quotes = array (
  "<nnn>",
  '<nnn>',
  "<abc>",
  '<abc>',
  "<%?php",
  '<%?php',
  "<<html>>",
  '<<html>>'
);

//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) "<html>hello</html>  world... strip_tags_test"
-- Iteration 8 --
string(46) "<html>hello</html>  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) "<html>hello</html>         world... strip_tags_test"
-- Iteration 8 --
unicode(46) "<html>hello</html>         world... strip_tags_test"
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation9.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation9.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation9.phpt
--TEST--
Test strip_tags() function : usage variations - double quoted strings
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving double quoted strings as 
values for $str argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

$double_quote_string = array (
  "<html> \$ -> This represents the dollar sign</html><?php echo hello ?>",
  "<html>\t\r\v The quick brown fo\fx jumped over the lazy dog</p>",
  "<a>This is a hyper text tag</a>",
  "<? <html>hello world\\t</html>?>",
  "<p>This is a paragraph</p>",
  "<b>This is \ta text in bold letters\r\s\malong with slashes\n</b>"
);

$quotes = "<html><a><p><b><?php";

//loop through the various elements of strings array to test strip_tags() 
functionality
$iterator = 1;
foreach($double_quote_string 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(50) "<html> $ -> This represents the dollar sign</html>"
-- Iteration 2 --
string(59) "<html>       The quick brown fox jumped over the lazy dog</p>"
-- Iteration 3 --
string(31) "<a>This is a hyper text tag</a>"
-- Iteration 4 --
string(0) ""
-- Iteration 5 --
string(26) "<p>This is a paragraph</p>"
-- Iteration 6 --
string(62) "<b>This is  a text in bold letters\s\malong with slashes
</b>"
Done
--UEXPECTF--
*** Testing strip_tags() : usage variations ***
-- Iteration 1 --
unicode(50) "<html> $ -> This represents the dollar sign</html>"
-- Iteration 2 --
unicode(59) "<html>      The quick brown fox jumped over the lazy dog</p>"
-- Iteration 3 --
unicode(31) "<a>This is a hyper text tag</a>"
-- Iteration 4 --
unicode(0) ""
-- Iteration 5 --
unicode(26) "<p>This is a paragraph</p>"
-- Iteration 6 --
unicode(62) "<b>This is         a text in bold letters\s\malong with slashes
</b>"
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_error.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_error.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_error.phpt
--TEST--
Test strip_tags() function : error conditions
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string 
 * Source code: ext/standard/string.c
*/


echo "*** Testing strip_tags() : error conditions ***\n";

// Zero arguments
echo "\n-- Testing strip_tags() function with Zero arguments --\n";
var_dump( strip_tags() );

//Test strip_tags with one more than the expected number of arguments
echo "\n-- Testing strip_tags() function with more than expected no. of 
arguments --\n";
$str = "<html>hello</html>";
$allowable_tags = "<html>";
$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

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation1.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation1.phpt
--TEST--
Test strip_tags() function : usage variations - unexpected values for 'str' 
argument
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string 
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving unexpected input values for 
$str argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

//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($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

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation2.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation2.phpt
--TEST--
Test strip_tags() function : usage variations - unexpected values for 
'allowable_tags'
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string 
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving unexpected values for 
$allowable_tags argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

// Initialise function argument
$string = "<html><a>hello</a></html><p>world</p><!-- COMMENT --><?php echo 
hello ?>";

//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

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation3.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation3.phpt
--TEST--
Test strip_tags() function : usage variations - unexpected values for both 
'str' and 'allowable_tags'
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string 
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving unexpected values for $str 
and $allowable_tags arguments
*/

echo "*** Testing strip_tags() : usage variations ***\n";

// get a resource
$fp=fopen(__FILE__, "r");

// get an unset variable
$unset_var = 10;
unset ($unset_var);

// 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($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

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation4.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation4.phpt
--TEST--
Test strip_tags() function : usage variations - invalid values for 'str' and 
valid 'allowable_tags'
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving invalid values for $str and 
valid values for $allowable_tags argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

// unexpected values for $string
$strings = array (
  "<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>",
  '<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>',
  "<%?php hello\t world?%>",
  '<%?php hello\t world?%>',
  "<<htmL>>hello<</htmL>>",
  '<<htmL>>hello<</htmL>>',
  "<a.>HtMl text</.a>",
  '<a.>HtMl text</.a>',
  "<nnn>I am not a valid html text</nnn>",
  '<nnn>I am not a valid html text</nnn>',
  "<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>",
  '<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>',
);

//valid html and php tags
$quotes = "<p><a><?php<html>";

//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) "<htmL>hello</htmL>"
-- Iteration 6 --
string(18) "<htmL>hello</htmL>"
-- 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

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation10.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation10.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation10.phpt
--TEST--
Test strip_tags() function : usage variations - single quoted strings
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/

/*
 * testing functionality of strip_tags() by giving single quoted strings as 
values for $str argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";


$single_quote_string = array (
  '<html> \$ -> This represents the dollar sign</html><?php echo hello ?>',
  '<html>\t\r\v The quick brown fo\fx jumped over the lazy dog</p>',
  '<a>This is a hyper text tag</a>',
  '<? <html>hello world\\t</html>?>',
  '<p>This is a paragraph</p>',
  '<b>This is \ta text in bold letters\r\s\malong with slashes\n</b>'
);

$quotes = "<html><a><p><b><?php";

//loop through the various elements of strings array to test strip_tags() 
functionality
$iterator = 1;
foreach($single_quote_string 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(51) "<html> \$ -> This represents the dollar sign</html>"
-- Iteration 2 --
string(63) "<html>\t\r\v The quick brown fo\fx jumped over the lazy dog</p>"
-- Iteration 3 --
string(31) "<a>This is a hyper text tag</a>"
-- Iteration 4 --
string(0) ""
-- Iteration 5 --
string(26) "<p>This is a paragraph</p>"
-- Iteration 6 --
string(65) "<b>This is \ta text in bold letters\r\s\malong with slashes\n</b>"
Done
--UEXPECTF--
*** Testing strip_tags() : usage variations ***
-- Iteration 1 --
unicode(51) "<html> \$ -> This represents the dollar sign</html>"
-- Iteration 2 --
unicode(63) "<html>\t\r\v The quick brown fo\fx jumped over the lazy dog</p>"
-- Iteration 3 --
unicode(31) "<a>This is a hyper text tag</a>"
-- Iteration 4 --
unicode(0) ""
-- Iteration 5 --
unicode(26) "<p>This is a paragraph</p>"
-- Iteration 6 --
unicode(65) "<b>This is \ta text in bold letters\r\s\malong with slashes\n</b>"
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strip_tags_variation5.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strip_tags_variation5.phpt
+++ php-src/ext/standard/tests/strings/strip_tags_variation5.phpt
--TEST--
Test strip_tags() function : usage variations - heredoc strings
--INI--
set short_open_tag = on
--FILE--
<?php
/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
 * Description: Strips HTML and PHP tags from a string
 * Source code: ext/standard/string.c
*/


/*
 * testing functionality of strip_tags() by giving heredoc strings as values 
for $str argument
*/

echo "*** Testing strip_tags() : usage variations ***\n";

// null here doc string
$null_string = <<<EOT
EOT;

// heredoc string with blank line
$blank_line = <<<EOT

EOT;

// here doc with multiline string
$multiline_string = <<<EOT
<html>hello world</html>
<p>13 &lt; 25</p>
<?php 1111 &amp; 0000 = 0000 ?>
<b>This is a double quoted string</b>
EOT;

// here doc with diferent whitespaces
$diff_whitespaces = <<<EOT
<html>hello\r world\t
1111\t\t != 2222\v\v</html>
<? heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces ?>
EOT;

// here doc with numeric values
$numeric_string = <<<EOT
<html>11 < 12. 123 >22</html>
<p>string</p> 1111\t <b>0000\t = 0000\n</b>
EOT;

// heredoc with quote chars & slash
$quote_char_string = <<<EOT
<html>This's a string with quotes:</html>
"strings in double quote";
'strings in single quote';
<html>this\line is single quoted /with\slashes </html>
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 = "<html><a><?php";

// loop through $res_heredoc_strings element and check the working on 
strip_tags()
$count = 1;
for($index =0; $index < count($res_heredoc_strings); $index ++) {
  echo "-- Iteration $count --\n";
  var_dump( strip_tags($res_heredoc_strings[$index], $quotes) );
  $count++;
}

echo "Done\n";
?>
--EXPECTF--
*** Testing strip_tags() : usage variations ***
-- Iteration 1 --
string(0) ""
-- Iteration 2 --
string(0) ""
-- Iteration 3 --
string(67) "<html>hello world</html>
13 &lt; 25

This is a double quoted string"
-- Iteration 4 --
string(44) "<html>hello world   
1111             != 2222</html>
"
-- Iteration 5 --
string(56) "<html>11 < 12. 123 >22</html>
string 1111      0000    = 0000
"
-- Iteration 6 --
string(150) "<html>This's a string with quotes:</html>
"strings in double quote";
'strings in single quote';
<html>this\line is single quoted /with\slashes </html>"
Done
--UEXPECTF--
*** Testing strip_tags() : usage variations ***
-- Iteration 1 --
unicode(0) ""
-- Iteration 2 --
unicode(0) ""
-- Iteration 3 --
unicode(67) "<html>hello world</html>
13 &lt; 25

This is a double quoted string"
-- Iteration 4 --
unicode(44) "<html>hello world  
1111             != 2222</html>
"
-- Iteration 5 --
unicode(56) "<html>11 < 12. 123 >22</html>
string 1111      0000    = 0000
"
-- Iteration 6 --
unicode(150) "<html>This's a string with quotes:</html>
"strings in double quote";
'strings in single quote';
<html>this\line is single quoted /with\slashes </html>"
Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to