]> granicus.if.org Git - php/commitdiff
more OCI8 tests by Chris Jones
authorAntony Dovgal <tony2001@php.net>
Fri, 22 Dec 2006 13:28:46 +0000 (13:28 +0000)
committerAntony Dovgal <tony2001@php.net>
Fri, 22 Dec 2006 13:28:46 +0000 (13:28 +0000)
ext/oci8/tests/coll_018.phpt [new file with mode: 0644]
ext/oci8/tests/error2.phpt [new file with mode: 0644]
ext/oci8/tests/lob_036.phpt [new file with mode: 0644]
ext/oci8/tests/statement_type.phpt

diff --git a/ext/oci8/tests/coll_018.phpt b/ext/oci8/tests/coll_018.phpt
new file mode 100644 (file)
index 0000000..f97cc49
--- /dev/null
@@ -0,0 +1,93 @@
+--TEST--
+Collection trim tests
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__)."/connect.inc";
+require dirname(__FILE__)."/create_type.inc";
+
+$coll1 = oci_new_collection($c, $type_name);
+
+echo "Test 1.\n";
+var_dump($coll1->trim());
+
+echo "\nTest 2.\n";
+var_dump($coll1->trim(0));
+
+echo "\nTest 3.\n";
+var_dump($coll1->append(1));
+var_dump($coll1->append(2));
+var_dump($coll1->append(3));
+var_dump($coll1->append(4));
+
+var_dump($coll1->getElem(-1));  // check before the beginning
+var_dump($coll1->getElem(0));
+var_dump($coll1->getElem(1));
+var_dump($coll1->getElem(2));
+var_dump($coll1->getElem(3));
+var_dump($coll1->getElem(4));  // check past the end
+
+echo "\nTest 4.\n";
+var_dump($coll1->trim(1));
+var_dump($coll1->getElem(2));  // this should be the last element
+var_dump($coll1->getElem(3));  // this element should have gone
+
+echo "\nTest 5.\n";
+var_dump($coll1->trim(2));
+var_dump($coll1->getElem(0));  // this should be the last element
+var_dump($coll1->getElem(1));  // this element should have gone
+
+echo "\nTest 6.\n";
+var_dump($coll1->trim(0));
+var_dump($coll1->getElem(0));  // this should still be the last element
+
+echo "\nTest 7.\n";
+var_dump($coll1->trim(1));
+var_dump($coll1->getElem(0));  // this should have gone
+
+echo "Done\n";
+
+require dirname(__FILE__)."/drop_type.inc";
+
+?>
+--EXPECTF--
+Test 1.
+
+Warning: OCI-Collection::trim() expects exactly 1 parameter, 0 given in %s on line 9
+NULL
+
+Test 2.
+bool(true)
+
+Test 3.
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(false)
+float(1)
+float(2)
+float(3)
+float(4)
+bool(false)
+
+Test 4.
+bool(true)
+float(3)
+bool(false)
+
+Test 5.
+bool(true)
+float(1)
+bool(false)
+
+Test 6.
+bool(true)
+float(1)
+
+Test 7.
+bool(true)
+bool(false)
+Done
diff --git a/ext/oci8/tests/error2.phpt b/ext/oci8/tests/error2.phpt
new file mode 100644 (file)
index 0000000..13ea6ce
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Exercise error code for SUCCESS_WITH_INFO
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+ini_set('error_reporting', E_ALL);
+
+$s = oci_parse($c, "create or replace procedure myproc as begin bogus end;");
+$e = @oci_execute($s);
+if (!$e) {
+    $es = oci_error($s);
+    echo $es['message']."\n";
+}
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+ORA-24344: success with compilation error
+Done
diff --git a/ext/oci8/tests/lob_036.phpt b/ext/oci8/tests/lob_036.phpt
new file mode 100644 (file)
index 0000000..5c2972e
--- /dev/null
@@ -0,0 +1,45 @@
+--TEST--
+Exercise cleanup code when LOB buffering is on
+--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
+                       ".$schema.$table_name." (blob)
+                      VALUES (empty_blob())
+                      RETURNING
+                               blob
+                      INTO :v_blob ";
+
+$s = oci_parse($c,$ora_sql);
+$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
+
+
+oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
+oci_execute($s, OCI_DEFAULT);
+
+var_dump($blob->write("test"));
+var_dump($blob->setBuffering(true));
+var_dump($blob->write("test"));
+
+$blob = null;
+
+require dirname(__FILE__).'/drop_table.inc';
+
+echo "Done\n";
+
+?>
+--EXPECT--
+int(4)
+bool(true)
+int(4)
+Done
+--UEXPECT--
+int(8)
+bool(true)
+int(8)
+Done
index f7ac43efc8dd65b1e8640a7ff25c5dfdf6b22ce1..78e6570dc9abd2c0ef2098928a244aa917b81466 100644 (file)
@@ -7,22 +7,19 @@ oci_statement_type()
 
 require dirname(__FILE__)."/connect.inc";
 
-if (!empty($dbase)) {
-       var_dump($c = oci_connect($user, $password, $dbase));
-}
-else {
-       var_dump($c = oci_connect($user, $password));
-}
-
 $sqls = Array(
-       "SELECT * FROM table",
-       "DELETE FROM table WHERE id = 1",
-       "INSERT INTO table VALUES(1)",
-       "UPDATE table SET id = 1",
-       "DROP TABLE table",
-       "CREATE TABLE table (id NUMBER)",
-       "WRONG SYNTAX",
-       ""
+    "SELECT * FROM table",
+    "DELETE FROM table WHERE id = 1",
+    "INSERT INTO table VALUES(1)",
+    "UPDATE table SET id = 1",
+    "DROP TABLE table",
+    "CREATE TABLE table (id NUMBER)",
+    "ALTER TABLE table ADD (col1 NUMBER)",
+    "BEGIN NULL; END;",
+    "DECLARE myn NUMBER BEGIN myn := 1; END;",
+    "CALL myproc(1)",
+    "WRONG SYNTAX",
+    ""
 );
 
 foreach ($sqls as $sql) {
@@ -34,24 +31,30 @@ echo "Done\n";
 
 ?>
 --EXPECTF--
-resource(%d) of type (oci8 connection)
 string(6) "SELECT"
 string(6) "DELETE"
 string(6) "INSERT"
 string(6) "UPDATE"
 string(4) "DROP"
 string(6) "CREATE"
+string(5) "ALTER"
+string(5) "BEGIN"
+string(7) "DECLARE"
+string(4) "CALL"
 string(7) "UNKNOWN"
 string(7) "UNKNOWN"
 Done
 --UEXPECTF--
-resource(%d) of type (oci8 connection)
 unicode(6) "SELECT"
 unicode(6) "DELETE"
 unicode(6) "INSERT"
 unicode(6) "UPDATE"
 unicode(4) "DROP"
 unicode(6) "CREATE"
+unicode(5) "ALTER"
+unicode(5) "BEGIN"
+unicode(7) "DECLARE"
+unicode(4) "CALL"
 unicode(7) "UNKNOWN"
 unicode(7) "UNKNOWN"
 Done