svn: /php/php-src/ branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_attr_set.phpt trunk/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
| From: | Ulf Wendel | Date: | Tue, 20 Oct 2009 17:54:57 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_attr_set.phpt trunk/ext/mysqli/tests/mysqli_stmt_attr_set.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-60739@lists.php.net to get a copy of this message | ||
uw Tue, 20 Oct 2009 17:54:57 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=289804
Log:
Making test a bit more portable
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
U php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_attr_set.phpt 2009-10-20 17:52:18 UTC
(rev 289803)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_stmt_attr_set.phpt 2009-10-20 17:54:57 UTC
(rev 289804)
@@ -45,23 +45,27 @@
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();
Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_attr_set.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_attr_set.phpt 2009-10-20 17:52:18 UTC (rev
289803)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_stmt_attr_set.phpt 2009-10-20 17:54:57 UTC (rev
289804)
@@ -45,23 +45,27 @@
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();