From: Ulf Wendel Date: Wed, 10 Oct 2007 09:51:45 +0000 (+0000) Subject: Adding new tests. X-Git-Tag: RELEASE_1_3_1~885 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dd9292e225dd92b1caef1bc97d0f740495d37aaf;p=php Adding new tests. --- diff --git a/ext/mysql/tests/mysql_affected_rows.phpt b/ext/mysql/tests/mysql_affected_rows.phpt new file mode 100644 index 0000000000..64b2d161d2 --- /dev/null +++ b/ext/mysql/tests/mysql_affected_rows.phpt @@ -0,0 +1,117 @@ +--TEST-- +mysql_affected_rows() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +done! diff --git a/ext/mysql/tests/mysql_client_encoding.phpt b/ext/mysql/tests/mysql_client_encoding.phpt new file mode 100644 index 0000000000..fe94490d06 --- /dev/null +++ b/ext/mysql/tests/mysql_client_encoding.phpt @@ -0,0 +1,67 @@ +--TEST-- +mysql_client_encoding() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +done! diff --git a/ext/mysql/tests/mysql_close.phpt b/ext/mysql/tests/mysql_close.phpt new file mode 100644 index 0000000000..19b13b74a4 --- /dev/null +++ b/ext/mysql/tests/mysql_close.phpt @@ -0,0 +1,36 @@ +--TEST-- +mysql_close() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_connect.phpt b/ext/mysql/tests/mysql_connect.phpt new file mode 100644 index 0000000000..ef4010ffc0 --- /dev/null +++ b/ext/mysql/tests/mysql_connect.phpt @@ -0,0 +1,98 @@ +--TEST-- +mysql_connect() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: mysql_connect(): Access denied for user '%s'@'%s' (using password: YES) in %s on line %d +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_constants.phpt b/ext/mysql/tests/mysql_constants.phpt new file mode 100644 index 0000000000..e20d32a346 --- /dev/null +++ b/ext/mysql/tests/mysql_constants.phpt @@ -0,0 +1,62 @@ +--TEST-- +Constants exported by ext/mysql +--SKIPIF-- + +--FILE-- + true, + 'MYSQL_NUM' => true, + 'MYSQL_BOTH' => true, + 'MYSQL_CLIENT_COMPRESS' => true, + 'MYSQL_CLIENT_INTERACTIVE' => true, + 'MYSQL_CLIENT_IGNORE_SPACE' => true, +); + +$version = mysql_get_server_info($link); +if (!preg_match('@(\d+)\.(\d+)\.(\d+)@ism', $version, $matches)) + printf("[001] Cannot get server version\n"); +$version = ($matches[1] * 100) + ($matches[2] * 10) + $matches[3]; + +if ($version > 400) { + $expected_constants = array_merge($expected_constants, array( + "MYSQL_CLIENT_SSL" => true, + )); +} + + +$unexpected_constants = array(); + +foreach ($constants as $group => $consts) { + foreach ($consts as $name => $value) { + if (stristr($name, 'mysql') && !stristr($name, 'mysqli')) { + $name = strtoupper($name); + if (isset($expected_constants[$name])) { + unset($expected_constants[$name]); + } else { + $unexpected_constants[$name] = $name; + } + } + } +} + +if (!empty($unexpected_constants)) { + printf("Dumping list of unexpected constants\n"); + var_dump($unexpected_constants); +} + +if (!empty($expected_constants)) { + printf("Dumping list of missing constants\n"); + var_dump($expected_constants); +} + +print "done!"; +?> +--EXPECTF-- +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_create_db.phpt b/ext/mysql/tests/mysql_create_db.phpt new file mode 100644 index 0000000000..0a5d30e97a --- /dev/null +++ b/ext/mysql/tests/mysql_create_db.phpt @@ -0,0 +1,44 @@ +--TEST-- +mysql_create_db() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +done! diff --git a/ext/mysql/tests/mysql_errno.phpt b/ext/mysql/tests/mysql_errno.phpt new file mode 100644 index 0000000000..288376ae82 --- /dev/null +++ b/ext/mysql/tests/mysql_errno.phpt @@ -0,0 +1,56 @@ +--TEST-- +mysql_errno() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +int(0) +int(%d) + +Warning: mysql_errno(): %d is not a valid MySQL-Link resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_error.phpt b/ext/mysql/tests/mysql_error.phpt new file mode 100644 index 0000000000..afdd90c338 --- /dev/null +++ b/ext/mysql/tests/mysql_error.phpt @@ -0,0 +1,60 @@ +--TEST-- +mysql_error() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: mysql_error(): %d is not a valid MySQL-Link resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_escape_string.phpt b/ext/mysql/tests/mysql_escape_string.phpt new file mode 100644 index 0000000000..1badea8903 --- /dev/null +++ b/ext/mysql/tests/mysql_escape_string.phpt @@ -0,0 +1,42 @@ +--TEST-- +mysql_escape_string() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(31) "Am I a unicode string in PHP 6?" +string(2) "\\" +string(2) "\"" +string(2) "\'" +string(2) "\n" +string(2) "\r" +string(8) "foo\0bar" +done! +--UEXPECTF-- +unicode(31) "Am I a unicode string in PHP 6?" +unicode(2) "\\" +unicode(2) "\"" +unicode(2) "\'" +unicode(2) "\n" +unicode(2) "\r" +unicode(8) "foo\0bar" +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_fetch_array.phpt b/ext/mysql/tests/mysql_fetch_array.phpt new file mode 100644 index 0000000000..f197ae9494 --- /dev/null +++ b/ext/mysql/tests/mysql_fetch_array.phpt @@ -0,0 +1,431 @@ +--TEST-- +mysql_fetch_array() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[005] +array(4) { + [0]=> + string(1) "1" + ["id"]=> + string(1) "1" + [1]=> + string(1) "a" + ["label"]=> + string(1) "a" +} +[006] +array(2) { + [0]=> + string(1) "2" + [1]=> + string(1) "b" +} +[007] +array(4) { + [0]=> + string(1) "3" + ["id"]=> + string(1) "3" + [1]=> + string(1) "c" + ["label"]=> + string(1) "c" +} +[008] +array(2) { + ["id"]=> + string(1) "4" + ["label"]=> + string(1) "d" +} +[009] +array(4) { + [0]=> + string(1) "5" + ["id"]=> + string(1) "5" + [1]=> + string(1) "e" + ["label"]=> + string(1) "e" +} +[011] +array(11) { + [0]=> + string(1) "1" + ["a"]=> + string(1) "2" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + ["c"]=> + string(1) "3" + [3]=> + string(1) "4" + ["C"]=> + string(1) "4" + [4]=> + NULL + ["d"]=> + NULL + [5]=> + string(1) "1" + ["e"]=> + string(1) "1" +} + +Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d +done! +--UEXPECTF-- +[005] +array(4) { + [0]=> + unicode(1) "1" + [u"id"]=> + unicode(1) "1" + [1]=> + unicode(1) "a" + [u"label"]=> + unicode(1) "a" +} +[006] +array(2) { + [0]=> + unicode(1) "2" + [1]=> + unicode(1) "b" +} +[007] +array(4) { + [0]=> + unicode(1) "3" + [u"id"]=> + unicode(1) "3" + [1]=> + unicode(1) "c" + [u"label"]=> + unicode(1) "c" +} +[008] +array(2) { + [u"id"]=> + unicode(1) "4" + [u"label"]=> + unicode(1) "d" +} +[009] +array(4) { + [0]=> + unicode(1) "5" + [u"id"]=> + unicode(1) "5" + [1]=> + unicode(1) "e" + [u"label"]=> + unicode(1) "e" +} +[011] +array(11) { + [0]=> + unicode(1) "1" + [u"a"]=> + unicode(1) "2" + [1]=> + unicode(1) "2" + [2]=> + unicode(1) "3" + [u"c"]=> + unicode(1) "3" + [3]=> + unicode(1) "4" + [u"C"]=> + unicode(1) "4" + [4]=> + NULL + [u"d"]=> + NULL + [5]=> + unicode(1) "1" + [u"e"]=> + unicode(1) "1" +} + +Warning: mysql_fetch_array(): %d is not a valid MySQL result resource in %s on line %d +done! diff --git a/ext/mysql/tests/mysql_fetch_assoc.phpt b/ext/mysql/tests/mysql_fetch_assoc.phpt new file mode 100644 index 0000000000..172917b6fd --- /dev/null +++ b/ext/mysql/tests/mysql_fetch_assoc.phpt @@ -0,0 +1,138 @@ +--TEST-- +mysql_fetch_assoc() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[005] +array(2) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} +[006] +bool(false) +[008] +array(5) { + ["a"]=> + string(1) "2" + ["c"]=> + string(1) "3" + ["C"]=> + string(1) "4" + ["d"]=> + NULL + ["e"]=> + string(1) "1" +} + +Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d +[010] +array(5) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" + ["_id"]=> + string(1) "1" + ["_label"]=> + string(2) "aa" + ["_foo"]=> + NULL +} +done! +--UEXPECTF-- +[005] +array(2) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} +[006] +bool(false) +[008] +array(5) { + [u"a"]=> + unicode(1) "2" + [u"c"]=> + unicode(1) "3" + [u"C"]=> + unicode(1) "4" + [u"d"]=> + NULL + [u"e"]=> + unicode(1) "1" +} + +Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d +[010] +array(5) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" + [u"_id"]=> + unicode(1) "1" + [u"_label"]=> + unicode(2) "aa" + [u"_foo"]=> + NULL +} +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_fetch_field.phpt b/ext/mysql/tests/mysql_fetch_field.phpt new file mode 100644 index 0000000000..7a50e23ca0 --- /dev/null +++ b/ext/mysql/tests/mysql_fetch_field.phpt @@ -0,0 +1,373 @@ +--TEST-- +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); + } + + if (!mysql_query("DROP TABLE IF EXISTS test", $link)) + printf("[013] [%d] %s\n", mysql_errno($link), mysql_error($link)); + + if (!mysql_query("CREATE TABLE test(id INT DEFAULT 1)")) + printf("[014] [%d] %s\n", mysql_errno($link), mysql_error($link)); + + if (!mysql_query("INSERT INTO test(id) VALUES (2)")) + printf("[015] [%d] %s\n", mysql_errno($link), mysql_error($link)); + + if (!$res = mysql_query("SELECT id FROM test", $link)) { + printf("[016] [%d] %s\n", mysql_errno($link), mysql_error($link)); + } + + var_dump(mysql_fetch_field($res)); + mysql_free_result($res); + + if (!$res = mysql_query("SELECT id FROM test", $link)) { + printf("[017] [%d] %s\n", mysql_errno($link), mysql_error($link)); + } + $res = mysql_list_fields($db, 'test'); + while ($tmp = mysql_fetch_field($res)) + if ($tmp->name == 'id') + var_dump($tmp); + + mysql_free_result($res); + + mysql_close($link); + print "done!"; +?> +--EXPECTF-- +object(stdClass)#%d (13) { + ["name"]=> + string(2) "ID" + ["table"]=> + string(4) "TEST" + ["def"]=> + string(0) "" + ["max_length"]=> + int(1) + ["not_null"]=> + int(1) + ["primary_key"]=> + int(1) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(1) + ["blob"]=> + int(0) + ["type"]=> + string(3) "int" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} +object(stdClass)#%d (13) { + ["name"]=> + string(5) "label" + ["table"]=> + string(4) "TEST" + ["def"]=> + string(0) "" + ["max_length"]=> + int(1) + ["not_null"]=> + int(0) + ["primary_key"]=> + int(0) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(0) + ["blob"]=> + int(0) + ["type"]=> + string(6) "string" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} +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 +object(stdClass)#%d (13) { + ["name"]=> + string(2) "id" + ["table"]=> + string(4) "test" + ["def"]=> + string(0) "" + ["max_length"]=> + int(1) + ["not_null"]=> + int(0) + ["primary_key"]=> + int(0) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(1) + ["blob"]=> + int(0) + ["type"]=> + string(3) "int" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} +object(stdClass)#%d (13) { + ["name"]=> + string(2) "id" + ["table"]=> + string(4) "test" + ["def"]=> + string(1) "1" + ["max_length"]=> + int(0) + ["not_null"]=> + int(0) + ["primary_key"]=> + int(0) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(1) + ["blob"]=> + int(0) + ["type"]=> + string(3) "int" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} +done! +--UEXPECTF-- +object(stdClass)#%d (13) { + [u"name"]=> + unicode(2) "ID" + [u"table"]=> + unicode(4) "TEST" + [u"def"]=> + unicode(0) "" + [u"max_length"]=> + int(1) + [u"not_null"]=> + int(1) + [u"primary_key"]=> + int(1) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(1) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(3) "int" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} +object(stdClass)#%d (13) { + [u"name"]=> + unicode(5) "label" + [u"table"]=> + unicode(4) "TEST" + [u"def"]=> + unicode(0) "" + [u"max_length"]=> + int(1) + [u"not_null"]=> + int(0) + [u"primary_key"]=> + int(0) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(0) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(6) "string" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} +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 +object(stdClass)#%d (13) { + [u"name"]=> + unicode(2) "id" + [u"table"]=> + unicode(4) "test" + [u"def"]=> + unicode(0) "" + [u"max_length"]=> + int(1) + [u"not_null"]=> + int(0) + [u"primary_key"]=> + int(0) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(1) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(3) "int" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} +object(stdClass)#%d (13) { + [u"name"]=> + unicode(2) "id" + [u"table"]=> + unicode(4) "test" + [u"def"]=> + unicode(1) "1" + [u"max_length"]=> + int(0) + [u"not_null"]=> + int(0) + [u"primary_key"]=> + int(0) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(1) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(3) "int" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} +done! diff --git a/ext/mysql/tests/mysql_fetch_lengths.phpt b/ext/mysql/tests/mysql_fetch_lengths.phpt new file mode 100644 index 0000000000..32c6ea9094 --- /dev/null +++ b/ext/mysql/tests/mysql_fetch_lengths.phpt @@ -0,0 +1,48 @@ +--TEST-- +mysql_fetch_lengths() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(2) { + [0]=> + int(1) + [1]=> + int(1) +} +bool(false) + +Warning: mysql_fetch_lengths(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_fetch_object.phpt b/ext/mysql/tests/mysql_fetch_object.phpt new file mode 100644 index 0000000000..cc20f738b0 --- /dev/null +++ b/ext/mysql/tests/mysql_fetch_object.phpt @@ -0,0 +1,217 @@ +--TEST-- +mysql_fetch_object() +--SKIPIF-- + +--FILE-- +a = $a; + $this->b = $b; + } + +} + +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', null)); +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a'))); +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b'))); +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b', 'c'))); +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', "no array and not null")); +var_dump(mysql_fetch_object($res)); +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b'))); + +class mysql_fetch_object_private_construct { + private function __construct($a, $b) { + var_dump($a); + } +} +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_private_construct', array('a', 'b'))); + +mysql_free_result($res); + +if (!$res = mysql_query("SELECT id AS ID, label FROM test AS TEST", $link)) { + printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link)); +} + +mysql_free_result($res); + +var_dump(mysql_fetch_object($res)); + +// Fatal error, script execution will end +var_dump(mysql_fetch_object($res, 'this_class_does_not_exist')); + +mysql_close($link); +print "done!"; +?> +--EXPECTF-- +object(stdClass)#%d (2) { + ["ID"]=> + string(1) "1" + ["label"]=> + string(1) "a" +} +object(mysql_fetch_object_test)#%d (4) { + ["a"]=> + NULL + ["b"]=> + NULL + ["ID"]=> + string(1) "2" + ["label"]=> + string(1) "b" +} + +Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d + +Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d + +Notice: Undefined variable: a in %s on line %d + +Notice: Undefined variable: b in %s on line %d +object(mysql_fetch_object_construct)#%d (4) { + ["a"]=> + NULL + ["b"]=> + NULL + ["ID"]=> + string(1) "3" + ["label"]=> + string(1) "c" +} + +Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d + +Notice: Undefined variable: b in %s on line %d +object(mysql_fetch_object_construct)#%d (4) { + ["a"]=> + string(1) "a" + ["b"]=> + NULL + ["ID"]=> + string(1) "4" + ["label"]=> + string(1) "d" +} +object(mysql_fetch_object_construct)#%d (4) { + ["a"]=> + string(1) "a" + ["b"]=> + string(1) "b" + ["ID"]=> + string(1) "5" + ["label"]=> + string(1) "e" +} +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d +bool(false) + +Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d +--UEXPECTF-- +object(stdClass)#%d (2) { + [u"ID"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" +} +object(mysql_fetch_object_test)#%d (4) { + [u"a"]=> + NULL + [u"b"]=> + NULL + [u"ID"]=> + unicode(1) "2" + [u"label"]=> + unicode(1) "b" +} + +Warning: Missing argument 1 for mysql_fetch_object_construct::__construct() in %s on line %d + +Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d + +Notice: Undefined variable: a in %s on line %d + +Notice: Undefined variable: b in %s on line %d +object(mysql_fetch_object_construct)#%d (4) { + [u"a"]=> + NULL + [u"b"]=> + NULL + [u"ID"]=> + unicode(1) "3" + [u"label"]=> + unicode(1) "c" +} + +Warning: Missing argument 2 for mysql_fetch_object_construct::__construct() in %s on line %d + +Notice: Undefined variable: b in %s on line %d +object(mysql_fetch_object_construct)#%d (4) { + [u"a"]=> + unicode(1) "a" + [u"b"]=> + NULL + [u"ID"]=> + unicode(1) "4" + [u"label"]=> + unicode(1) "d" +} +object(mysql_fetch_object_construct)#%d (4) { + [u"a"]=> + unicode(1) "a" + [u"b"]=> + unicode(1) "b" + [u"ID"]=> + unicode(1) "5" + [u"label"]=> + unicode(1) "e" +} +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d +bool(false) + +Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d diff --git a/ext/mysql/tests/mysql_fetch_row.phpt b/ext/mysql/tests/mysql_fetch_row.phpt new file mode 100644 index 0000000000..b98f29c4da --- /dev/null +++ b/ext/mysql/tests/mysql_fetch_row.phpt @@ -0,0 +1,80 @@ +--TEST-- +mysql_fetch_row() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +[004] +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "a" +} +[005] +bool(false) + +Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! +--EXPECTF-- +[004] +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "a" +} +[005] +bool(false) + +Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! +--UEXPECTF-- +[004] +array(2) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "a" +} +[005] +bool(false) + +Warning: mysql_fetch_row(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_field_flags.phpt b/ext/mysql/tests/mysql_field_flags.phpt new file mode 100644 index 0000000000..4a63c907fc --- /dev/null +++ b/ext/mysql/tests/mysql_field_flags.phpt @@ -0,0 +1,147 @@ +--TEST-- +mysql_field_flags() +--SKIPIF-- + +--FILE-- + array( + array('label', '1'), + 'label' => array(($version < 500) ? 'multiple_key' : 'unique_key') + ), + 'labela INT, label2 CHAR(1), KEY keyname (labela, label2)' => array( + array('labela, label2', '1, "a"'), + 'labela' => array('multiple_key'), + ), + 'label1 BLOB' => array( + array('label1', '"blob"'), + 'label1' => array('blob', 'binary'), + ), + 'label1 INT UNSIGNED' => array( + array('label1', '100'), + 'label1' => array('unsigned'), + ), + 'label1 INT UNSIGNED NOT NULL AUTO INCREMENT' => array( + array('label1', '100'), + 'label1' => array('auto_increment', + 'unsigned'), + ), + 'label1 ENUM("a", "b")' => array( + array('label1', '"a"'), + 'label1' => array('enum'), + ), + 'label1 SET("a", "b")' => array( + array('label1', '"a"'), + 'label1' => array('set'), + ), + 'label1 TIMESTAMP' => array( + array('label1', sprintf('"%s"', @date("Y-m-d H:i:s"))), + 'label1' => array( + 'timestamp', + 'unsigned', + 'zerofill', + 'binary', + 'not_null'), + ), +); + +foreach ($tables as $columns => $expected) { + if (!mysql_query("DROP TABLE IF EXISTS test", $link)) { + printf("[010/%s] [%d] %s\n", $columns, mysql_errno($link), mysql_error($link)); + continue; + } + $sql = sprintf("CREATE TABLE test(id INT, %s) ENGINE = %s", $columns, $engine); + if (!@mysql_query($sql, $link)) { + // server or engine might not support this + continue; + } + + reset($expected); + list($k, $values) = each($expected); + $sql = sprintf("INSERT INTO test(id, %s) VALUES (1, %s)", $values[0], $values[1]); + if (!mysql_query($sql, $link)) { + printf("[011/%s] '%s', [%d] %s\n", $columns, $sql, mysql_errno($link), mysql_error($link)); + continue; + } + + if (!$res = mysql_query(sprintf("SELECT id, %s FROM test", $values[0]), $link)) { + printf("[012/%s] [%d] %s\n", $columns, mysql_errno($link), mysql_error($link)); + continue; + } + + $i = 1; + while (list($field, $flags) = each($expected)) { + $tmp = mysql_field_flags($res, $i++); + + foreach ($flags as $k => $flag) { + if (!preg_match(sprintf('@\s*%s\s*@ismU', $flag), $tmp)) { + printf("[013/%s] Field '%s', flag '%s' not found, [%d] %s\n", $columns, $field, $flag, mysql_errno($link), mysql_error($link)); + } + } + foreach ($flags as $k => $flag) { + $tmp = preg_replace(sprintf('@\s*%s\s*@ismU', $flag), '', $tmp); + } + if ('' != $tmp) + printf("[014/%s] Field '%s', unexpected flags '%s' found, [%d] %s\n", $columns, $field, $tmp, mysql_errno($link), mysql_error($link)); + } + mysql_free_result($res); +} + +var_dump(mysql_field_flags($res, 0)); + +mysql_close($link); +print "done!"; +?> +--EXPECTF-- +Warning: Wrong parameter count for mysql_field_flags() in %s on line %d + +Warning: mysql_field_flags(): Field -1 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_flags(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_flags(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_field_len.phpt b/ext/mysql/tests/mysql_field_len.phpt new file mode 100644 index 0000000000..76c298112c --- /dev/null +++ b/ext/mysql/tests/mysql_field_len.phpt @@ -0,0 +1,54 @@ +--TEST-- +mysql_field_len() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for mysql_field_len() in %s on line %d + +Warning: mysql_field_len(): Field -1 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_len(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_len(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_field_name.phpt b/ext/mysql/tests/mysql_field_name.phpt new file mode 100644 index 0000000000..c37ba6eb04 --- /dev/null +++ b/ext/mysql/tests/mysql_field_name.phpt @@ -0,0 +1,65 @@ +--TEST-- +mysql_field_name() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for mysql_field_name() in %s on line %d + +Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d +string(2) "id" + +Warning: mysql_field_name(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_name(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! +--UEXPECTF-- +Warning: Wrong parameter count for mysql_field_name() in %s on line %d + +Warning: mysql_field_name(): Field -1 is invalid for MySQL result index %d in %s on line %d +unicode(2) "id" + +Warning: mysql_field_name(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_name(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_field_seek.phpt b/ext/mysql/tests/mysql_field_seek.phpt new file mode 100644 index 0000000000..e5105d984d --- /dev/null +++ b/ext/mysql/tests/mysql_field_seek.phpt @@ -0,0 +1,235 @@ +--TEST-- +mysql_field_seek() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d +bool(false) +object(stdClass)#%d (13) { + ["name"]=> + string(2) "id" + ["table"]=> + string(4) "test" + ["def"]=> + string(0) "" + ["max_length"]=> + int(1) + ["not_null"]=> + int(1) + ["primary_key"]=> + int(1) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(1) + ["blob"]=> + int(0) + ["type"]=> + string(3) "int" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} +bool(true) +object(stdClass)#%d (13) { + ["name"]=> + string(2) "id" + ["table"]=> + string(4) "test" + ["def"]=> + string(0) "" + ["max_length"]=> + int(1) + ["not_null"]=> + int(1) + ["primary_key"]=> + int(1) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(1) + ["blob"]=> + int(0) + ["type"]=> + string(3) "int" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} +bool(true) +object(stdClass)#%d (13) { + ["name"]=> + string(5) "label" + ["table"]=> + string(4) "test" + ["def"]=> + string(0) "" + ["max_length"]=> + int(1) + ["not_null"]=> + int(0) + ["primary_key"]=> + int(0) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(0) + ["blob"]=> + int(0) + ["type"]=> + string(6) "string" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} + +Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d +bool(false) +bool(false) + +Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! +--UEXPECTF-- +Warning: mysql_field_seek(): Field -1 is invalid for MySQL result index %d in %s on line %d +bool(false) +object(stdClass)#%d (13) { + [u"name"]=> + unicode(2) "id" + [u"table"]=> + unicode(4) "test" + [u"def"]=> + unicode(0) "" + [u"max_length"]=> + int(1) + [u"not_null"]=> + int(1) + [u"primary_key"]=> + int(1) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(1) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(3) "int" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} +bool(true) +object(stdClass)#%d (13) { + [u"name"]=> + unicode(2) "id" + [u"table"]=> + unicode(4) "test" + [u"def"]=> + unicode(0) "" + [u"max_length"]=> + int(1) + [u"not_null"]=> + int(1) + [u"primary_key"]=> + int(1) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(1) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(3) "int" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} +bool(true) +object(stdClass)#%d (13) { + [u"name"]=> + unicode(5) "label" + [u"table"]=> + unicode(4) "test" + [u"def"]=> + unicode(0) "" + [u"max_length"]=> + int(1) + [u"not_null"]=> + int(0) + [u"primary_key"]=> + int(0) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(0) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(6) "string" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} + +Warning: mysql_field_seek(): Field %d is invalid for MySQL result index %d in %s on line %d +bool(false) +bool(false) + +Warning: mysql_field_seek(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! diff --git a/ext/mysql/tests/mysql_field_table.phpt b/ext/mysql/tests/mysql_field_table.phpt new file mode 100644 index 0000000000..e82ac13abc --- /dev/null +++ b/ext/mysql/tests/mysql_field_table.phpt @@ -0,0 +1,65 @@ +--TEST-- +mysql_field_table() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for mysql_field_table() in %s on line %d + +Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d +string(4) "test" + +Warning: mysql_field_table(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_table(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! +--UEXPECTF-- +Warning: Wrong parameter count for mysql_field_table() in %s on line %d + +Warning: mysql_field_table(): Field -1 is invalid for MySQL result index %d in %s on line %d +unicode(4) "test" + +Warning: mysql_field_table(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_table(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_field_type.phpt b/ext/mysql/tests/mysql_field_type.phpt new file mode 100644 index 0000000000..61d8425fe7 --- /dev/null +++ b/ext/mysql/tests/mysql_field_type.phpt @@ -0,0 +1,65 @@ +--TEST-- +mysql_field_type() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: Wrong parameter count for mysql_field_type() in %s on line %d + +Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d +string(3) "int" + +Warning: mysql_field_type(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_type(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! +--UEXPECTF-- +Warning: Wrong parameter count for mysql_field_type() in %s on line %d + +Warning: mysql_field_type(): Field -1 is invalid for MySQL result index %d in %s on line %d +unicode(3) "int" + +Warning: mysql_field_type(): Field 2 is invalid for MySQL result index %d in %s on line %d + +Warning: mysql_field_type(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file diff --git a/ext/mysql/tests/mysql_free_result.phpt b/ext/mysql/tests/mysql_free_result.phpt new file mode 100644 index 0000000000..95e5656a4f --- /dev/null +++ b/ext/mysql/tests/mysql_free_result.phpt @@ -0,0 +1,47 @@ +--TEST-- +mysql_free_result() +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: mysql_free_result(): %d is not a valid MySQL result resource in %s on line %d +bool(false) +done! \ No newline at end of file