summaryrefslogtreecommitdiff
path: root/ext/odbc/tests
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/odbc/tests
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/odbc/tests')
-rw-r--r--ext/odbc/tests/config.inc8
-rw-r--r--ext/odbc/tests/odbc_columnprivileges_001.phpt28
-rw-r--r--ext/odbc/tests/odbc_columns_001.phpt32
-rw-r--r--ext/odbc/tests/odbc_data_source_001.phpt25
-rw-r--r--ext/odbc/tests/odbc_exec_001.phpt40
-rw-r--r--ext/odbc/tests/odbc_exec_002.phpt36
-rw-r--r--ext/odbc/tests/odbc_free_result_001.phpt50
-rw-r--r--ext/odbc/tests/odbc_tables_001.phpt29
-rw-r--r--ext/odbc/tests/skipif.inc10
9 files changed, 258 insertions, 0 deletions
diff --git a/ext/odbc/tests/config.inc b/ext/odbc/tests/config.inc
new file mode 100644
index 0000000..a88eea4
--- /dev/null
+++ b/ext/odbc/tests/config.inc
@@ -0,0 +1,8 @@
+<?php
+
+putenv('ODBCINI=/etc/odbc.ini');
+putenv('ODBCSYSINI=/etc');
+
+$dsn = 'myodbc3';
+$user = 'root';
+$pass = '';
diff --git a/ext/odbc/tests/odbc_columnprivileges_001.phpt b/ext/odbc/tests/odbc_columnprivileges_001.phpt
new file mode 100644
index 0000000..062985d
--- /dev/null
+++ b/ext/odbc/tests/odbc_columnprivileges_001.phpt
@@ -0,0 +1,28 @@
+--TEST--
+odbc_columnprivileges(): Basic test
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+var_dump($result = odbc_columnprivileges($conn, '', '', '', ''));
+var_dump(odbc_fetch_row($result));
+
+var_dump($result = odbc_columnprivileges($conn, NULL, NULL, NULL, NULL));
+var_dump(odbc_fetch_row($result));
+
+var_dump($result = odbc_columnprivileges($conn, 'FOO', 'FOO', 'FOO', 'FOO'));
+var_dump(odbc_fetch_row($result));
+
+?>
+--EXPECTF--
+resource(%d) of type (odbc result)
+bool(false)
+resource(%d) of type (odbc result)
+bool(false)
+resource(%d) of type (odbc result)
+bool(false)
diff --git a/ext/odbc/tests/odbc_columns_001.phpt b/ext/odbc/tests/odbc_columns_001.phpt
new file mode 100644
index 0000000..f6da78e
--- /dev/null
+++ b/ext/odbc/tests/odbc_columns_001.phpt
@@ -0,0 +1,32 @@
+--TEST--
+odbc_columns(): Basic test
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+var_dump($result = odbc_columns($conn, '', '', '', ''));
+var_dump(odbc_fetch_row($result));
+
+var_dump($result = odbc_columns($conn, NULL, NULL, NULL, NULL));
+var_dump(odbc_fetch_row($result));
+
+var_dump($result = odbc_columns($conn, 'FOO', 'FOO', 'FOO', 'FOO'));
+var_dump(odbc_fetch_row($result));
+
+?>
+--EXPECTF--
+resource(%d) of type (odbc result)
+bool(false)
+resource(%d) of type (odbc result)
+bool(false)
+
+Warning: odbc_columns(): SQL error: Failed to fetch error message, SQL state HY000 in SQLColumns in %s on line %d
+bool(false)
+
+Warning: odbc_fetch_row() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
diff --git a/ext/odbc/tests/odbc_data_source_001.phpt b/ext/odbc/tests/odbc_data_source_001.phpt
new file mode 100644
index 0000000..17a826f
--- /dev/null
+++ b/ext/odbc/tests/odbc_data_source_001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+odbc_data_source(): Basic test
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+var_dump(odbc_data_source($conn, NULL));
+var_dump(odbc_data_source($conn, ''));
+var_dump(odbc_data_source($conn, SQL_FETCH_FIRST));
+
+?>
+--EXPECTF--
+Warning: odbc_data_source(): Invalid fetch type (0) in %s on line %d
+bool(false)
+
+Warning: odbc_data_source() expects parameter 2 to be long, string given in %s on line %d
+NULL
+array(%d) {
+%a
+}
diff --git a/ext/odbc/tests/odbc_exec_001.phpt b/ext/odbc/tests/odbc_exec_001.phpt
new file mode 100644
index 0000000..c525a96
--- /dev/null
+++ b/ext/odbc/tests/odbc_exec_001.phpt
@@ -0,0 +1,40 @@
+--TEST--
+odbc_exec(): Basic test
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+odbc_exec($conn, 'foo', 'bar');
+odbc_exec($conn, 'foo');
+
+odbc_exec($conn, '', '');
+odbc_exec($conn, '');
+
+odbc_exec($conn, 1, 1);
+odbc_exec($conn, 1);
+
+odbc_exec($conn, NULL, NULL);
+odbc_exec($conn, NULL);
+
+?>
+--EXPECTF--
+Warning: odbc_exec() expects parameter 3 to be long, %unicode_string_optional% given in %s on line %d
+
+Warning: odbc_exec(): SQL error: %s in %s on line %d
+
+Warning: odbc_exec() expects parameter 3 to be long, %unicode_string_optional% given in %s on line %d
+
+Warning: odbc_exec(): SQL error: %s in %s on line %d
+
+Warning: odbc_exec(): SQL error: %s in %s on line %d
+
+Warning: odbc_exec(): SQL error: %s in %s on line %d
+
+Warning: odbc_exec(): SQL error: %s in %s on line %d
+
+Warning: odbc_exec(): SQL error: %s in %s on line %d
diff --git a/ext/odbc/tests/odbc_exec_002.phpt b/ext/odbc/tests/odbc_exec_002.phpt
new file mode 100644
index 0000000..8f9672d
--- /dev/null
+++ b/ext/odbc/tests/odbc_exec_002.phpt
@@ -0,0 +1,36 @@
+--TEST--
+odbc_exec(): Getting data from query
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+odbc_exec($conn, 'CREATE DATABASE odbcTEST');
+
+odbc_exec($conn, 'CREATE TABLE FOO (TEST INT)');
+
+odbc_exec($conn, 'INSERT INTO FOO VALUES (1)');
+odbc_exec($conn, 'INSERT INTO FOO VALUES (2)');
+
+$res = odbc_exec($conn, 'SELECT * FROM FOO');
+
+var_dump(odbc_fetch_row($res));
+var_dump(odbc_result($res, 'test'));
+var_dump(odbc_fetch_array($res));
+
+odbc_exec($conn, 'DROP TABLE FOO');
+
+odbc_exec($conn, 'DROP DATABASE odbcTEST');
+
+?>
+--EXPECTF--
+bool(true)
+string(1) "1"
+array(1) {
+ ["TEST"]=>
+ string(1) "2"
+}
diff --git a/ext/odbc/tests/odbc_free_result_001.phpt b/ext/odbc/tests/odbc_free_result_001.phpt
new file mode 100644
index 0000000..4fcd5cd
--- /dev/null
+++ b/ext/odbc/tests/odbc_free_result_001.phpt
@@ -0,0 +1,50 @@
+--TEST--
+odbc_free_result(): Basic test
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+odbc_exec($conn, 'CREATE DATABASE odbcTEST');
+
+odbc_exec($conn, 'CREATE TABLE FOO (TEST INT)');
+odbc_exec($conn, 'ALTER TABLE FOO ADD PRIMARY KEY FOO(TEST)');
+
+odbc_exec($conn, 'INSERT INTO FOO VALUES (1)');
+odbc_exec($conn, 'INSERT INTO FOO VALUES (2)');
+
+$res = odbc_exec($conn, 'SELECT * FROM FOO');
+
+var_dump(odbc_fetch_row($res));
+var_dump(odbc_result($res, 'test'));
+var_dump(odbc_free_result($res));
+var_dump(odbc_free_result($conn));
+var_dump(odbc_free_result(NULL));
+var_dump(odbc_fetch_row($res));
+var_dump(odbc_result($res, 'test'));
+
+odbc_exec($conn, 'DROP TABLE FOO');
+
+odbc_exec($conn, 'DROP DATABASE odbcTEST');
+
+?>
+--EXPECTF--
+bool(true)
+string(1) "1"
+bool(true)
+
+Warning: odbc_free_result(): supplied resource is not a valid ODBC result resource in %s on line %d
+bool(false)
+
+Warning: odbc_free_result() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Warning: odbc_fetch_row(): %d is not a valid ODBC result resource in %s on line %d
+bool(false)
+
+Warning: odbc_result(): %d is not a valid ODBC result resource in %s on line %d
+bool(false)
diff --git a/ext/odbc/tests/odbc_tables_001.phpt b/ext/odbc/tests/odbc_tables_001.phpt
new file mode 100644
index 0000000..6b922f2
--- /dev/null
+++ b/ext/odbc/tests/odbc_tables_001.phpt
@@ -0,0 +1,29 @@
+--TEST--
+odbc_tables(): Basic test
+--SKIPIF--
+<?php include 'skipif.inc'; ?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$conn = odbc_connect($dsn, $user, $pass);
+
+var_dump($result = odbc_tables($conn, '', '', '', ''));
+var_dump(odbc_fetch_row($result));
+
+var_dump($result = odbc_tables($conn, NULL, NULL, NULL, NULL));
+var_dump(odbc_fetch_row($result));
+
+var_dump($result = odbc_tables($conn, 'FOO', 'FOO', 'FOO', 'FOO'));
+var_dump(odbc_fetch_row($result));
+
+
+?>
+--EXPECTF--
+resource(%d) of type (odbc result)
+bool(false)
+resource(%d) of type (odbc result)
+bool(false)
+resource(%d) of type (odbc result)
+bool(false)
diff --git a/ext/odbc/tests/skipif.inc b/ext/odbc/tests/skipif.inc
new file mode 100644
index 0000000..179a5b1
--- /dev/null
+++ b/ext/odbc/tests/skipif.inc
@@ -0,0 +1,10 @@
+<?php
+
+if (!extension_loaded('odbc')) die('skip');
+
+include 'config.inc';
+
+$conn = @odbc_connect($dsn, $user, $pass);
+if (!$conn) {
+ die('skip could not connect');
+}