Author: uwendel
Date: 2007-07-11 12:21:11 +0200 (Wed, 11 Jul 2007)
New Revision: 701
Modified:
trunk/tests/ext/mysql/001.phpt
trunk/tests/ext/mysql/002.phpt
trunk/tests/ext/mysql/003.phpt
trunk/tests/ext/mysql/connect.inc
trunk/tests/ext/mysql/skipif.inc
trunk/tests/ext/mysql/table.inc
Log:
Whitespace AKA php.net coding standards change only
Modified: trunk/tests/ext/mysql/001.phpt
===================================================================
--- trunk/tests/ext/mysql/001.phpt 2007-07-10 18:16:20 UTC (rev 700)
+++ trunk/tests/ext/mysql/001.phpt 2007-07-11 10:21:11 UTC (rev 701)
@@ -4,15 +4,13 @@
<?php include 'skipif.inc'; ?>
--FILE--
<?php
-
-include 'connect.inc';
+require_once('connect.inc');
$test = '';
if ($socket)
- $host = sprintf("%s:%s", $host, $socket);
+ $host = sprintf("%s:%s", $host, $socket);
else if ($port)
- $host = sprintf("%s:%s", $host, $port);
-
+ $host = sprintf("%s:%s", $host, $port);
/*** test mysql_connect localhost ***/
$db = mysql_connect($host, $user, $passwd);
Modified: trunk/tests/ext/mysql/002.phpt
===================================================================
--- trunk/tests/ext/mysql/002.phpt 2007-07-10 18:16:20 UTC (rev 700)
+++ trunk/tests/ext/mysql/002.phpt 2007-07-11 10:21:11 UTC (rev 701)
@@ -4,11 +4,11 @@
<?php include 'skipif.inc'; ?>
--FILE--
<?php
-include_once('connect.inc');
+require_once('connect.inc');
-if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
var_dump($link);
Modified: trunk/tests/ext/mysql/003.phpt
===================================================================
--- trunk/tests/ext/mysql/003.phpt 2007-07-10 18:16:20 UTC (rev 700)
+++ trunk/tests/ext/mysql/003.phpt 2007-07-11 10:21:11 UTC (rev 701)
@@ -12,31 +12,27 @@
}
}
-$data = array(
- "one",
- "two",
- "three"
- );
+$data = array("one", "two", "three");
-if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
-
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
if (!mysql_query('DROP TABLE IF EXISTS test', $link))
- printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
+ printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!mysql_query("CREATE TABLE test(a varchar(10))", $link))
- printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
+ printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
foreach ($data as $str) {
if (!mysql_query(sprintf("INSERT INTO test VALUES('%s')", $str), $link))
- printf("[004 - %s] [%d] %s\n", $str, mysql_errno($link), mysql_error($link));
+ printf("[004 - %s] [%d] %s\n", $str, mysql_errno($link), mysql_error($link));
}
echo "==stdClass==\n";
if (!$res = mysql_query("SELECT a FROM test", $link))
- printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
+ printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
while ($obj = mysql_fetch_object($res)) {
var_dump($obj);
}
@@ -45,14 +41,13 @@
echo "==class24==\n";
if (!$res = mysql_query("SELECT a FROM test", $link))
printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
-
+
while ($obj = mysql_fetch_object($res, 'class24')) {
var_dump($obj);
}
mysql_free_result($res);
mysql_close($link);
print "done!";
-
?>
--EXPECTF--
==stdClass==
Modified: trunk/tests/ext/mysql/connect.inc
===================================================================
--- trunk/tests/ext/mysql/connect.inc 2007-07-10 18:16:20 UTC (rev 700)
+++ trunk/tests/ext/mysql/connect.inc 2007-07-11 10:21:11 UTC (rev 701)
@@ -1,66 +1,66 @@
<?php
- 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;
- }
- }
-
- /* wrapper to simplify test porting */
- function my_mysql_connect($host, $user, $passwd, $db, $port, $socket) {
-
- if ($socket)
- $host = sprintf("%s:%s", $host, $socket);
- else if ($port)
- $host = sprintf("%s:%s", $host, $port);
-
- if (!$link = mysql_connect($host, $user, $passwd, true)) {
- printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d]
%s\n",
- $host, $user, $passwd,
- mysql_errno(), mysql_error());
- return false;
- }
-
- if (!mysql_select_db($db, $link)) {
- printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link));
- return false;
- }
-
- return $link;
+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;
}
+}
- /*
- Default values are "localhost", "root",
- database "phptest" and empty password.
- Change the MYSQL_TEST environment values
- if you want to use another configuration
- */
-
- $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;
+/* wrapper to simplify test porting */
+function my_mysql_connect($host, $user, $passwd, $db, $port, $socket) {
- $IS_MYSQLND = stristr(mysql_get_client_info(), "mysqlnd");
+ if ($socket)
+ $host = sprintf("%s:%s", $host, $socket);
+ else if ($port)
+ $host = sprintf("%s:%s", $host, $port);
+
+ if (!$link = mysql_connect($host, $user, $passwd, true)) {
+ printf("[000-a] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
+ $host, $user, $passwd,
+ mysql_errno(), mysql_error());
+ return false;
+ }
+
+ if (!mysql_select_db($db, $link)) {
+ printf("[000-b] [%d] %s\n", mysql_errno($link), mysql_error($link));
+ return false;
+ }
+
+ return $link;
+}
+
+/*
+Default values are "localhost", "root",
+database "phptest" and empty password.
+Change the MYSQL_TEST environment values
+if you want to use another configuration.
+*/
+
+$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") : "test";
+$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(mysql_get_client_info(), "mysqlnd");
?>
Modified: trunk/tests/ext/mysql/skipif.inc
===================================================================
--- trunk/tests/ext/mysql/skipif.inc 2007-07-10 18:16:20 UTC (rev 700)
+++ trunk/tests/ext/mysql/skipif.inc 2007-07-11 10:21:11 UTC (rev 701)
@@ -1,5 +1,5 @@
<?php
-include_once('connect.inc');
+require_once('connect.inc');
if (!extension_loaded("mysql")) {
die('skip mysql extension not available');
}
Modified: trunk/tests/ext/mysql/table.inc
===================================================================
--- trunk/tests/ext/mysql/table.inc 2007-07-10 18:16:20 UTC (rev 700)
+++ trunk/tests/ext/mysql/table.inc 2007-07-11 10:21:11 UTC (rev 701)
@@ -6,19 +6,19 @@
printf("Cannot connect to the server using host=%s/%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
$host, $myhost, $user, $db, $port, $socket);
exit(1);
-}
+}
if (!mysql_query('DROP TABLE IF EXISTS test', $link)) {
printf("Failed to drop old test table: [%d] %s\n", mysql_errno($link),
mysql_error($link));
exit(1);
-}
-
+}
+
if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' .
$engine, $link)) {
printf("Failed to create test table: [%d] %s\n", mysql_errno($link),
mysql_error($link));
exit(1);
}
if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4,
"d"), (5, "e"), (6, "f")', $link)) {
- printf("[%d] %s\n", mysql_errno($link), mysql_error($link));
+ printf("[%d] %s\n", mysql_errno($link), mysql_error($link));
}
?>
\ No newline at end of file
| Thread |
|---|
| • PHP mysqlnd svn commit: r701 - trunk/tests/ext/mysql | uwendel | 11 Jul |