]> granicus.if.org Git - php/commitdiff
add new tests
authorAntony Dovgal <tony2001@php.net>
Tue, 12 Dec 2006 09:33:17 +0000 (09:33 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 12 Dec 2006 09:33:17 +0000 (09:33 +0000)
ext/oci8/tests/lob_028.phpt [new file with mode: 0644]
ext/oci8/tests/lob_029.phpt [new file with mode: 0644]

diff --git a/ext/oci8/tests/lob_028.phpt b/ext/oci8/tests/lob_028.phpt
new file mode 100644 (file)
index 0000000..e175632
--- /dev/null
@@ -0,0 +1,122 @@
+--TEST--
+Test descriptor types for oci_new_descriptor()
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+// Successful statements
+
+$d = oci_new_descriptor($c, OCI_D_FILE);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DTYPE_FILE);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_D_LOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DTYPE_LOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_D_ROWID);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DTYPE_ROWID);
+var_dump($d);
+
+// Unsuccessful statements
+
+$d = oci_new_descriptor($c, OCI_B_CLOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_B_CLOB);
+var_dump($d);
+
+$d = oci_new_descriptor($c, OCI_DEFAULT);
+var_dump($d);
+
+$d = oci_new_descriptor($c, 1);
+var_dump($d);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+object(OCI-Lob)#%d (1) {
+  ["descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  ["descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  ["descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  ["descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  ["descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  ["descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+Done
+--UEXPECTF--
+object(OCI-Lob)#%d (1) {
+  [u"descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  [u"descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  [u"descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  [u"descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  [u"descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+object(OCI-Lob)#%d (1) {
+  [u"descriptor"]=>
+  resource(%d) of type (oci8 descriptor)
+}
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+
+Warning: oci_new_descriptor(): Unknown descriptor type %d in %s on line %d
+NULL
+Done
diff --git a/ext/oci8/tests/lob_029.phpt b/ext/oci8/tests/lob_029.phpt
new file mode 100644 (file)
index 0000000..6dc9182
--- /dev/null
@@ -0,0 +1,120 @@
+--TEST--
+reading/writing BFILE LOBs
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+$realdirname = dirname(__FILE__);
+$realfilename = "oci8bfiletest.txt";
+$fullname = $realdirname."/".$realfilename;
+
+// Setup
+$s = oci_parse($c, "create directory TestDir as '$realdirname'");
+oci_execute($s);
+
+file_put_contents($fullname, 'Some text in the bfile');
+
+$s = oci_parse($c, "create table FileTest (FileNum number, FileDesc varchar2(30), Image bfile)");
+oci_execute($s);
+
+$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (1, 'Description 1', bfilename('TESTDIR', '$realfilename'))");
+oci_execute($s);
+
+// Run tests
+
+echo "Test 1. Check how many rows in the table\n";
+
+$s = oci_parse($c, "select count(*) numrows from FileTest");
+oci_execute($s);
+oci_fetch_all($s, $res);
+var_dump($res);
+
+echo "Test 2\n";
+$s = oci_parse($c, "select * from FileTest");
+oci_execute($s);
+oci_fetch_all($s, $res);
+var_dump($res);
+
+echo "Test 3\n";
+$d = oci_new_descriptor($c, OCI_D_FILE);
+
+$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (2, 'Description 2', bfilename('TESTDIR', '$realfilename')) returning Image into :im");
+oci_bind_by_name($s, ":im", $d, -1, OCI_B_BFILE);
+oci_execute($s);
+
+$r = $d->read(40);
+var_dump($r);
+
+unlink($fullname);
+
+$s = oci_parse($c, "drop table FileTest");
+oci_execute($s);
+
+$s = oci_parse($c, "drop directory TestDir");
+oci_execute($s);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+Test 1. Check how many rows in the table
+array(1) {
+  ["NUMROWS"]=>
+  array(1) {
+    [0]=>
+    string(1) "1"
+  }
+}
+Test 2
+array(3) {
+  ["FILENUM"]=>
+  array(1) {
+    [0]=>
+    string(1) "1"
+  }
+  ["FILEDESC"]=>
+  array(1) {
+    [0]=>
+    string(13) "Description 1"
+  }
+  ["IMAGE"]=>
+  array(1) {
+    [0]=>
+    string(22) "Some text in the bfile"
+  }
+}
+Test 3
+string(22) "Some text in the bfile"
+Done
+--UEXPECTF--
+Test 1. Check how many rows in the table
+array(1) {
+  [u"NUMROWS"]=>
+  array(1) {
+    [0]=>
+    unicode(1) "1"
+  }
+}
+Test 2
+array(3) {
+  [u"FILENUM"]=>
+  array(1) {
+    [0]=>
+    unicode(1) "1"
+  }
+  [u"FILEDESC"]=>
+  array(1) {
+    [0]=>
+    unicode(13) "Description 1"
+  }
+  [u"IMAGE"]=>
+  array(1) {
+    [0]=>
+    string(22) "Some text in the bfile"
+  }
+}
+Test 3
+string(22) "Some text in the bfile"
+Done