summaryrefslogtreecommitdiff
path: root/ext/oci8/tests
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-01-31 13:56:16 +0000
committerAntony Dovgal <tony2001@php.net>2007-01-31 13:56:16 +0000
commitcdaff68610cb4816723d692402d0f084d131a85a (patch)
tree30424eacf7a6559b8599021694d0d8f8a1267de3 /ext/oci8/tests
parent4f6f150490990d1e9dbc0b59cab6f20f15fefbef (diff)
downloadphp-git-cdaff68610cb4816723d692402d0f084d131a85a.tar.gz
MFH: improve tests
Diffstat (limited to 'ext/oci8/tests')
-rw-r--r--ext/oci8/tests/bind_empty.phpt69
-rw-r--r--ext/oci8/tests/oci_execute_segfault.phpt36
2 files changed, 94 insertions, 11 deletions
diff --git a/ext/oci8/tests/bind_empty.phpt b/ext/oci8/tests/bind_empty.phpt
index 9c602b32c3..ba50f86175 100644
--- a/ext/oci8/tests/bind_empty.phpt
+++ b/ext/oci8/tests/bind_empty.phpt
@@ -4,7 +4,7 @@ binding empty values
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
-
+
require dirname(__FILE__).'/connect.inc';
$drop = "DROP table bind_test";
@@ -16,18 +16,57 @@ $statement = oci_parse($c, $create);
oci_execute($statement);
+echo "Test 1\n";
+
$name = null;
$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
oci_bind_by_name($stmt, ":name", $name);
-$res = oci_execute($stmt);
+var_dump(oci_execute($stmt));
+
+echo "Test 2\n";
$name = "";
$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
oci_bind_by_name($stmt, ":name", $name);
+var_dump(oci_execute($stmt));
+
+echo "Test 3\n";
+
+$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('abc')");
$res = oci_execute($stmt);
+$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('def')");
+$res = oci_execute($stmt);
+
+$name = null;
+$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'abc'");
+oci_bind_by_name($stmt, ":name", $name);
+
+var_dump(oci_execute($stmt));
+
+$stid = oci_parse($c, "select * from bind_test order by 1");
+oci_execute($stid);
+oci_fetch_all($stid, $res);
+var_dump($res);
+
+echo "Test 4\n";
+
+$name = "";
+$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'def'");
+oci_bind_by_name($stmt, ":name", $name);
+
+var_dump(oci_execute($stmt));
+
+$stid = oci_parse($c, "select * from bind_test order by 1");
+oci_execute($stid);
+oci_fetch_all($stid, $res);
+var_dump($res);
+
+
+// Clean up
+
$drop = "DROP table bind_test";
$statement = oci_parse($c, $drop);
@oci_execute($statement);
@@ -36,4 +75,30 @@ echo "Done\n";
?>
--EXPECTF--
+Test 1
+bool(true)
+Test 2
+bool(true)
+Test 3
+bool(true)
+array(1) {
+ ["NAME"]=>
+ array(2) {
+ [0]=>
+ string(3) "def"
+ [1]=>
+ NULL
+ }
+}
+Test 4
+bool(true)
+array(1) {
+ ["NAME"]=>
+ array(2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ }
+}
Done
diff --git a/ext/oci8/tests/oci_execute_segfault.phpt b/ext/oci8/tests/oci_execute_segfault.phpt
index 3859f4ffe0..9ba7d770fd 100644
--- a/ext/oci8/tests/oci_execute_segfault.phpt
+++ b/ext/oci8/tests/oci_execute_segfault.phpt
@@ -1,30 +1,48 @@
--TEST--
-oci_execute() segfault after repeated bind
+oci_execute() segfault after repeated bind of LOB descriptor
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
-
+
require dirname(__FILE__).'/connect.inc';
require dirname(__FILE__).'/create_table.inc';
$ora_sql = "INSERT INTO
- ".$table_name." (blob, clob)
+ ".$schema.$table_name." (blob, clob)
VALUES (empty_blob(), empty_clob())
RETURNING
blob
INTO :v_blob ";
-$s = oci_parse($c,$ora_sql);
-$blob = oci_new_descriptor($c,OCI_D_LOB);
-oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
-oci_execute($s);
+$s = oci_parse($c, $ora_sql);
+$blob = oci_new_descriptor($c, OCI_D_LOB);
+oci_bind_by_name($s, ":v_blob", $blob, -1, OCI_B_BLOB);
+oci_execute($s, OCI_DEFAULT);
+var_dump($blob->save("some binary data"));
+
+oci_bind_by_name($s, ":v_blob", $blob, -1, OCI_B_BLOB);
+oci_execute($s, OCI_DEFAULT);
+var_dump($blob->save("some more binary data"));
+
+$query = 'SELECT blob, DBMS_LOB.GETLENGTH(blob) FROM '.$schema.$table_name.' ORDER BY 2';
+
+$s = oci_parse ($c, $query);
+oci_execute($s, OCI_DEFAULT);
+
+while ($arr = oci_fetch_assoc($s)) {
+ $result = $arr['BLOB']->load();
+ var_dump($result);
+}
-oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
-oci_execute($s);
+require dirname(__FILE__).'/drop_table.inc';
echo "Done\n";
?>
--EXPECT--
+bool(true)
+bool(true)
+string(16) "some binary data"
+string(21) "some more binary data"
Done