]> granicus.if.org Git - php/commitdiff
Coverage for the OO variants of some functions
authorUlf Wendel <uw@php.net>
Thu, 24 Sep 2009 08:19:56 +0000 (08:19 +0000)
committerUlf Wendel <uw@php.net>
Thu, 24 Sep 2009 08:19:56 +0000 (08:19 +0000)
ext/mysqli/tests/mysqli_class_mysqli_driver_reflection.phpt
ext/mysqli/tests/mysqli_get_connection_stats.phpt
ext/mysqli/tests/mysqli_poll.phpt

index 9141469967e6c9e295dd2246a2f9485684c3acfb..2e6d9c2fd1c723f903e8d4547919fa2ae07074ad 100644 (file)
@@ -15,8 +15,6 @@ Those tests go into the details and are aimed to be a development tool, no more.
 */
 if (!$IS_MYSQLND)
        die("skip Test has been written for the latest version of mysqlnd only");
-if ($MYSQLND_VERSION < 50005)
-       die("skip Test requires mysqlnd Revision 5.0.4 or newer");
 ?>
 --FILE--
 <?php
index 8c2926a0b80c0da648db56a2838e1f0f5e47ee5c..698a4684ff9c90d9df35efbfdaa1bca3d05ac879 100644 (file)
@@ -47,18 +47,33 @@ if (!function_exists('mysqli_get_connection_stats')) {
                var_dump($info2);
        }
 
+       if (!is_array($info = $link->get_connection_stats()) || empty($info))
+               printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
+
+       foreach ($info as $k => &$v) {
+               if (strpos($k, "mem_") === 0) {
+                       $v = 0;
+               }
+       }
+
+       if ($info !== $info2) {
+               printf("[007] The hashes should be identical except of the memory related fields\n");
+               var_dump($info);
+               var_dump($info2);
+       }
+
        mysqli_close($link);
        include "table.inc";
 
        if (!is_array($info = mysqli_get_connection_stats($link)) || empty($info))
-               printf("[006] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
+               printf("[008] Expecting array/any_non_empty, got %s/%s\n", gettype($info), $info);
 
        if (!is_array($info2 = mysqli_get_client_stats()) || empty($info2))
-               printf("[007] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
+               printf("[009] Expecting array/any_non_empty, got %s/%s\n", gettype($info2), $info2);
 
        // assuming the test is run in a plain-vanilla CLI environment
        if ($info === $info2) {
-               printf("[008] The hashes should not be identical\n");
+               printf("[010] The hashes should not be identical\n");
                var_dump($info);
                var_dump($info2);
        }
index 1bfae4bdbe95c24727a56aee8b42255f36aacffe..93e3b210bf70307c09737dda6fe45eb5c821e049 100644 (file)
@@ -53,14 +53,25 @@ if (!$IS_MYSQLND)
                printf("[009] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true));
 
 
-       function poll_async($offset, $links, $errors, $reject, $exp_ready) {
-
-               if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000)))
-                       printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
-                               $exp_ready, $tmp);
+       function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) {
+
+               if ($use_oo_syntax) {
+                       if ($exp_ready !== ($tmp = $link->poll($links, $errors, $reject, 0, 1000)))
+                               printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
+                                       $exp_ready, $tmp);
+               } else {
+                       if ($exp_ready !== ($tmp = mysqli_poll($links, $errors, $reject, 0, 1000)))
+                               printf("[%03d + 1] There should be %d links ready to read from, %d ready\n",
+                                       $exp_ready, $tmp);
+               }
 
                foreach ($links as $mysqli) {
-                       if (is_object($res = mysqli_reap_async_query($mysqli))) {
+                       if ($use_oo_syntax) {
+                               $res = $mysqli->reap_async_query();
+                       } else {
+                               $res = mysqli_reap_async_query($mysqli);
+                       }
+                       if (is_object($res)) {
                                printf("[%03d + 2] Can fetch resultset although no query has been run!\n", $offset);
                        } else if (mysqli_errno($mysqli) > 0) {
                                printf("[%03d + 3] Error indicated through links array: %d/%s",
@@ -85,7 +96,14 @@ if (!$IS_MYSQLND)
        $links = array($link);
        $errors = array($link);
        $reject = array($link);
-       poll_async(10, $links, $errors, $reject, 0);
+       poll_async(10, $link, $links, $errors, $reject, 0, false);
+       mysqli_close($link);
+
+       $link = get_connection();
+       $links = array($link);
+       $errors = array($link);
+       $reject = array($link);
+       poll_async(11, $link, $links, $errors, $reject, 0, true);
        mysqli_close($link);
 
        // Connections on which no query has been send - 2
@@ -94,7 +112,7 @@ if (!$IS_MYSQLND)
        $links = array($link, $link);
        $errors = array($link, $link);
        $reject = array();
-       poll_async(11, $links, $errors, $reject, 0);
+       poll_async(12, $link, $links, $errors, $reject, 0, false);
 
        // Connections on which no query has been send - 3
        // Difference: pass two connections
@@ -102,7 +120,7 @@ if (!$IS_MYSQLND)
        $links = array($link, get_connection());
        $errors = array($link, $link);
        $reject = array();
-       poll_async(12, $links, $errors, $reject, 0);
+       poll_async(13, $link, $links, $errors, $reject, 0, false);
 
        // Reference mess...
        $link = get_connection();
@@ -110,15 +128,16 @@ if (!$IS_MYSQLND)
        $errors = array($link);
        $ref_errors =& $errors;
        $reject = array();
-       poll_async(13, $links, $ref_errors, $reject, 0);
+       poll_async(14, $link, $links, $ref_errors, $reject, 0, false);
 
        print "done!";
 ?>
 --EXPECTF--
 [010 + 6] Rejecting thread %d: 0/
 [011 + 6] Rejecting thread %d: 0/
-[011 + 6] Rejecting thread %d: 0/
 [012 + 6] Rejecting thread %d: 0/
 [012 + 6] Rejecting thread %d: 0/
 [013 + 6] Rejecting thread %d: 0/
+[013 + 6] Rejecting thread %d: 0/
+[014 + 6] Rejecting thread %d: 0/
 done!