List:Commits« Previous MessageNext Message »
From:uwendel Date:July 2 2007 6:26pm
Subject:PHP mysqlnd svn commit: r587 - trunk/tests/ext/mysqli
View as plain text  
Author: uwendel
Date: 2007-07-02 20:26:10 +0200 (Mon, 02 Jul 2007)
New Revision: 587

Modified:
   trunk/tests/ext/mysqli/mysqli_fetch_array.phpt
Log:
Trying not to rely on "introspection" or to be more precise mysql field type flags when
checking expected return values.
Test is not working properly, committing to discuss it with Andrey.



Modified: trunk/tests/ext/mysqli/mysqli_fetch_array.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_fetch_array.phpt	2007-07-02 17:40:01 UTC (rev 586)
+++ trunk/tests/ext/mysqli/mysqli_fetch_array.phpt	2007-07-02 18:26:10 UTC (rev 587)
@@ -66,7 +66,7 @@
     
     mysqli_free_result($res);
     
-    function func_mysqli_fetch_array($link, $engine, $sql_type, $sql_value, $php_value,
$offset, $regexp_comparison = NULL) {
+    function func_mysqli_fetch_array($link, $engine, $sql_type, $sql_value, $php_value,
$offset, $regexp_comparison = NULL, $binary_type = false) {
         
         if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
             printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link),
mysqli_error($link));            
@@ -103,27 +103,41 @@
             printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link),
mysqli_error($link));
             return false;
         }
-		$fields = mysqli_fetch_fields($res);
+		
 
-		if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) {
-        	if ($regexp_comparison) {
-            	if (!preg_match($regexp_comparison, (string)$row['label']) ||
!preg_match($regexp_comparison, (string)$row[1])) {
-                	printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s.
[%d] %s\n", $offset + 4, 
-                    gettype($php_value), $php_value, $regexp_comparison,
+		
+      	if ($regexp_comparison) {
+          	if (!preg_match($regexp_comparison, (string)$row['label']) ||
!preg_match($regexp_comparison, (string)$row[1])) {
+              	printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d]
%s\n", $offset + 4, 
+                  gettype($php_value), $php_value, $regexp_comparison,
+                  gettype($row[1]), $row[1],
+                  gettype($row['label']), $row['label'], mysqli_errno($link),
mysqli_error($link));
+	              return false;
+           }
+           
+      	} else if ((gettype($php_value) == 'unicode') && $binary_type) {
+            // Unicode is on and we are told that the MySQL column type is a binary type.
+            // Don't expect a unicode value from the database, you'll get binary string  
          
+            if (($row['label'] != $php_value) || ($row[1] != $php_value)) {
+                printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n",
$offset + 5, 
+                    gettype($php_value), $php_value,
                     gettype($row[1]), $row[1],
                     gettype($row['label']), $row['label'], mysqli_errno($link),
mysqli_error($link));
-	                return false;
-    	        }
-            
-        	} else {
-            	if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
-                	printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n",
$offset + 4, 
+                return false;
+            }
+            if (gettype($row['label']) == 'unicode') {
+                printf("[%04d] SQL Type: '%s', binary columns are supposed to return
binary string and not unicode\n",
+                    $offset + 6, $sql_type);
+                return false;
+            }
+      	} else {      	    
+          	if (($row['label'] !== $php_value) || ($row[1] != $php_value)) {
+               	printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n",
$offset + 7, 
                     gettype($php_value), $php_value,
                     gettype($row[1]), $row[1],
                     gettype($row['label']), $row['label'], mysqli_errno($link),
mysqli_error($link));
-                	return false;
-            	}
-        	}
+                return false;
+            }       
         }
         return true;
     }
