]> granicus.if.org Git - php/commitdiff
Improving test to reflect latest API changes
authorUlf Wendel <uw@php.net>
Thu, 3 Nov 2011 17:39:39 +0000 (17:39 +0000)
committerUlf Wendel <uw@php.net>
Thu, 3 Nov 2011 17:39:39 +0000 (17:39 +0000)
ext/mysqli/tests/mysqli_class_mysqli_interface.phpt

index d54d951c10994b73826d799cc482d6a6ffd59111..c6d4e7cc328e50716dbfe1092b2012916dc7de92 100644 (file)
@@ -56,6 +56,11 @@ require_once('skipifconnectfailure.inc');
                'thread_safe'                   => true,
                'use_result'                    => true,
        );
+
+       if (version_compare(PHP_VERSION, '5.3.99', '<=')) {
+               $expected_methods['client_encoding'] = true;
+       }
+
        if ($IS_MYSQLND) {
                // mysqlnd only
                /* $expected_methods['get_client_stats']        = true; */
@@ -94,15 +99,70 @@ require_once('skipifconnectfailure.inc');
                printf("ok\n");
 
        printf("\nClass variables:\n");
-       $variables = array_keys(get_class_vars(get_class($mysqli)));
-       sort($variables);
-       foreach ($variables as $k => $var)
-               printf("%s\n", $var);
+
+       $expected_class_variables = $expected_object_variables = array(
+               "affected_rows"         => true,
+               "client_info"           => true,
+               "client_version"        => true,
+               "connect_errno"         => true,
+               "connect_error"         => true,
+               "errno"                         => true,
+               "error"                         => true,
+               "field_count"           => true,
+               "host_info"                     => true,
+               "info"                          => true,
+               "insert_id"                     => true,
+               "protocol_version"      => true,
+               "server_info"           => true,
+               "server_version"        => true,
+               "sqlstate"                      => true,
+               "stat"                          => true,
+               "thread_id"                     => true,
+               "warning_count"         => true,
+       );
+
+       if (version_compare(PHP_VERSION, '5.3.99', '>')) {
+         $expected_class_variables["error_list"] = true;
+         $expected_object_variables["error_list"] = true;
+       }
+
+       $variables = get_class_vars(get_class($mysqli));
+       foreach ($variables as $var => $v) {
+               if (isset($expected_class_variables[$var])) {
+                       unset($expected_class_variables[$var]);
+                       unset($variables[$var]);
+               }
+       }
+
+       if (!empty($expected_class_variables)) {
+         printf("Dumping list of missing class variables\n");
+         var_dump($expected_class_variables);
+       }
+       if (!empty($variables)) {
+         printf("Dumping list of unexpected class variables\n");
+         var_dump($variables);
+       }
+       echo "ok\n";
 
        printf("\nObject variables:\n");
-       $variables = array_keys(get_object_vars($mysqli));
-       foreach ($variables as $k => $var)
-               printf("%s\n", $var);
+       $variables = get_object_vars($mysqli);
+       foreach ($variables as $var => $v) {
+               if (isset($expected_object_variables[$var])) {
+                       unset($expected_object_variables[$var]);
+                       unset($variables[$var]);
+               }
+       }
+
+       if (!empty($expected_object_variables)) {
+         printf("Dumping list of missing object variables\n");
+         var_dump($expected_object_variables);
+       }
+       if (!empty($variables)) {
+         printf("Dumping list of unexpected object variables\n");
+         var_dump($variables);
+       }
+       echo "ok\n";
+
 
        printf("\nMagic, magic properties:\n");
 
@@ -131,10 +191,10 @@ require_once('skipifconnectfailure.inc');
                $mysqli->error, gettype($mysqli->error),
                mysqli_error($link), gettype(mysqli_error($link)));
 
-       assert(mysqli_error_list($link) === $mysqli->error_list);
-       printf("mysqli->error_list = '%s'/%s ('%s'/%s)\n",
-               $mysqli->error_list, gettype($mysqli->error_list),
-               mysqli_error_list($link), gettype(mysqli_error_list($link)));
+       if (version_compare(PHP_VERSION, '5.3.99', '>')) {
+               assert(mysqli_error_list($link) === $mysqli->error_list);
+               assert(is_array($mysqli->error_list));
+       }
 
        assert(mysqli_field_count($link) === $mysqli->field_count);
        printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n",
@@ -225,46 +285,10 @@ Methods:
 ok
 
 Class variables:
-affected_rows
-client_info
-client_version
-connect_errno
-connect_error
-errno
-error
-error_list
-field_count
-host_info
-info
-insert_id
-protocol_version
-server_info
-server_version
-sqlstate
-stat
-thread_id
-warning_count
+ok
 
 Object variables:
-affected_rows
-client_info
-client_version
-connect_errno
-connect_error
-errno
-error
-error_list
-field_count
-host_info
-info
-insert_id
-server_info
-server_version
-stat
-sqlstate
-protocol_version
-thread_id
-warning_count
+ok
 
 Magic, magic properties:
 mysqli->affected_rows = '%s'/integer ('%s'/integer)
@@ -272,7 +296,6 @@ mysqli->client_info = '%s'/%unicode|string% ('%s'/%unicode|string%)
 mysqli->client_version =  '%d'/integer ('%d'/integer)
 mysqli->errno = '0'/integer ('0'/integer)
 mysqli->error = ''/%unicode|string% (''/%unicode|string%)
-mysqli->error_list = 'Array'/array ('Array'/array)
 mysqli->field_count = '0'/integer ('0'/integer)
 mysqli->insert_id = '0'/integer ('0'/integer)
 mysqli->sqlstate = '00000'/%unicode|string% ('00000'/%unicode|string%)