]> granicus.if.org Git - php/commitdiff
Making test a bit more portable
authorUlf Wendel <uw@php.net>
Tue, 20 Oct 2009 17:54:57 +0000 (17:54 +0000)
committerUlf Wendel <uw@php.net>
Tue, 20 Oct 2009 17:54:57 +0000 (17:54 +0000)
ext/mysqli/tests/mysqli_stmt_attr_set.phpt

index db92d4bff2fec04787c00c7d84923a5db60d33f2..5ff6e5e4583be4bfc5e69f6fdb19dd83759ba7d1 100644 (file)
@@ -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();