summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Wendel <uw@php.net>2007-10-10 09:49:37 +0000
committerUlf Wendel <uw@php.net>2007-10-10 09:49:37 +0000
commit15a201d6a7b943b44795c295feda212dec5d9af9 (patch)
tree3547ff8b6bca87abf4423ea1aedd440c8a46bce5
parent83911a1e5ecea6b27ece9a3afb04e33d7cda9f38 (diff)
downloadphp-git-15a201d6a7b943b44795c295feda212dec5d9af9.tar.gz
New tests use more helper files.
-rwxr-xr-xext/mysql/tests/skipifconnectfailure.inc17
-rw-r--r--ext/mysql/tests/table.inc24
2 files changed, 41 insertions, 0 deletions
diff --git a/ext/mysql/tests/skipifconnectfailure.inc b/ext/mysql/tests/skipifconnectfailure.inc
new file mode 100755
index 0000000000..2fe4090daf
--- /dev/null
+++ b/ext/mysql/tests/skipifconnectfailure.inc
@@ -0,0 +1,17 @@
+<?php
+$skip_on_connect_failure = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : false;
+if ($skip_on_connect_failure) {
+ if ($socket)
+ $myhost = sprintf("%s:%s", $host, $socket);
+ else if ($port)
+ $myhost = sprintf("%s:%s", $host, $port);
+
+ if (!$link = @mysql_connect($myhost, $user, $passwd, true))
+ die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysql_errno(), mysql_error()));
+
+ if (!@mysql_select_db($db, $link))
+ die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysql_errno(), mysql_error()));
+
+ mysql_close($link);
+}
+?> \ No newline at end of file
diff --git a/ext/mysql/tests/table.inc b/ext/mysql/tests/table.inc
new file mode 100644
index 0000000000..ddfbe430c0
--- /dev/null
+++ b/ext/mysql/tests/table.inc
@@ -0,0 +1,24 @@
+<?PHP
+require_once('connect.inc');
+
+// connect + select_db
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $myhost, $user, $db, $port, $socket);
+ exit(1);
+}
+
+if (!mysql_query('DROP TABLE IF EXISTS test', $link)) {
+ printf("Failed to drop old test table: [%d] %s\n", mysql_errno($link), mysql_error($link));
+ exit(1);
+}
+
+if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine, $link)) {
+ printf("Failed to create test table: [%d] %s\n", mysql_errno($link), mysql_error($link));
+ exit(1);
+}
+
+if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")', $link)) {
+ printf("[%d] %s\n", mysql_errno($link), mysql_error($link));
+}
+?> \ No newline at end of file