mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
Coverage for the OO variants of some functions
This commit is contained in:
parent
7eeff10cc0
commit
057a62fc52
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) {
|
||||
|
||||
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);
|
||||
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!
|
||||
|
Loading…
Reference in New Issue
Block a user