Author: uwendel
Date: 2007-10-17 16:16:45 +0200 (Wed, 17 Oct 2007)
New Revision: 1108
Added:
trunk/tests/ext/pdo_mysql/pdo_mysql_class_constants.phpt
Log:
Checking class constants which can be used when connecting to MySQL
- the counterpart to mysql_option() stuff
Added: trunk/tests/ext/pdo_mysql/pdo_mysql_class_constants.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_mysql_class_constants.phpt 2007-10-17 13:25:43 UTC (rev
1107)
+++ trunk/tests/ext/pdo_mysql/pdo_mysql_class_constants.phpt 2007-10-17 14:16:45 UTC (rev
1108)
@@ -0,0 +1,73 @@
+--TEST--
+PDO MySQL specific class constants
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+ $expected = array(
+ 'MYSQL_ATTR_USE_BUFFERED_QUERY' => true,
+ 'MYSQL_ATTR_LOCAL_INFILE' => true,
+ 'MYSQL_ATTR_INIT_COMMAND' => true,
+ 'MYSQL_ATTR_READ_DEFAULT_FILE' => true,
+ 'MYSQL_ATTR_READ_DEFAULT_GROUP' => true,
+ 'MYSQL_ATTR_MAX_BUFFER_SIZE' => true,
+ 'MYSQL_ATTR_DIRECT_QUERY' => true,
+ );
+
+ /*
+ TODO
+
+ MYSQLI_OPT_CONNECT_TIMEOUT != PDO::ATTR_TIMEOUT (integer)
+ Sets the timeout value in seconds for communications with the database.
+ ^ Potential BUG, PDO::ATTR_TIMEOUT is used in pdo_mysql_handle_factory
+
+ MYSQLI_SET_CHARSET_NAME -> DSN/charset=<charset_name>
+ ^ Undocumented and pitfall for ext/mysqli users
+
+ Assorted mysqlnd settings missing
+ */
+ $ref = new ReflectionClass('PDO');
+ $constants = $ref->getConstants();
+ $values = array();
+
+ foreach ($constants as $name => $value)
+ if (substr($name, 0, 11) == 'MYSQL_ATTR_') {
+ if (!isset($values[$value]))
+ $values[$value] = array($name);
+ else
+ $values[$value][] = $name;
+
+ if (isset($expected[$name])) {
+ unset($expected[$name]);
+ unset($constants[$name]);
+ }
+
+ } else {
+ unset($constants[$name]);
+ }
+
+ if (!empty($constants)) {
+ printf("[001] Dumping list of unexpected constants\n");
+ var_dump($constants);
+ }
+
+ if (!empty($expected)) {
+ printf("[002] Dumping list of missing constants\n");
+ var_dump($expected);
+ }
+
+ if (!empty($values)) {
+ foreach ($values as $value => $constants) {
+ if (count($constants) > 1) {
+ printf("[003] Several constants share the same value '%s'\n", $value);
+ var_dump($constants);
+ }
+ }
+ }
+
+ print "done!";
+--EXPECT--
+done!
\ No newline at end of file
| Thread |
|---|
| • PHP mysqlnd svn commit: r1108 - trunk/tests/ext/pdo_mysql | uwendel | 17 Oct |