From: Ulf Wendel Date: Wed, 11 Jul 2007 15:26:07 +0000 (+0000) Subject: Whitespace and more testing. X-Git-Tag: BEFORE_IMPORT_OF_MYSQLND~217 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ff686d786863e4ef97edaf01ffdf6ea90ad36a1;p=php Whitespace and more testing. --- diff --git a/ext/mysql/tests/mysql_fetch_field.phpt b/ext/mysql/tests/mysql_fetch_field.phpt index cfd0a42b8b..31a9dfd427 100644 --- a/ext/mysql/tests/mysql_fetch_field.phpt +++ b/ext/mysql/tests/mysql_fetch_field.phpt @@ -2,7 +2,6 @@ mysql_fetch_field() --SKIPIF-- - --FILE-- array(1, 'int'), + 'TINYINT' => array(1, 'int'), + 'BOOL' => array('true', 'int'), + 'SMALLINT' => array(32767, 'int'), + 'MEDIUMINT' => array(8388607, 'int'), + 'INT' => array(100, 'int'), + 'BIGINT' => array(100, 'int'), + 'FLOAT' => array(100, 'real'), + 'DOUBLE' => array(100, 'real'), + 'DECIMAL' => array(100, 'real'), + 'DATE' => array(@date('Y-m-d'), 'date'), + 'DATETIME' => array(@date('Y-m-d H:i:s'), 'datetime'), + 'TIMESTAMP' => array(@date('Y-m-d H:i:s'), 'timestamp'), + 'TIME' => array(@date('H:i:s'), 'time'), + 'YEAR' => array(@date('Y'), 'year'), + 'CHAR(1)' => array('a', 'string'), + 'VARCHAR(1)' => array('a', 'string'), + 'BINARY(1)' => array('a', 'string'), + 'VARBINARY(1)' => array('a', 'string'), + 'TINYBLOB' => array('a', 'blob'), + 'TINYTEXT' => array('a', 'blob'), + 'BLOB' => array('a', 'blob'), + 'TEXT' => array('a', 'blob'), + 'MEDIUMBLOB' => array('a', 'blob'), + 'MEDIUMTEXT' => array('a', 'blob'), + 'LONGBLOB' => array('a', 'blob'), + 'LONGTEXT' => array('a', 'blob'), + 'ENUM("a", "b")' => array('a', 'string'), /* !!! */ + 'SET("a", "b")' => array('a', 'string'), /* !!! */ + ); + + foreach ($types as $type_name => $type_desc) { + if (!mysql_query("DROP TABLE IF EXISTS test", $link)) + printf("[008/%s] [%d] %s\n", $type_name, mysql_errno($link), mysql_error($link)); + if (!mysql_query(sprintf("CREATE TABLE test(id INT, label %s) ENGINE = %s", $type_name, $engine), $link)) { + // server and/or engine might not support the data type + continue; + } + if (!mysql_query(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $type_desc[0]), $link)) { + printf("[009/%s] [%d] %s\n", $type_name, mysql_errno($link), mysql_error($link)); + continue; + } + if (!$res = mysql_query("SELECT id, label FROM test", $link)) { + printf("[010/%s] [%d] %s\n", $type_name, mysql_errno($link), mysql_error($link)); + continue; + } + if (!$tmp = mysql_fetch_field($res, 1)) { + printf("[011/%s] [%d] %s\n", $type_name, mysql_errno($link), mysql_error($link)); + } + + if ($type_desc[1] != $tmp->type) { + printf("[012/%s] Expecting type '%s' got '%s'\n", $type_name, $type_desc[1], $tmp->type); + } + mysql_free_result($res); + } mysql_close($link); print "done!"; @@ -93,6 +164,8 @@ object(stdClass)#%d (13) { } bool(false) +Warning: mysql_fetch_field(): Bad field offset in %s on line %d + Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d done! --UEXPECTF-- @@ -154,5 +227,7 @@ object(stdClass)#%d (13) { } bool(false) +Warning: mysql_fetch_field(): Bad field offset in %s on line %d + Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d done!