xref: /PHP-7.0/ext/filter/tests/045.phpt (revision 610c7fbe)
1--TEST--
2Options must not be changed by filter_var()
3--SKIPIF--
4<?php if (!extension_loaded("filter")) die("skip"); ?>
5--FILE--
6<?php
7$a = array("flags"=>(string)FILTER_FLAG_ALLOW_HEX, "options" => array("min_range"=>"0", "max_range"=>"1024"));
8$ret = filter_var("0xff", FILTER_VALIDATE_INT, $a);
9echo ($ret === 255 && $a["options"]["min_range"] === "0")?"ok\n":"bug\n";
10echo ($ret === 255 && $a["options"]["max_range"] === "1024")?"ok\n":"bug\n";
11echo ($ret === 255 && is_string($a["flags"]) && $a["flags"] == FILTER_FLAG_ALLOW_HEX)?"ok\n":"bug\n";
12$a = (string)FILTER_FLAG_ALLOW_HEX;
13$ret = filter_var("0xff", FILTER_VALIDATE_INT, $a);
14echo ($ret === 255 && is_string($a) && $a == FILTER_FLAG_ALLOW_HEX)?"ok\n":"bug\n";
15$a = array("test"=>array("filter"=>(string)FILTER_VALIDATE_INT, "flags"=>(string)FILTER_FLAG_ALLOW_HEX));
16$ret = filter_var_array(array("test"=>"0xff"), $a);
17echo ($ret["test"] === 255 && is_string($a["test"]["filter"]) && $a["test"]["filter"] == FILTER_VALIDATE_INT)?"ok\n":"bug\n";
18echo ($ret["test"] === 255 && is_string($a["test"]["flags"]) && $a["test"]["flags"] == FILTER_FLAG_ALLOW_HEX)?"ok\n":"bug\n";
19$a = array("test"=>(string)FILTER_VALIDATE_INT);
20$ret = filter_var_array(array("test"=>"255"), $a);
21echo ($ret["test"] === 255 && is_string($a["test"]) && $a["test"] == FILTER_VALIDATE_INT)?"ok\n":"bug\n";
22?>
23--EXPECT--
24ok
25ok
26ok
27ok
28ok
29ok
30ok
31