PHP  
 PHP_5_4
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/mysql/tests/mysql_field_flags.phpt ('mysql_field_flags()')

Script

1: <?php
2:
include "connect.inc";
3:
4:
$tmp    NULL;
5:
$link   NULL;
6:
7: if (!
is_null($tmp = @mysql_field_flags()))
8:     
printf("[001] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
9:
10: if (
null !== ($tmp = @mysql_field_flags($link)))
11:     
printf("[002] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
12:
13: require(
'table.inc');
14: if (!
$res mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2"$link)) {
15:     
printf("[003] [%d] %s\n"mysql_errno($link), mysql_error($link));
16: }
17:
18: if (
NULL !== ($tmp mysql_field_flags($res)))
19:     
printf("[004] Expecting NULL, got %s/%s\n"gettype($tmp), $tmp);
20:
21: if (
false !== ($tmp mysql_field_flags($res, -1)))
22:     
printf("[005] Expecting boolean/false, got %s/%s\n"gettype($tmp), $tmp);
23:
24: if (!
is_string($tmp mysql_field_flags($res0)) || empty($tmp))
25:     
printf("[006] Expecting non empty string, got %s/%s\n"gettype($tmp), $tmp);
26:
27: if ((
version_compare(PHP_VERSION'5.9.9''>') == 1) && !is_unicode($tmp)) {
28:     
printf("[007] Check the unicode support!\n");
29:     
var_inspect($tmp);
30: }
31:
32: if (
false !== ($tmp mysql_field_flags($res2)))
33:     
printf("[008] Expecting boolean/false, got %s/%s\n"gettype($tmp), $tmp);
34:
35:
mysql_free_result($res);
36:
37:
$version mysql_get_server_info($link);
38: if (!
preg_match('@(\d+)\.(\d+)\.(\d+)@ism'$version$matches))
39:     
printf("[009] Cannot get server version\n");
40:
$version = ($matches[1] * 100) + ($matches[2] * 10) + $matches[3];
41:
42:
$tables = array(
43:     
'label INT, UNIQUE KEY (label)'                         =>  array(
44:                                 array(
'label''1'),
45:                                 
'label' => array(($version 500) ? 'multiple_key' 'unique_key')
46:                                 ),
47:     
'labela INT, label2 CHAR(1), KEY keyname (labela, label2)'      =>  array(
48:                                 array(
'labela, label2'"1, 'a'"),
49:                                 
'labela' => array('multiple_key'),
50:                                 ),
51:     
'label1 BLOB'                                           =>  array(
52:                                 array(
'label1'"'blob'"),
53:                                 
'label1' => array('blob''binary'),
54:                                 ),
55:     
'label1 INT UNSIGNED'                                   =>  array(
56:                                 array(
'label1''100'),
57:                                 
'label1' => array('unsigned'),
58:                                 ),
59:     
'label1 INT UNSIGNED NOT NULL AUTO INCREMENT'           =>  array(
60:                                 array(
'label1''100'),
61:                                 
'label1' => array('auto_increment',
62:                                         
'unsigned'),
63:                                 ),
64:     
'label1 ENUM("a", "b")'                                 =>  array(
65:                                 array(
'label1'"'a'"),
66:                                 
'label1' => array('enum'),
67:                                 ),
68:     
'label1 SET("a", "b")'                                  =>  array(
69:                                 array(
'label1'"'a'"),
70:                                 
'label1' => array('set'),
71:                                 ),
72:     
'label1 TIMESTAMP'                                      =>  array(
73:                                 array(
'label1'sprintf("'%s'", @date("Y-m-d H:i:s"))),
74:                                 
'label1' => array(
75:                                         
'timestamp',
76:                                         
'binary',
77:                                         
'not_null'),
78:                                 ),
79: );
80:
81: if (
$version 560) {
82:     
$tables['label1 TIMESTAMP']['label1'][] = 'zerofill';
83:     
$tables['label1 TIMESTAMP']['label1'][] = 'unsigned';
84: }
85:
86:
87: foreach (
$tables as $columns => $expected) {
88:     if (!
mysql_query("DROP TABLE IF EXISTS test"$link)) {
89:         
printf("[010/%s] [%d] %s\n"$columnsmysql_errno($link), mysql_error($link));
90:         continue;
91:     }
92:     
$sql sprintf("CREATE TABLE test(id INT, %s) ENGINE = %s"$columns$engine);
93:         if (!@
mysql_query($sql$link)) {
94:         
// server or engine might not support this
95:         
continue;
96:     }
97:
98:     
reset($expected);
99:     list(
$k$values) = each($expected);
100:     
$sql sprintf("INSERT INTO test(id, %s) VALUES (1, %s)"$values[0], $values[1]);
101:     if (!
mysql_query($sql$link)) {
102:         
printf("[011/%s] '%s', [%d] %s\n"$columns$sqlmysql_errno($link), mysql_error($link));
103:         continue;
104:     }
105:
106:     if (!
$res mysql_query(sprintf("SELECT id, %s FROM test"$values[0]), $link)) {
107:         
printf("[012/%s] [%d] %s\n"$columnsmysql_errno($link), mysql_error($link));
108:         continue;
109:     }
110:
111:     
$i 1;
112:     while (list(
$field$flags) = each($expected)) {
113:         
$tmp mysql_field_flags($res$i++);
114:
115:         foreach (
$flags as $k => $flag) {
116:         if (!
preg_match(sprintf('@\s*%s\s*@ismU'$flag), $tmp)) {
117:             
printf("[013/%s] Field '%s', flag '%s' not found, [%d] %s\n"$columns$field$flagmysql_errno($link), mysql_error($link));
118:         }
119:     }
120:         foreach (
$flags as $k => $flag) {
121:             
$tmp preg_replace(sprintf('@\s*%s\s*@ismU'$flag), ''$tmp);
122:         }
123:         if (
'' != $tmp)
124:             
printf("[014/%s] Field '%s', unexpected flags '%s' found, [%d] %s\n"$columns$field$tmpmysql_errno($link), mysql_error($link));
125:     }
126:     
mysql_free_result($res);
127: }
128:
129:
var_dump(mysql_field_flags($res0));
130:
131:
mysql_close($link);
132: print 
"done!";
133:
?>
134:

Expected

Warning: mysql_field_flags() expects exactly 2 parameters, 1 given 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!

Output

Warning: mysql_field_flags() expects exactly 2 parameters, 1 given in /var/php_gcov/PHP_5_4/ext/mysql/tests/mysql_field_flags.php on line 18

Warning: mysql_field_flags(): Field -1 is invalid for MySQL result index 8 in /var/php_gcov/PHP_5_4/ext/mysql/tests/mysql_field_flags.php on line 21

Warning: mysql_field_flags(): Field 2 is invalid for MySQL result index 8 in /var/php_gcov/PHP_5_4/ext/mysql/tests/mysql_field_flags.php on line 32
[014/label1 TIMESTAMP] Field 'label1', unexpected flags ' unsigned zerofill' found, [0] 

Warning: mysql_field_flags(): 15 is not a valid MySQL result resource in /var/php_gcov/PHP_5_4/ext/mysql/tests/mysql_field_flags.php on line 129
bool(false)
done!

Diff

006+ [014/label1 TIMESTAMP] Field 'label1', unexpected flags ' unsigned zerofill' found, [0] 

 

Generated at Sat, 23 Aug 2014 22:39:52 +0000 (3 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.