From 326fd449e2b21b23c7825e7481fb0c7e0851fa09 Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Wed, 10 Oct 2007 10:04:46 +0000 Subject: [PATCH] Starting to merge updated set of tests into 5.3. --- ext/mysqli/tests/connect.inc | 67 ++++++++---- ext/mysqli/tests/local_infile_tools.inc | 111 ++++++++++++++++++++ ext/mysqli/tests/reflection_tools.inc | 121 ++++++++++++++++++++++ ext/mysqli/tests/skipif.inc | 7 +- ext/mysqli/tests/skipifconnectfailure.inc | 10 ++ ext/mysqli/tests/skipifemb.inc | 8 +- ext/mysqli/tests/skipifnotemb.inc | 8 +- ext/mysqli/tests/skipifunicode.inc | 5 + ext/mysqli/tests/table.inc | 23 ++++ 9 files changed, 327 insertions(+), 33 deletions(-) create mode 100644 ext/mysqli/tests/local_infile_tools.inc create mode 100644 ext/mysqli/tests/reflection_tools.inc create mode 100755 ext/mysqli/tests/skipifconnectfailure.inc create mode 100644 ext/mysqli/tests/skipifunicode.inc create mode 100644 ext/mysqli/tests/table.inc diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc index ea24ff89ae..5db701d93b 100644 --- a/ext/mysqli/tests/connect.inc +++ b/ext/mysqli/tests/connect.inc @@ -1,25 +1,54 @@ embedded) { - $host = "localhost"; - $user = "root"; - $passwd = ""; + $host = getenv("MYSQL_TEST_HOST") ? getenv("MYSQL_TEST_HOST") : "localhost"; + $port = getenv("MYSQL_TEST_PORT") ? getenv("MYSQL_TEST_PORT") : 3306; + $user = getenv("MYSQL_TEST_USER") ? getenv("MYSQL_TEST_USER") : "root"; + $passwd = getenv("MYSQL_TEST_PASSWD") ? getenv("MYSQL_TEST_PASSWD") : ""; + $db = getenv("MYSQL_TEST_DB") ? getenv("MYSQL_TEST_DB") : "phptest"; + $engine = getenv("MYSQL_TEST_ENGINE") ? getenv("MYSQL_TEST_ENGINE") : "MyISAM"; + $socket = getenv("MYSQL_TEST_SOCKET") ? getenv("MYSQL_TEST_SOCKET") : null; + + /* Development setting: test experimal features and/or feature requests that never worked before? */ + $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ? + ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) : + false; + + $IS_MYSQLND = stristr(mysqli_get_client_info(), "mysqlnd"); + if (!$IS_MYSQLND) { + $MYSQLND_VERSION = NULL; } else { - $path = dirname(__FILE__); - $host = ":embedded"; - $user = $passwd = NULL; - $args = array( - "--datadir=$path", - "--innodb_data_home_dir=$path", - "--innodb_data_file_path=ibdata1:10M:autoextend", - "--log-error=$path/testrun.log", - "--init-connect='CREATE DATABASE IF NOT EXISTS test;'" - ); - $driver->embedded_server_start(TRUE, $args, NULL); + if (preg_match('@Revision:\s+(\d+)\s*\$@ism', mysqli_get_client_info(), $matches)) { + $MYSQLND_VERSION = (int)$matches[1]; + } else { + $MYSQLND_VERSION = -1; + } } -?> + if (!function_exists('sys_get_temp_dir')) { + function sys_get_temp_dir() { + + if (!empty($_ENV['TMP'])) + return realpath( $_ENV['TMP'] ); + if (!empty($_ENV['TMPDIR'])) + return realpath( $_ENV['TMPDIR'] ); + if (!empty($_ENV['TEMP'])) + return realpath( $_ENV['TEMP'] ); + + $temp_file = tempnam(md5(uniqid(rand(), TRUE)), ''); + if ($temp_file) { + $temp_dir = realpath(dirname($temp_file)); + unlink($temp_file); + return $temp_dir; + } + return FALSE; + } + } +?> \ No newline at end of file diff --git a/ext/mysqli/tests/local_infile_tools.inc b/ext/mysqli/tests/local_infile_tools.inc new file mode 100644 index 0000000000..d740b8253c --- /dev/null +++ b/ext/mysqli/tests/local_infile_tools.inc @@ -0,0 +1,111 @@ + $values) { + if (!$tmp = mysqli_fetch_assoc($res)) { + printf("[%03d/%d] [%d] '%s'\n", $offset + 4, $k, mysqli_errno($link), mysqli_error($link)); + return false; + } + if ($values['id'] != $tmp['id']) { + printf("[%03d/%d] Expecting %s got %s\n", + $offset + 5, $k, + $values['id'], $tmp['id']); + return false; + } + if ($values['label'] != $tmp['label']) { + printf("[%03d/%d] Expecting %s got %s\n", + $offset + 6, $k, + $values['label'], $tmp['label']); + return false; + } + } + + if ($res && $tmp = mysqli_fetch_assoc($res)) { + printf("[%03d] More results than expected!\n", $offset + 7); + do { + var_dump($tmp); + } while ($tmp = mysqli_fetch_assoc($res)); + return false; + } + + if ($res) + mysqli_free_result($res); + + return true; + } +?> \ No newline at end of file diff --git a/ext/mysqli/tests/reflection_tools.inc b/ext/mysqli/tests/reflection_tools.inc new file mode 100644 index 0000000000..a96634b3c8 --- /dev/null +++ b/ext/mysqli/tests/reflection_tools.inc @@ -0,0 +1,121 @@ +getName()); + printf("isInternal: %s\n", ($class->isInternal()) ? 'yes' : 'no'); + printf("isUserDefined: %s\n", ($class->isUserDefined()) ? 'yes' : 'no'); + printf("isInstantiable: %s\n", ($class->isInstantiable()) ? 'yes' : 'no'); + printf("isInterface: %s\n", ($class->isInterface()) ? 'yes' : 'no'); + printf("isAbstract: %s\n", ($class->isAbstract()) ? 'yes' : 'no'); + printf("isFinal: %s\n", ($class->isFinal()) ? 'yes' : 'no'); + printf("isIteratable: %s\n", ($class->isIterateable()) ? 'yes' : 'no'); + printf("Modifiers: '%d'\n", $class->getModifiers()); + printf("Parent Class: '%s'\n", $class->getParentClass()); + printf("Extension: '%s'\n", $class->getExtensionName()); + + if ($method = $class->getConstructor()) + inspectMethod($method); + + if ($methods = $class->getMethods()) { + $tmp = array(); + foreach ($methods as $method) + $tmp[$method->getName()] = $method; + + ksort($tmp, SORT_STRING); + foreach ($tmp as $method) + inspectMethod($method); + } + + if ($properties = $class->getProperties()) { + $tmp = array(); + foreach ($properties as $prop) + $tmp[$prop->getName()] = $prop; + ksort($tmp, SORT_STRING); + foreach ($tmp as $prop) + inspectProperty($prop); + } + + + if ($properties = $class->getDefaultProperties()) { + ksort($properties, SORT_STRING); + foreach ($properties as $name => $v) + printf("Default property '%s'\n", $name); + } + + if ($properties = $class->getStaticProperties()) { + ksort($properties, SORT_STRING); + foreach ($properties as $name => $v) + printf("Static property '%s'\n", $name); + } + + if ($constants = $class->getConstants()) { + ksort($constants, SORT_STRING); + foreach ($constant as $name => $value) + printf("Constant '%s' = '%s'\n", $name, $value); + } + + } + + function inspectProperty(&$prop) { + + printf("\nInspecting property '%s'\n", $prop->getName()); + printf("isPublic: %s\n", ($prop->isPublic()) ? 'yes' : 'no'); + printf("isPrivate: %s\n", ($prop->isPrivate()) ? 'yes' : 'no'); + printf("isProtected: %s\n", ($prop->isProtected()) ? 'yes' : 'no'); + printf("isStatic: %s\n", ($prop->isStatic()) ? 'yes' : 'no'); + printf("isDefault: %s\n", ($prop->isDefault()) ? 'yes' : 'no'); + printf("Modifiers: %d\n", $prop->getModifiers()); + // printf("Value\n"); var_export($prop->getValue()); + + } + + function inspectMethod(&$method) { + + printf("\nInspecting method '%s'\n", $method->getName()); + printf("isFinal: %s\n", ($method->isFinal()) ? 'yes' : 'no'); + printf("isAbstract: %s\n", ($method->isAbstract()) ? 'yes' : 'no'); + printf("isPublic: %s\n", ($method->isPublic()) ? 'yes' : 'no'); + printf("isPrivate: %s\n", ($method->isPrivate()) ? 'yes' : 'no'); + printf("isProtected: %s\n", ($method->isProtected()) ? 'yes' : 'no'); + printf("isStatic: %s\n", ($method->isStatic()) ? 'yes' : 'no'); + printf("isConstructor: %s\n", ($method->isConstructor()) ? 'yes' : 'no'); + printf("isDestructor: %s\n", ($method->isDestructor()) ? 'yes' : 'no'); + printf("isInternal: %s\n", ($method->isInternal()) ? 'yes' : 'no'); + printf("isUserDefined: %s\n", ($method->isUserDefined()) ? 'yes' : 'no'); + printf("returnsReference: %s\n", ($method->returnsReference()) ? 'yes' : 'no'); + printf("Modifiers: %d\n", $method->getModifiers()); + printf("Number of Parameters: %d\n", $method->getNumberOfParameters()); + printf("Number of Required Parameters: %d\n", $method->getNumberOfRequiredParameters()); + + if ($params = $method->getParameters()) { + $tmp = array(); + foreach ($params as $k => $param) + $tmp[$param->getName()] = $param; + + ksort($tmp, SORT_STRING); + foreach ($tmp as $param) + inspectParameter($method, $param); + } + + if ($static = $method->getStaticVariables()) { + sort($static, SORT_STRING); + printf("Static variables: %s\n", implode('/', $static)); + } + + } + + function inspectParameter(&$method, &$param) { + + printf("\nInspecting parameter '%s' of method '%s'\n", + $param->getName(), $method->getName()); + printf("isArray: %s\n", ($param->isArray()) ? 'yes': 'no'); + printf("allowsNull: %s\n", ($param->allowsNull()) ? 'yes' : 'no'); + printf("isPassedByReference: %s\n", ($param->isPassedByReference()) ? 'yes' : 'no'); + printf("isOptional: %s\n", ($param->isOptional()) ? 'yes' : 'no'); + printf("isDefaultValueAvailable: %s\n", ($param->isDefaultValueAvailable()) ? 'yes' : 'no'); + // printf("getDefaultValue: %s\n", ($param->getDefaultValue()) ? 'yes' : 'no'); + + } +?> \ No newline at end of file diff --git a/ext/mysqli/tests/skipif.inc b/ext/mysqli/tests/skipif.inc index 38c438738c..a7581fb480 100644 --- a/ext/mysqli/tests/skipif.inc +++ b/ext/mysqli/tests/skipif.inc @@ -2,9 +2,4 @@ if (!extension_loaded('mysqli')){ die('skip mysqli extension not available'); } -include "connect.inc"; -$driver = new mysqli_driver(); -if (!$driver->embedded && !($con = @mysqli_connect($host, $user, $passwd, "", 3306))) { - die('skip could not connect to MySQL'); -} -?> +?> \ No newline at end of file diff --git a/ext/mysqli/tests/skipifconnectfailure.inc b/ext/mysqli/tests/skipifconnectfailure.inc new file mode 100755 index 0000000000..f2b193d378 --- /dev/null +++ b/ext/mysqli/tests/skipifconnectfailure.inc @@ -0,0 +1,10 @@ + diff --git a/ext/mysqli/tests/skipifemb.inc b/ext/mysqli/tests/skipifemb.inc index 298c7219a6..254a4ccece 100644 --- a/ext/mysqli/tests/skipifemb.inc +++ b/ext/mysqli/tests/skipifemb.inc @@ -1,5 +1,5 @@ embedded) - die("skip test doesn't run with embedded server"); -?> + $driver = new mysqli_driver(); + if ($driver->embedded) + die("skip test doesn't run with embedded server"); +?> \ No newline at end of file diff --git a/ext/mysqli/tests/skipifnotemb.inc b/ext/mysqli/tests/skipifnotemb.inc index 8639130cbe..d73d185bc4 100644 --- a/ext/mysqli/tests/skipifnotemb.inc +++ b/ext/mysqli/tests/skipifnotemb.inc @@ -1,5 +1,5 @@ embedded) - die("skip test for with embedded server only"); -?> + $driver = new mysqli_driver(); + if (!$driver->embedded) + die("skip test for with embedded server only"); +?> \ No newline at end of file diff --git a/ext/mysqli/tests/skipifunicode.inc b/ext/mysqli/tests/skipifunicode.inc new file mode 100644 index 0000000000..23cd79d460 --- /dev/null +++ b/ext/mysqli/tests/skipifunicode.inc @@ -0,0 +1,5 @@ + diff --git a/ext/mysqli/tests/table.inc b/ext/mysqli/tests/table.inc new file mode 100644 index 0000000000..bfbbed7102 --- /dev/null +++ b/ext/mysqli/tests/table.inc @@ -0,0 +1,23 @@ + \ No newline at end of file -- 2.50.1