uw              Wed Oct 10 10:04:46 2007 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/mysqli/tests   local_infile_tools.inc 
                                reflection_tools.inc 
                                skipifconnectfailure.inc 
                                skipifunicode.inc table.inc 

  Modified files:              
    /php-src/ext/mysqli/tests   connect.inc skipifemb.inc skipif.inc 
                                skipifnotemb.inc 
  Log:
  Starting to merge updated set of tests into 5.3. 
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/connect.inc?r1=1.6.2.1.2.2&r2=1.6.2.1.2.2.2.1&diff_format=u
Index: php-src/ext/mysqli/tests/connect.inc
diff -u php-src/ext/mysqli/tests/connect.inc:1.6.2.1.2.2 
php-src/ext/mysqli/tests/connect.inc:1.6.2.1.2.2.2.1
--- php-src/ext/mysqli/tests/connect.inc:1.6.2.1.2.2    Tue Jul 11 23:43:55 2006
+++ php-src/ext/mysqli/tests/connect.inc        Wed Oct 10 10:04:46 2007
@@ -1,25 +1,54 @@
 <?php
+       /*
+       Default values are "localhost", "root",
+       database "phptest" and empty password.
+       Change the MYSQL_TEST environment values
+       if you want to use another configuration
+       */
 
-  /* default values are localhost, root and empty password 
-     Change the values if you use another configuration   */
-       $driver = new mysqli_driver;
-
-       if (!$driver->embedded) {
-               $host = "localhost";
-               $user = "root";
-               $passwd = "";
+       $driver    = new mysqli_driver;
+
+       $host      = getenv("MYSQL_TEST_HOST")     ? getenv("MYSQL_TEST_HOST") 
: "localhost";
+       $port      = getenv("MYSQL_TEST_PORT")     ? getenv("MYSQL_TEST_PORT") 
: 3306;
+       $user      = getenv("MYSQL_TEST_USER")     ? getenv("MYSQL_TEST_USER") 
: "root";
+       $passwd    = getenv("MYSQL_TEST_PASSWD")   ? 
getenv("MYSQL_TEST_PASSWD") : "";
+       $db        = getenv("MYSQL_TEST_DB")       ? getenv("MYSQL_TEST_DB") : 
"phptest";
+       $engine    = getenv("MYSQL_TEST_ENGINE")   ? 
getenv("MYSQL_TEST_ENGINE") : "MyISAM";
+       $socket    = getenv("MYSQL_TEST_SOCKET")   ? 
getenv("MYSQL_TEST_SOCKET") : null;
+
+       /* Development setting: test experimal features and/or feature requests 
that never worked before? */
+       $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), 
array(0, 1))) ?
+                               ((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? 
true : false) :
+                               false;
+
+       $IS_MYSQLND = stristr(mysqli_get_client_info(), "mysqlnd");
+       if (!$IS_MYSQLND) {
+               $MYSQLND_VERSION = NULL;
        } else {
-               $path =  dirname(__FILE__);
-               $host = ":embedded";
-               $user = $passwd = NULL;
-               $args = array(
-                                       "--datadir=$path", 
-                                       "--innodb_data_home_dir=$path",
-                                       
"--innodb_data_file_path=ibdata1:10M:autoextend",
-                                       "--log-error=$path/testrun.log",
-                                        "--init-connect='CREATE DATABASE IF 
NOT EXISTS test;'"
-                               );
-               $driver->embedded_server_start(TRUE, $args, NULL);
+               if (preg_match('@Revision:\s+(\d+)[EMAIL PROTECTED]', 
mysqli_get_client_info(), $matches)) {
+                       $MYSQLND_VERSION = (int)$matches[1];
+               } else {
+                       $MYSQLND_VERSION = -1;
+               }
        }
 
-?>
+       if (!function_exists('sys_get_temp_dir')) {
+               function sys_get_temp_dir() {
+
+                       if (!empty($_ENV['TMP']))
+                               return realpath( $_ENV['TMP'] );
+                       if (!empty($_ENV['TMPDIR']))
+                               return realpath( $_ENV['TMPDIR'] );
+                       if (!empty($_ENV['TEMP']))
+                               return realpath( $_ENV['TEMP'] );
+
+                       $temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
+                       if ($temp_file) {
+                               $temp_dir = realpath(dirname($temp_file));
+                               unlink($temp_file);
+                               return $temp_dir;
+                       }
+                       return FALSE;
+               }
+       }
+?>
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/skipifemb.inc?r1=1.1&r2=1.1.6.1&diff_format=u
Index: php-src/ext/mysqli/tests/skipifemb.inc
diff -u php-src/ext/mysqli/tests/skipifemb.inc:1.1 
php-src/ext/mysqli/tests/skipifemb.inc:1.1.6.1
--- php-src/ext/mysqli/tests/skipifemb.inc:1.1  Fri Jan  7 14:59:59 2005
+++ php-src/ext/mysqli/tests/skipifemb.inc      Wed Oct 10 10:04:46 2007
@@ -1,5 +1,5 @@
 <?php
-  $driver = new mysqli_driver();
-  if ($driver->embedded) 
-    die("skip test doesn't run with embedded server");
-?>
+       $driver = new mysqli_driver();
+       if ($driver->embedded)
+               die("skip test doesn't run with embedded server");
+?>
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/skipif.inc?r1=1.5.4.1&r2=1.5.4.1.2.1&diff_format=u
Index: php-src/ext/mysqli/tests/skipif.inc
diff -u php-src/ext/mysqli/tests/skipif.inc:1.5.4.1 
php-src/ext/mysqli/tests/skipif.inc:1.5.4.1.2.1
--- php-src/ext/mysqli/tests/skipif.inc:1.5.4.1 Tue Dec 12 08:09:40 2006
+++ php-src/ext/mysqli/tests/skipif.inc Wed Oct 10 10:04:46 2007
@@ -2,9 +2,4 @@
 if (!extension_loaded('mysqli')){
        die('skip mysqli extension not available');
 }
-include "connect.inc";
-$driver = new mysqli_driver();
-if (!$driver->embedded && !($con = @mysqli_connect($host, $user, $passwd, "", 
3306))) {
-       die('skip could not connect to MySQL');
-}
-?>
+?>
\ No newline at end of file
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/skipifnotemb.inc?r1=1.1.2.2&r2=1.1.2.2.2.1&diff_format=u
Index: php-src/ext/mysqli/tests/skipifnotemb.inc
diff -u php-src/ext/mysqli/tests/skipifnotemb.inc:1.1.2.2 
php-src/ext/mysqli/tests/skipifnotemb.inc:1.1.2.2.2.1
--- php-src/ext/mysqli/tests/skipifnotemb.inc:1.1.2.2   Tue Jul 11 23:45:28 2006
+++ php-src/ext/mysqli/tests/skipifnotemb.inc   Wed Oct 10 10:04:46 2007
@@ -1,5 +1,5 @@
 <?php
-  $driver = new mysqli_driver();
-  if (!$driver->embedded) 
-    die("skip test for with embedded server only");
-?>
+       $driver = new mysqli_driver();
+       if (!$driver->embedded)
+               die("skip test for with embedded server only");
+?>
\ No newline at end of file

http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/local_infile_tools.inc?view=markup&rev=1.1
Index: php-src/ext/mysqli/tests/local_infile_tools.inc
+++ php-src/ext/mysqli/tests/local_infile_tools.inc
<?php
        /* Utility function for mysqli_set_local_infile*.phpt tests */
        function shutdown_clean($file) {
                if ($file) {
                        unlink($file);
                }
        }

        function create_standard_csv($offset) {
                // create a CVS file
                $file = tempnam(sys_get_temp_dir(), 'mysqli_test');
                if (!$fp = fopen($file, 'w')) {
                        printf("[%03d + 1] Cannot create CVS file '%s'\n", 
$offset, $file);
                        return NULL;
                } else {
                        /* Looks ugly? No, handy if you have crashes... */
                        register_shutdown_function("shutdown_clean", $file);
                }

                if (ini_get('unicode.semantics')) {
                        if (!fwrite($fp, (binary)"'97';'x';\n") ||
                                !fwrite($fp, (binary)"'98';'y';\n") ||
                                !fwrite($fp, (binary)"99;'z';\n")) {
                                printf("[%03d + 2] Cannot write CVS file 
'%s'\n", $offset, $file);
                                return NULL;
                        }
                } else {
                        if (!fwrite($fp, "97;'x';\n") ||
                                !fwrite($fp, "98;'y';\n") ||
                                !fwrite($fp, "99;'z';\n")) {
                                printf("[%03d + 3] Cannot write CVS file 
'%s'\n", $offset, $file);
                                return NULL;
                        }
                }

                fclose($fp);

                if (!chmod($file, 0644)) {
                        printf("[%03d + 4] Cannot change the file perms of '%s' 
from 0600 to 0644, MySQL might not be able to read it\n",
                                $offset, $file);
                        return NULL;
                }
                return $file;
        }

        function try_handler($offset, $link, $file, $handler, $expected = null) 
{

                if ('default' == $handler) {
                        mysqli_set_local_infile_default($link);
                } else if (!mysqli_set_local_infile_handler($link, $handler)) {
                        printf("[%03d] Cannot set infile handler to '%s'\n", 
$offset, $handler);
                        return false;
                }
                printf("Callback set to '%s'\n", $handler);

                if (!mysqli_query($link, sprintf("DELETE FROM test"))) {
                        printf("[%03d] Cannot remove records, [%d] %s\n", 
$offset + 1, mysqli_errno($link), mysqli_error($link));
                        return false;
                }

                if (!mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s'
                        INTO TABLE test
                        FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
                        LINES TERMINATED BY '\n'",
                        mysqli_real_escape_string($link, $file)))) {
                        printf("[%03d] LOAD DATA failed, [%d] %s\n",
                                $offset + 2,
                                mysqli_errno($link), mysqli_error($link));
                }

                if (!$res = mysqli_query($link, "SELECT id, label FROM test 
ORDER BY id")) {
                        printf("[%03d] [%d] %s\n", $offset + 3, 
mysqli_errno($link), mysqli_error($link));
                        return false;
                }

                if (!is_array($expected))
                        return true;

                foreach ($expected as $k => $values) {
                        if (!$tmp = mysqli_fetch_assoc($res)) {
                                printf("[%03d/%d] [%d] '%s'\n", $offset + 4, 
$k, mysqli_errno($link), mysqli_error($link));
                                return false;
                        }
                        if ($values['id'] != $tmp['id']) {
                                printf("[%03d/%d] Expecting %s got %s\n",
                                        $offset + 5, $k,
                                        $values['id'], $tmp['id']);
                                        return false;
                        }
                        if ($values['label'] != $tmp['label']) {
                                printf("[%03d/%d] Expecting %s got %s\n",
                                        $offset + 6, $k,
                                        $values['label'], $tmp['label']);
                                        return false;
                        }
                }

                if ($res && $tmp = mysqli_fetch_assoc($res)) {
                        printf("[%03d] More results than expected!\n", $offset 
+ 7);
                        do {
                                var_dump($tmp);
                        } while ($tmp = mysqli_fetch_assoc($res));
                        return false;
                }

                if ($res)
                        mysqli_free_result($res);

                return true;
        }
?>
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/reflection_tools.inc?view=markup&rev=1.1
Index: php-src/ext/mysqli/tests/reflection_tools.inc
+++ php-src/ext/mysqli/tests/reflection_tools.inc
<?php
        function inspectClass($class) {

                /* not used: public ReflectionClass[] getInterfaces()  */

                printf("\nInspecting class '%s'\n", $class->getName());
                printf("isInternal: %s\n", ($class->isInternal()) ? 'yes' : 
'no');
                printf("isUserDefined: %s\n", ($class->isUserDefined()) ? 'yes' 
: 'no');
                printf("isInstantiable: %s\n", ($class->isInstantiable()) ? 
'yes' : 'no');
                printf("isInterface: %s\n", ($class->isInterface()) ? 'yes' : 
'no');
                printf("isAbstract: %s\n", ($class->isAbstract()) ? 'yes' : 
'no');
                printf("isFinal: %s\n", ($class->isFinal()) ? 'yes' : 'no');
                printf("isIteratable: %s\n", ($class->isIterateable()) ? 'yes' 
: 'no');
                printf("Modifiers: '%d'\n", $class->getModifiers());
                printf("Parent Class: '%s'\n", $class->getParentClass());
                printf("Extension: '%s'\n", $class->getExtensionName());

                if ($method = $class->getConstructor())
                        inspectMethod($method);

                if ($methods = $class->getMethods()) {
                        $tmp = array();
                        foreach ($methods as $method)
                                $tmp[$method->getName()] = $method;

                        ksort($tmp, SORT_STRING);
                        foreach ($tmp as $method)
                                inspectMethod($method);
                }

                if ($properties = $class->getProperties()) {
                        $tmp = array();
                        foreach ($properties as $prop)
                                $tmp[$prop->getName()] = $prop;
                        ksort($tmp, SORT_STRING);
                        foreach ($tmp as $prop)
                        inspectProperty($prop);
                }


                if ($properties = $class->getDefaultProperties()) {
                        ksort($properties, SORT_STRING);
                        foreach ($properties as $name => $v)
                                printf("Default property '%s'\n", $name);
                }

                if ($properties = $class->getStaticProperties()) {
                        ksort($properties, SORT_STRING);
                        foreach ($properties as $name => $v)
                                printf("Static property '%s'\n", $name);
                }

                if ($constants = $class->getConstants()) {
                        ksort($constants, SORT_STRING);
                        foreach ($constant as $name => $value)
                                printf("Constant '%s' = '%s'\n", $name, $value);
                }

        }

        function inspectProperty(&$prop) {

                printf("\nInspecting property '%s'\n", $prop->getName());
                printf("isPublic: %s\n", ($prop->isPublic()) ? 'yes' : 'no');
                printf("isPrivate: %s\n", ($prop->isPrivate()) ? 'yes' : 'no');
                printf("isProtected: %s\n", ($prop->isProtected()) ? 'yes' : 
'no');
                printf("isStatic: %s\n", ($prop->isStatic()) ? 'yes' : 'no');
                printf("isDefault: %s\n", ($prop->isDefault()) ? 'yes' : 'no');
                printf("Modifiers: %d\n", $prop->getModifiers());
                // printf("Value\n"); var_export($prop->getValue());

        }

        function inspectMethod(&$method) {

                printf("\nInspecting method '%s'\n", $method->getName());
                printf("isFinal: %s\n", ($method->isFinal()) ? 'yes' : 'no');
                printf("isAbstract: %s\n", ($method->isAbstract()) ? 'yes' : 
'no');
                printf("isPublic: %s\n", ($method->isPublic()) ? 'yes' : 'no');
                printf("isPrivate: %s\n", ($method->isPrivate()) ? 'yes' : 
'no');
                printf("isProtected: %s\n", ($method->isProtected()) ? 'yes' : 
'no');
                printf("isStatic: %s\n", ($method->isStatic()) ? 'yes' : 'no');
                printf("isConstructor: %s\n", ($method->isConstructor()) ? 
'yes' : 'no');
                printf("isDestructor: %s\n", ($method->isDestructor()) ? 'yes' 
: 'no');
                printf("isInternal: %s\n", ($method->isInternal()) ? 'yes' : 
'no');
                printf("isUserDefined: %s\n", ($method->isUserDefined()) ? 
'yes' : 'no');
                printf("returnsReference: %s\n", ($method->returnsReference()) 
? 'yes' : 'no');
                printf("Modifiers: %d\n", $method->getModifiers());
                printf("Number of Parameters: %d\n", 
$method->getNumberOfParameters());
                printf("Number of Required Parameters: %d\n", 
$method->getNumberOfRequiredParameters());

                if ($params = $method->getParameters()) {
                        $tmp = array();
                        foreach ($params as $k => $param)
                                $tmp[$param->getName()] = $param;

                        ksort($tmp, SORT_STRING);
                        foreach ($tmp as $param)
                                inspectParameter($method, $param);
                }

                if ($static = $method->getStaticVariables()) {
                        sort($static, SORT_STRING);
                        printf("Static variables: %s\n", implode('/', $static));
                }

        }

        function inspectParameter(&$method, &$param) {

                printf("\nInspecting parameter '%s' of method '%s'\n",
                $param->getName(), $method->getName());
                printf("isArray: %s\n", ($param->isArray()) ? 'yes': 'no');
                printf("allowsNull: %s\n", ($param->allowsNull()) ? 'yes' : 
'no');
                printf("isPassedByReference: %s\n", 
($param->isPassedByReference()) ? 'yes' : 'no');
                printf("isOptional: %s\n", ($param->isOptional()) ? 'yes' : 
'no');
                printf("isDefaultValueAvailable: %s\n", 
($param->isDefaultValueAvailable()) ? 'yes' : 'no');
                // printf("getDefaultValue: %s\n", ($param->getDefaultValue()) 
? 'yes' : 'no');

        }
?>
http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/skipifconnectfailure.inc?view=markup&rev=1.1
Index: php-src/ext/mysqli/tests/skipifconnectfailure.inc
+++ php-src/ext/mysqli/tests/skipifconnectfailure.inc
<?php
$skip_on_connect_failure  = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? 
getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : false;
if ($skip_on_connect_failure) {
        include_once('connect.inc');
        $link = @mysqli_connect($host, $user, $passwd, $db, $port, $socket);
        if (!is_object($link))
                die(sprintf("skip Can't connect to MySQL Server - [%d] %s", 
mysqli_connect_errno(), mysqli_connect_error()));
        mysqli_close($link);
}
?>

http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/skipifunicode.inc?view=markup&rev=1.1
Index: php-src/ext/mysqli/tests/skipifunicode.inc
+++ php-src/ext/mysqli/tests/skipifunicode.inc

http://cvs.php.net/viewvc.cgi/php-src/ext/mysqli/tests/table.inc?view=markup&rev=1.1
Index: php-src/ext/mysqli/tests/table.inc
+++ php-src/ext/mysqli/tests/table.inc
<?PHP
require_once('connect.inc');

if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
    printf("Cannot connect to the server using host=%s, user=%s, passwd=***, 
dbname=%s, port=%s, socket=%s\n",
        $host, $user, $db, $port, $socket);
    exit(1);
}   
        
if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
    printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link), 
mysqli_error($link));
    exit(1);
}        
        
if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY 
KEY(id)) ENGINE=' . $engine)) {
    printf("Failed to create test table: [%d] %s\n", mysqli_errno($link), 
mysqli_error($link));
    exit(1);
}

if (!mysqli_query($link, 'INSERT INTO test(id, label) VALUES (1, "a"), (2, 
"b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")')) {
    printf("[%d] %s\n",  mysqli_errno($link), mysqli_error($link));        
}
?>
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to