summaryrefslogtreecommitdiff
path: root/ext/mysqli
diff options
context:
space:
mode:
authorUlf Wendel <uw@php.net>2007-10-10 10:20:11 +0000
committerUlf Wendel <uw@php.net>2007-10-10 10:20:11 +0000
commit8cc5e4740274f33a0cea9c6c70cf377e9c5e72cc (patch)
tree1de68330d5f7292717ca144c37144c7f5adc0edf /ext/mysqli
parent3a3594d3f1298b04e1cd9c8988a5a195a21a32c5 (diff)
downloadphp-git-8cc5e4740274f33a0cea9c6c70cf377e9c5e72cc.tar.gz
Last bunch of new tests.
Diffstat (limited to 'ext/mysqli')
-rw-r--r--ext/mysqli/tests/mysqli_thread_id.phpt40
-rw-r--r--ext/mysqli/tests/mysqli_thread_safe.phpt16
-rw-r--r--ext/mysqli/tests/mysqli_unclonable.phpt23
-rw-r--r--ext/mysqli/tests/mysqli_use_result.phpt62
-rw-r--r--ext/mysqli/tests/mysqli_warning_count.phpt48
-rw-r--r--ext/mysqli/tests/mysqli_warning_unclonable.phpt37
6 files changed, 226 insertions, 0 deletions
diff --git a/ext/mysqli/tests/mysqli_thread_id.phpt b/ext/mysqli/tests/mysqli_thread_id.phpt
new file mode 100644
index 0000000000..6735489444
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_thread_id.phpt
@@ -0,0 +1,40 @@
+--TEST--
+mysqli_thread_id()
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ $tmp = NULL;
+ $link = NULL;
+
+ if (!is_null($tmp = @mysqli_thread_id()))
+ printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!is_null($tmp = @mysqli_thread_id($link)))
+ printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ require('table.inc');
+
+ if (!is_int($tmp = mysqli_thread_id($link)) || (0 === $tmp))
+ printf("[003] Expecting int/any but zero, got %s/%s. [%d] %s\n",
+ gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
+
+ // should work if the thread id is correct
+ mysqli_kill($link, mysqli_thread_id($link));
+
+ mysqli_close($link);
+
+ if (NULL !== ($tmp = mysqli_thread_id($link)))
+ printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ print "done!";
+?>
+--EXPECTF--
+Warning: mysqli_thread_id(): Couldn't fetch mysqli in %s on line %d
+done! \ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_thread_safe.phpt b/ext/mysqli/tests/mysqli_thread_safe.phpt
new file mode 100644
index 0000000000..0777c2abd7
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_thread_safe.phpt
@@ -0,0 +1,16 @@
+--TEST--
+mysqli_thread_safe()
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+?>
+--FILE--
+<?php
+ if (!is_bool($tmp = mysqli_thread_safe()))
+ printf("[001] Expecting boolean/any, got %s/%s.\n", gettype($tmp), $tmp);
+
+ print "done!";
+?>
+--EXPECTF--
+done! \ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_unclonable.phpt b/ext/mysqli/tests/mysqli_unclonable.phpt
new file mode 100644
index 0000000000..73894f4f2a
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_unclonable.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Trying to clone mysqli object
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+ $link_clone = clone $link;
+ mysqli_close($link);
+
+ print "done!";
+?>
+--EXPECTF--
+Fatal error: Trying to clone an uncloneable object of class mysqli in %s on line %d \ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_use_result.phpt b/ext/mysqli/tests/mysqli_use_result.phpt
new file mode 100644
index 0000000000..2f53aeae2a
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_use_result.phpt
@@ -0,0 +1,62 @@
+--TEST--
+mysqli_use_result()
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ $tmp = NULL;
+ $link = NULL;
+
+ if (!is_null($tmp = @mysqli_use_result()))
+ printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!is_null($tmp = @mysqli_use_result($link)))
+ printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ require('table.inc');
+
+ if (!$res = mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id"))
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($res = mysqli_use_result($link)))
+ printf("[004] Expecting object, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+
+ if (false !== ($tmp = mysqli_data_seek($res, 2)))
+ printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n",
+ gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
+
+ mysqli_free_result($res);
+
+ if (!mysqli_query($link, "DELETE FROM test"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (false !== ($res = mysqli_use_result($link)))
+ printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n",
+ gettype($res), $res, mysqli_errno($link), mysqli_error($link));
+
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test ORDER BY id"))
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (false !== ($tmp = mysqli_data_seek($res, 1)))
+ printf("[009] Expecting boolean/false, got %s/%s\n",
+ gettype($tmp), $tmp);
+
+ mysqli_close($link);
+
+ if (NULL !== ($tmp = mysqli_use_result($link)))
+ printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ print "done!";
+?>
+--EXPECTF--
+Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
+
+Warning: mysqli_use_result(): Couldn't fetch mysqli in %s on line %d
+done! \ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_warning_count.phpt b/ext/mysqli/tests/mysqli_warning_count.phpt
new file mode 100644
index 0000000000..c1663131b5
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_warning_count.phpt
@@ -0,0 +1,48 @@
+--TEST--
+mysqli_warning_count()
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ $tmp = NULL;
+ $link = NULL;
+
+ if (!is_null($tmp = @mysqli_warning_count()))
+ printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!is_null($tmp = @mysqli_warning_count($link)))
+ printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ require('table.inc');
+
+ if (NULL !== ($tmp = @mysqli_warning_count($link, "too_many")))
+ printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (0 !== ($tmp = mysqli_warning_count($link)))
+ printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS this_table_does_not_exist"))
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (1 !== ($tmp = mysqli_warning_count($link)))
+ printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
+
+ mysqli_close($link);
+
+ if (NULL !== ($tmp = mysqli_warning_count($link)))
+ printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
+
+ print "done!";
+?>
+--EXPECTF--
+Warning: mysqli_warning_count(): Couldn't fetch mysqli in %s on line %d
+done! \ No newline at end of file
diff --git a/ext/mysqli/tests/mysqli_warning_unclonable.phpt b/ext/mysqli/tests/mysqli_warning_unclonable.phpt
new file mode 100644
index 0000000000..bdbc0e2f70
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_warning_unclonable.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Trying to clone mysqli_warning object
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+require_once('connect.inc');
+if (!$TEST_EXPERIMENTAL)
+ die("skip - experimental (= unsupported) feature");
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_query($link, "CREATE TABLE test (id SMALLINT)"))
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!mysqli_query($link, "INSERT INTO test (id) VALUES (1000000)"))
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+
+ if (!is_object($warning = mysqli_get_warnings($link)) || 'mysqli_warning' != get_class($warning)) {
+ printf("[005] Expecting object/mysqli_warning, got %s/%s\n", gettype($tmp), (is_object($tmp) ? var_dump($tmp, true) : $tmp));
+ }
+
+ $warning_clone = clone $warning;
+ print "done!";
+?>
+--EXPECTF--
+Fatal error: Trying to clone an uncloneable object of class mysqli_warning in %s on line %d \ No newline at end of file