@@ -222,44 +236,44 @@
     func_mysqli_fetch_array($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
     func_mysqli_fetch_array($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
     
-    func_mysqli_fetch_array($link, $engine, "BINARY(1)", "a", "a", 630);
-    func_mysqli_fetch_array($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a",
640);
-    func_mysqli_fetch_array($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650);
-    func_mysqli_fetch_array($link, $engine, "BINARY(1)", NULL, NULL, 660);
+    func_mysqli_fetch_array($link, $engine, "BINARY(1)", "a", "a", 630, null, true);
+    func_mysqli_fetch_array($link, $engine, "BINARY(2)", chr(0) . "a", chr(0) . "a", 640,
null, true);
+    func_mysqli_fetch_array($link, $engine, "BINARY(1) NOT NULL", "b", "b", 650, null,
true);
+    func_mysqli_fetch_array($link, $engine, "BINARY(1)", NULL, NULL, 660, null, true);
     
-    func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", "a", "a", 670);
-    func_mysqli_fetch_array($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a",
680);
-    func_mysqli_fetch_array($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690);
-    func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", NULL, NULL, 700);
+    func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", "a", "a", 670, null, true);
+    func_mysqli_fetch_array($link, $engine, "VARBINARY(2)", chr(0) . "a", chr(0) . "a",
680, null, true);
+    func_mysqli_fetch_array($link, $engine, "VARBINARY(1) NOT NULL", "b", "b", 690, null,
true);
+    func_mysqli_fetch_array($link, $engine, "VARBINARY(1)", NULL, NULL, 700, null, true);
     
-    func_mysqli_fetch_array($link, $engine, "TINYBLOB", "a", "a", 710);
-    func_mysqli_fetch_array($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720);
-    func_mysqli_fetch_array($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730); 
-    func_mysqli_fetch_array($link, $engine, "TINYBLOB", NULL, NULL, 740);
+    func_mysqli_fetch_array($link, $engine, "TINYBLOB", "a", "a", 710, null, true);
+    func_mysqli_fetch_array($link, $engine, "TINYBLOB", chr(0) . "a", chr(0) . "a", 720,
null, true);
+    func_mysqli_fetch_array($link, $engine, "TINYBLOB NOT NULL", "b", "b", 730, null,
true); 
+    func_mysqli_fetch_array($link, $engine, "TINYBLOB", NULL, NULL, 740, null, true);
     
     func_mysqli_fetch_array($link, $engine, "TINYTEXT", "a", "a", 750);
     func_mysqli_fetch_array($link, $engine, "TINYTEXT NOT NULL", "a", "a", 760);
     func_mysqli_fetch_array($link, $engine, "TINYTEXT", NULL, NULL, 770);
     
-    func_mysqli_fetch_array($link, $engine, "BLOB", "a", "a", 780);
-    func_mysqli_fetch_array($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780);
-    func_mysqli_fetch_array($link, $engine, "BLOB", NULL, NULL, 790);
+    func_mysqli_fetch_array($link, $engine, "BLOB", "a", "a", 780, null, true);
+    func_mysqli_fetch_array($link, $engine, "BLOB", chr(0) . "a", chr(0) . "a", 780,
null, true);
+    func_mysqli_fetch_array($link, $engine, "BLOB", NULL, NULL, 790, null, true);
        
     func_mysqli_fetch_array($link, $engine, "TEXT", "a", "a", 800);
     func_mysqli_fetch_array($link, $engine, "TEXT", chr(0) . "a", chr(0) . "a", 810);
     func_mysqli_fetch_array($link, $engine, "TEXT", NULL, NULL, 820);
     
-    func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", "a", "a", 830);
-    func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a",
840);
-    func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", NULL, NULL, 850);
+    func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", "a", "a", 830, null, true);
+    func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", chr(0) . "a", chr(0) . "a",
840, null, true);
+    func_mysqli_fetch_array($link, $engine, "MEDIUMBLOB", NULL, NULL, 850, null, true);
     
     func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", "a", "a", 860);
     func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", chr(0) . "a", chr(0) . "a",
870);
     func_mysqli_fetch_array($link, $engine, "MEDIUMTEXT", NULL, NULL, 880);
     
-    func_mysqli_fetch_array($link, $engine, "LONGBLOB", "a", "a", 890);
+    func_mysqli_fetch_array($link, $engine, "LONGBLOB", "a", "a", 890, null, true);
     func_mysqli_fetch_array($link, $engine, "LONGTEXT", chr(0) . "a", chr(0) . "a", 900);
-    func_mysqli_fetch_array($link, $engine, "LONGBLOB", NULL, NULL, 910);
+    func_mysqli_fetch_array($link, $engine, "LONGBLOB", NULL, NULL, 910, null, true);
     
     func_mysqli_fetch_array($link, $engine, "ENUM('a', 'b')", "a", "a", 920);
     func_mysqli_fetch_array($link, $engine, "ENUM('a', 'b')", NULL, NULL, 930);

Thread
PHP mysqlnd svn commit: r587 - trunk/tests/ext/mysqliuwendel2 Jul