From: Ulf Wendel Date: Tue, 20 Oct 2009 17:54:57 +0000 (+0000) Subject: Making test a bit more portable X-Git-Tag: php-5.4.0alpha1~191^2~2480 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9fe748303709eca85163d29426a95980f6f617b3;p=php Making test a bit more portable --- diff --git a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt index db92d4bff2..5ff6e5e458 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt @@ -45,23 +45,27 @@ require_once('skipifconnectfailure.inc'); printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); $stmt->prepare("SELECT * FROM test"); + mt_srand(microtime(true)); + + /* mysqlnd detects invalid attributes, libmysql does not AFAIK */ + $invalid_ret = ($IS_MYSQLND) ? false : true; + for ($i = -100; $i < 1000; $i++) { if (in_array($i, $valid_attr)) continue; $invalid_attr = $i; - if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { - printf("[006a] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); + if ($invalid_ret !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { + printf("[006a] Expecting boolean/%s for attribute %d, got %s/%s\n", $invalid_ret, $invalid_attr, gettype($tmp), $tmp); } } - for ($i = 0; $i < 10; $i++) { + for ($i = 0; $i < 2; $i++) { do { $invalid_attr = mt_rand(-1 * (min(4294967296, PHP_INT_MAX) + 1), min(4294967296, PHP_INT_MAX)); } while (in_array($invalid_attr, $valid_attr)); - if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { - /* Although it may be desired to get false neither the MySQL Client Library nor mysqlnd are supposed to detect invalid codes */ - printf("[006b] Expecting boolean/true for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); + if ($invalid_ret !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { + printf("[006b] Expecting boolean/%s for attribute %d, got %s/%s\n", $invalid_ret, $invalid_attr, gettype($tmp), $tmp); } } $stmt->close();