summaryrefslogtreecommitdiff
path: root/ext/interbase/tests
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-04-10 14:09:48 +0200
committerSean Finney <seanius@debian.org>2009-04-10 14:09:48 +0200
commitcd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f (patch)
tree1315c623bb7d9dfa8d366fa9cd2c6834ceeb5da5 /ext/interbase/tests
parent9ea47aab740772adf0c69d8c94b208a464e599ea (diff)
downloadphp-upstream/5.2.9.dfsg.1.tar.gz
Imported Upstream version 5.2.9.dfsg.1upstream/5.2.9.dfsg.1
Diffstat (limited to 'ext/interbase/tests')
-rw-r--r--ext/interbase/tests/bug45373.phpt49
-rw-r--r--ext/interbase/tests/bug45575.phpt22
-rw-r--r--ext/interbase/tests/bug46247.phpt36
-rw-r--r--ext/interbase/tests/bug46543.phpt28
-rw-r--r--ext/interbase/tests/ibase_affected_rows_001.phpt32
-rw-r--r--ext/interbase/tests/ibase_close_001.phpt25
-rw-r--r--ext/interbase/tests/ibase_drop_db_001.phpt31
-rw-r--r--ext/interbase/tests/ibase_errmsg_001.phpt22
-rw-r--r--ext/interbase/tests/ibase_free_query_001.phpt28
-rw-r--r--ext/interbase/tests/ibase_num_fields_001.phpt25
-rw-r--r--ext/interbase/tests/ibase_num_params_001.phpt32
-rw-r--r--ext/interbase/tests/ibase_param_info_001.phpt55
-rw-r--r--ext/interbase/tests/ibase_rollback_001.phpt41
-rw-r--r--ext/interbase/tests/ibase_trans_001.phpt21
-rw-r--r--ext/interbase/tests/ibase_trans_002.phpt34
-rwxr-xr-xext/interbase/tests/interbase.inc5
16 files changed, 485 insertions, 1 deletions
diff --git a/ext/interbase/tests/bug45373.phpt b/ext/interbase/tests/bug45373.phpt
new file mode 100644
index 000000000..8ec71df15
--- /dev/null
+++ b/ext/interbase/tests/bug45373.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Bug #45373 (php crash on query with errors in params)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+ require("interbase.inc");
+
+ $db = ibase_connect($test_base);
+
+
+ $sql = "select * from test1 where i = ? and c = ?";
+
+ $q = ibase_prepare($db, $sql);
+ $r = ibase_execute($q, 1, 'test table not created with isql');
+ var_dump(ibase_fetch_assoc($r));
+ ibase_free_result($r);
+
+ $r = ibase_execute($q, 1, 'test table not created with isql', 1);
+ var_dump(ibase_fetch_assoc($r));
+ ibase_free_result($r);
+
+ $r = ibase_execute($q, 1);
+ var_dump(ibase_fetch_assoc($r));
+
+?>
+--EXPECTF--
+array(2) {
+ ["I"]=>
+ int(1)
+ ["C"]=>
+ string(32) "test table not created with isql"
+}
+
+Notice: ibase_execute(): Statement expects 2 arguments, 3 given in %sbug45373.php on line %d
+array(2) {
+ ["I"]=>
+ int(1)
+ ["C"]=>
+ string(32) "test table not created with isql"
+}
+
+Warning: ibase_execute(): Statement expects 2 arguments, 1 given in %sbug45373.php on line %d
+
+Warning: ibase_fetch_assoc(): supplied argument is not a valid Firebird/InterBase result resource in %sbug45373.php on line %d
+bool(false)
+
+Warning: Unknown: invalid statement handle in Unknown on line 0
diff --git a/ext/interbase/tests/bug45575.phpt b/ext/interbase/tests/bug45575.phpt
new file mode 100644
index 000000000..ca0fa831e
--- /dev/null
+++ b/ext/interbase/tests/bug45575.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #45575 (Segfault with invalid non-string as event handler callback)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$db = ibase_connect($test_base);
+
+function foobar($var) { var_dump($var); return true; }
+
+ibase_set_event_handler($db, null, 'TEST1');
+ibase_set_event_handler($db, 1, 'TEST1');
+ibase_set_event_handler('foobar', 'TEST1');
+
+?>
+--EXPECTF--
+Warning: ibase_set_event_handler(): Callback argument is not a callable function in %s on line %d
+
+Warning: ibase_set_event_handler(): Callback argument 1 is not a callable function in %s on line %d
diff --git a/ext/interbase/tests/bug46247.phpt b/ext/interbase/tests/bug46247.phpt
new file mode 100644
index 000000000..ffd153b5f
--- /dev/null
+++ b/ext/interbase/tests/bug46247.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$db = ibase_connect($test_base);
+
+function test() { }
+
+ibase_set_event_handler();
+
+ibase_set_event_handler('test', 1);
+ibase_set_event_handler($db, 'test', 1);
+ibase_set_event_handler(NULL, 'test', 1);
+
+
+ibase_set_event_handler('foo', 1);
+ibase_set_event_handler($db, 'foo', 1);
+ibase_set_event_handler(NULL, 'foo', 1);
+
+?>
+--EXPECTF--
+
+Warning: Wrong parameter count for ibase_set_event_handler() in %s on line %d
+
+Warning: ibase_set_event_handler(): supplied argument is not a valid InterBase link resource in %s on line %d
+
+Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d
+
+Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d
+
+Warning: ibase_set_event_handler(): supplied argument is not a valid InterBase link resource in %s on line %d
diff --git a/ext/interbase/tests/bug46543.phpt b/ext/interbase/tests/bug46543.phpt
new file mode 100644
index 000000000..59e088c3d
--- /dev/null
+++ b/ext/interbase/tests/bug46543.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #46543 (ibase_trans() memory leaks when using wrong parameters)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+@ibase_close();
+
+ibase_trans(1);
+ibase_trans();
+ibase_trans('foo');
+ibase_trans(fopen(__FILE__, 'r'));
+
+$x = ibase_connect($test_base);
+ibase_trans(1, 2, $x, $x, 3);
+
+?>
+--EXPECTF--
+Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on line %d
+
+Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on line %d
+
+Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on line %d
+
+Warning: ibase_trans(): supplied resource is not a valid Firebird/InterBase link resource in %s on line %d
diff --git a/ext/interbase/tests/ibase_affected_rows_001.phpt b/ext/interbase/tests/ibase_affected_rows_001.phpt
new file mode 100644
index 000000000..398a84c8b
--- /dev/null
+++ b/ext/interbase/tests/ibase_affected_rows_001.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ibase_affected_rows(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+ibase_query($x, 'INSERT INTO test1 VALUES (1, 100)');
+ibase_query($x, 'INSERT INTO test1 VALUES (10000, 100)');
+
+ibase_query($x, 'UPDATE test1 SET i = 10000');
+var_dump(ibase_affected_rows($x));
+
+
+ibase_query($x, 'UPDATE test1 SET i = 10000 WHERE i = 2.0');
+var_dump(ibase_affected_rows($x));
+
+ibase_query($x, 'UPDATE test1 SET i =');
+var_dump(ibase_affected_rows($x));
+
+
+?>
+--EXPECTF--
+int(3)
+int(0)
+
+Warning: ibase_query(): Dynamic SQL Error SQL error code = -104 %s on line %d
+int(0)
diff --git a/ext/interbase/tests/ibase_close_001.phpt b/ext/interbase/tests/ibase_close_001.phpt
new file mode 100644
index 000000000..25412d484
--- /dev/null
+++ b/ext/interbase/tests/ibase_close_001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+ibase_close(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+var_dump(ibase_close($x));
+var_dump(ibase_close($x));
+var_dump(ibase_close());
+var_dump(ibase_close('foo'));
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+
+Warning: ibase_close(): %d is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
+
+Warning: ibase_close(): %d is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_drop_db_001.phpt b/ext/interbase/tests/ibase_drop_db_001.phpt
new file mode 100644
index 000000000..b5cabced5
--- /dev/null
+++ b/ext/interbase/tests/ibase_drop_db_001.phpt
@@ -0,0 +1,31 @@
+--TEST--
+ibase_drop_db(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+unlink($file = tempnam('/tmp',"php_ibase_test"));
+
+
+$db = ibase_query(IBASE_CREATE,
+ sprintf("CREATE SCHEMA '%s' USER '%s' PASSWORD '%s' DEFAULT CHARACTER SET %s",$file,
+ $user, $password, ($charset = ini_get('ibase.default_charset')) ? $charset : 'NONE'));
+
+var_dump($db);
+var_dump(ibase_drop_db($db));
+var_dump(ibase_drop_db(1));
+var_dump(ibase_drop_db(NULL));
+
+?>
+--EXPECTF--
+resource(%d) of type (Firebird/InterBase link)
+bool(true)
+
+Warning: ibase_drop_db(): supplied resource is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
+
+Warning: ibase_drop_db(): %d is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_errmsg_001.phpt b/ext/interbase/tests/ibase_errmsg_001.phpt
new file mode 100644
index 000000000..ad0e827f9
--- /dev/null
+++ b/ext/interbase/tests/ibase_errmsg_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+ibase_errmsg(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+ibase_query('SELECT Foobar');
+var_dump(ibase_errmsg());
+
+ibase_close($x);
+var_dump(ibase_errmsg());
+
+?>
+--EXPECTF--
+Warning: ibase_query(): Dynamic SQL Error SQL error code = -104 %s on line %d
+string(%d) "Dynamic SQL Error SQL error code = -104 %s"
+bool(false)
diff --git a/ext/interbase/tests/ibase_free_query_001.phpt b/ext/interbase/tests/ibase_free_query_001.phpt
new file mode 100644
index 000000000..bedec7173
--- /dev/null
+++ b/ext/interbase/tests/ibase_free_query_001.phpt
@@ -0,0 +1,28 @@
+--TEST--
+ibase_free_query(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$q =ibase_prepare($x, 'SELECT 1 FROM test1 WHERE i = ?');
+$q =ibase_prepare($x, 'SELECT 1 FROM test1 WHERE i = ?');
+$q = ibase_prepare($x, 'SELECT 1 FROM test1 WHERE i = ?');
+
+var_dump(ibase_free_query($q));
+var_dump(ibase_free_query($q));
+var_dump(ibase_free_query($x));
+
+?>
+--EXPECTF--
+bool(true)
+
+Warning: ibase_free_query(): 11 is not a valid Firebird/InterBase query resource in %s on line %d
+bool(false)
+
+Warning: ibase_free_query(): supplied resource is not a valid Firebird/InterBase query resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_num_fields_001.phpt b/ext/interbase/tests/ibase_num_fields_001.phpt
new file mode 100644
index 000000000..510b0f6f5
--- /dev/null
+++ b/ext/interbase/tests/ibase_num_fields_001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+ibase_num_fields(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+var_dump(ibase_num_fields(ibase_query('SELECT * FROM test1')));
+
+var_dump(ibase_num_fields(1));
+var_dump(ibase_num_fields());
+
+?>
+--EXPECTF--
+int(2)
+
+Warning: ibase_num_fields(): supplied argument is not a valid Firebird/InterBase result resource in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for ibase_num_fields() in %s on line %d
+NULL
diff --git a/ext/interbase/tests/ibase_num_params_001.phpt b/ext/interbase/tests/ibase_num_params_001.phpt
new file mode 100644
index 000000000..2cacc50f3
--- /dev/null
+++ b/ext/interbase/tests/ibase_num_params_001.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ibase_num_params(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ?');
+var_dump(ibase_num_params($rs));
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ?');
+var_dump(ibase_num_params());
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ? AND 3 = :x');
+var_dump(ibase_num_params($rs));
+
+
+?>
+--EXPECTF--
+int(2)
+
+Warning: Wrong parameter count for ibase_num_params() in %s on line %d
+NULL
+
+Warning: ibase_prepare(): Dynamic SQL Error SQL error code = -206 %s in %s on line %d
+
+Warning: ibase_num_params(): supplied argument is not a valid Firebird/InterBase query resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_param_info_001.phpt b/ext/interbase/tests/ibase_param_info_001.phpt
new file mode 100644
index 000000000..3dd92ba7a
--- /dev/null
+++ b/ext/interbase/tests/ibase_param_info_001.phpt
@@ -0,0 +1,55 @@
+--TEST--
+ibase_param_info(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ?');
+var_dump(ibase_param_info($rs, 1));
+
+print "---\n";
+
+var_dump(ibase_param_info($rs, 100));
+
+print "---\n";
+
+var_dump(ibase_param_info(100));
+
+
+?>
+--EXPECTF--
+array(10) {
+ [0]=>
+ string(0) ""
+ ["name"]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ ["alias"]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ ["relation"]=>
+ string(0) ""
+ [3]=>
+ string(1) "4"
+ ["length"]=>
+ string(1) "4"
+ [4]=>
+ string(7) "INTEGER"
+ ["type"]=>
+ string(7) "INTEGER"
+}
+---
+bool(false)
+---
+
+Warning: Wrong parameter count for ibase_param_info() in %s on line %d
+NULL
+
+Warning: Unknown: invalid statement handle in Unknown on line 0
diff --git a/ext/interbase/tests/ibase_rollback_001.phpt b/ext/interbase/tests/ibase_rollback_001.phpt
new file mode 100644
index 000000000..3cde5e9d4
--- /dev/null
+++ b/ext/interbase/tests/ibase_rollback_001.phpt
@@ -0,0 +1,41 @@
+--TEST--
+ibase_rollback(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+ibase_query('INSERT INTO test1 VALUES (100, 2)');
+ibase_query('INSERT INTO test1 VALUES (100, 2)');
+ibase_query('INSERT INTO test1 VALUES (100, 2)');
+
+$rs = ibase_query('SELECT COUNT(*) FROM test1 WHERE i = 100');
+var_dump(ibase_fetch_row($rs));
+
+var_dump(ibase_rollback($x));
+
+$rs = ibase_query('SELECT COUNT(*) FROM test1 WHERE i = 100');
+var_dump(ibase_fetch_row($rs));
+
+var_dump(ibase_rollback($x));
+var_dump(ibase_rollback());
+
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ int(3)
+}
+bool(true)
+array(1) {
+ [0]=>
+ int(0)
+}
+bool(true)
+
+Warning: ibase_rollback(): invalid transaction handle (expecting explicit transaction start) in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_trans_001.phpt b/ext/interbase/tests/ibase_trans_001.phpt
new file mode 100644
index 000000000..cceb60e9a
--- /dev/null
+++ b/ext/interbase/tests/ibase_trans_001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+ibase_trans(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+var_dump(ibase_trans($x));
+var_dump(ibase_trans(1));
+var_dump(ibase_close());
+var_dump(ibase_close($x));
+
+?>
+--EXPECTF--
+resource(%d) of type (Firebird/InterBase transaction)
+resource(%d) of type (Firebird/InterBase transaction)
+bool(true)
+bool(true)
diff --git a/ext/interbase/tests/ibase_trans_002.phpt b/ext/interbase/tests/ibase_trans_002.phpt
new file mode 100644
index 000000000..be7c073ca
--- /dev/null
+++ b/ext/interbase/tests/ibase_trans_002.phpt
@@ -0,0 +1,34 @@
+--TEST--
+ibase_trans(): Basic operations
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$trans = ibase_trans(IBASE_DEFAULT, $x);
+$sth = ibase_prepare($trans, 'INSERT INTO test1 VALUES (?, ?)');
+
+$res = ibase_execute($sth, 100, 100);
+var_dump($res);
+
+ibase_commit($trans);
+
+$rs = ibase_query($x, 'SELECT * FROM test1 WHERE i = 100');
+var_dump(ibase_fetch_assoc($rs));
+
+ibase_free_query($sth);
+unset($res);
+
+?>
+--EXPECT--
+int(1)
+array(2) {
+ ["I"]=>
+ int(100)
+ ["C"]=>
+ string(3) "100"
+}
diff --git a/ext/interbase/tests/interbase.inc b/ext/interbase/tests/interbase.inc
index eea3bebe7..3254ace95 100755
--- a/ext/interbase/tests/interbase.inc
+++ b/ext/interbase/tests/interbase.inc
@@ -1,4 +1,4 @@
-<?php /* $Id: interbase.inc,v 1.10 2004/06/01 08:38:33 abies Exp $ */
+<?php /* $Id: interbase.inc,v 1.10.6.1 2008/10/07 12:53:08 felipe Exp $ */
srand((double)microtime()*1000000);
@@ -104,6 +104,9 @@ function rand_number($len , $prec = -1, $sign = 1)
}
} else if ($prec == 0) {
$n = substr(rand() . rand(), 0, rand() % $len + 1);
+ } else if (($prec - $len) == 0) {
+ $n = substr(rand() . rand(), 0, 1);
+ $n .= "." . substr(rand(), 0, $prec);
} else {
$n = substr(rand() . rand(), 0, rand() % ($len - $prec) + 1);
$n .= "." . substr(rand(), 0, $prec);