diff options
| author | Ulf Wendel <uw@php.net> | 2007-10-10 10:14:38 +0000 |
|---|---|---|
| committer | Ulf Wendel <uw@php.net> | 2007-10-10 10:14:38 +0000 |
| commit | ec08f105b92ddfc7591caac7fc100f038fc9a141 (patch) | |
| tree | 48a00c2774b1757b7f9ed0dbf415f2bb8f3feec8 /ext/mysqli/tests/mysqli_driver.phpt | |
| parent | 97c82d363fb7e6c0c2a855c13d6fc35e696bb5d8 (diff) | |
| download | php-git-ec08f105b92ddfc7591caac7fc100f038fc9a141.tar.gz | |
Adding new tests mysqli_d*.phpt mysqli_e*.phpt mysqli_f*.phpt
Diffstat (limited to 'ext/mysqli/tests/mysqli_driver.phpt')
| -rw-r--r-- | ext/mysqli/tests/mysqli_driver.phpt | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/ext/mysqli/tests/mysqli_driver.phpt b/ext/mysqli/tests/mysqli_driver.phpt new file mode 100644 index 0000000000..765fee527c --- /dev/null +++ b/ext/mysqli/tests/mysqli_driver.phpt @@ -0,0 +1,115 @@ +--TEST-- +mysqli_driver class +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifemb.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php + include "connect.inc"; + include "table.inc"; + + if (!is_object($driver = new mysqli_driver())) + printf("[001] Failed to create mysqli_driver object\n"); + + $client_info = mysqli_get_client_info(); + if (($tmp = $driver->client_info) !== $client_info) + printf("[002] Expecting %s/%s, got %s/%s\n", + gettype($client_info), $client_info, + gettype($tmp), $tmp); + + $client_version = mysqli_get_client_version(); + if (($tmp = $driver->client_version) !== $client_version) + printf("[003] Expecting %s/%s, got %s/%s\n", + gettype($client_version), $client_version, + gettype($tmp), $tmp); + + if (!is_int($tmp = $driver->driver_version) || (0 == $tmp)) + printf("[004] Expecting int/any, got %s/%s\n", + gettype($tmp), $tmp); + + + $all_modes = array(MYSQLI_REPORT_INDEX, MYSQLI_REPORT_ERROR, MYSQLI_REPORT_STRICT, + MYSQLI_REPORT_ALL, MYSQLI_REPORT_OFF); + $report_mode = $driver->report_mode; + if (!is_int($report_mode)) + printf("[005] Expecting int/any, got %s/%s\n", + gettype($report_mode), $report_mode); + + if (!in_array($report_mode, $all_modes)) + printf("[006] Illegal report mode returned? Got %s, expected %s\n", + $report_mode, implode(', ', $all_modes)); + + $driver->report_mode = MYSQLI_REPORT_STRICT; + $ok = false; + try { + + if ($link = mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket)) + printf("[007] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n", + $host, $user . 'unknown_really', $db, $port, $socket); + mysqli_close($link); + + } catch (mysqli_sql_exception $e) { + $ok = true; + if ('' == $e->getMessage()) + printf("[008] getMessage() has returned an emptry string.\n"); + if ('' == $e->getCode()) + printf("[009] getCode() has returned an empty string.\n"); + if ('' == $e->getFile()) + printf("[010] getFile() has returned an empty string.\n"); + if ('' == $e->getLine()) + printf("[011] getLine() has returned an empty string.\n"); + $tmp = $e->getTrace(); + if (empty($tmp)) + printf("[012] getTrace() has returned an empty array.\n"); + if ('' == $e->getTraceAsString()) + printf("[013] getTraceAsString() has returned an empty string.\n"); + if ('' == $e->__toString()) + printf("[014] __toString() has returned an empty string.\n"); + + } + if (!$ok) + printf("[015] Error reporting mode has not been switched to exceptions and or no exception thrown\n"); + + + $driver->report_mode = MYSQLI_REPORT_OFF; + if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[016] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + mysqli_query($link, "NO_SQL"); + mysqli_close($link); + + $driver->report_mode = MYSQLI_REPORT_ERROR; + + if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[017] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + mysqli_query($link, "NO_SQL"); + mysqli_close($link); + + if (MYSQLI_REPORT_ERROR !== $driver->report_mode) + printf("[018] Error mode should be different\n"); + + /* TODO - more report testing should go in here, but it's not really documented what behaviour is expected */ + + $driver->report_mode = $report_mode; + + $reconnect = $driver->reconnect; + if (!is_bool($reconnect)) + printf("[019] Expecting boolean/any, got %s/%s\n", + gettype($reconnect), $reconnect); + + /* pointless, but I need more documentation */ + $driver->reconnect = true; + $driver->reconnect = false; + $driver->reconnect = $reconnect; + + if (!is_bool($embedded = $driver->embedded)) + printf("[020] Expecting boolean/any, got %s/%s\n", + gettype($embedded), $embedded); + + print "done!"; +?> +--EXPECTF-- +Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NO_SQL' at line 1 in %s on line %d +done!
\ No newline at end of file |
