Annotation of embedaddon/php/ext/pcre/tests/preg_match_all_error2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test preg_match_all() function : error conditions - wrong arg types
                      3: --FILE--
                      4: <?php
                      5: /*
                      6: * proto int preg_match_all(string pattern, string subject, array subpatterns [, int flags [, int offset]])
                      7: * Function is implemented in ext/pcre/php_pcre.c
                      8: */
                      9: error_reporting(E_ALL&~E_NOTICE);
                     10: /*
                     11: * Testing how preg_match_all reacts to being passed the wrong type of input argument
                     12: */
                     13: echo "*** Testing preg_match_all() : error conditions ***\n";
                     14: $regex = '/[a-zA-Z]/';
                     15: $value = new stdclass(); //Object
                     16: var_dump(preg_match_all($regex, $value, $matches));
                     17: var_dump($matches);
                     18: $input = array(array('this is', 'a subarray'), 'test',);
                     19: foreach($input as $value) {
                     20:     print "\nArg value is: $value\n";
                     21:     var_dump(preg_match_all($regex, $value, $matches));
                     22:     var_dump($matches);
                     23: }
                     24: echo "Done";
                     25: ?>
                     26: --EXPECTF--
                     27: *** Testing preg_match_all() : error conditions ***
                     28: 
                     29: Warning: preg_match_all() expects parameter 2 to be string, object given in %spreg_match_all_error2.php on line %d
                     30: bool(false)
                     31: NULL
                     32: 
                     33: Arg value is: Array
                     34: 
                     35: Warning: preg_match_all() expects parameter 2 to be string, array given in %spreg_match_all_error2.php on line %d
                     36: bool(false)
                     37: NULL
                     38: 
                     39: Arg value is: test
                     40: int(4)
                     41: array(1) {
                     42:   [0]=>
                     43:   array(4) {
                     44:     [0]=>
                     45:     string(1) "t"
                     46:     [1]=>
                     47:     string(1) "e"
                     48:     [2]=>
                     49:     string(1) "s"
                     50:     [3]=>
                     51:     string(1) "t"
                     52:   }
                     53: }
                     54: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>