Skip to content

Commit fc0e395

Browse files
committed
add new tests
1 parent f5543e8 commit fc0e395

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

ext/oci8/tests/lob_028.phpt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
--TEST--
2+
Test descriptor types for oci_new_descriptor()
3+
--SKIPIF--
4+
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5+
--FILE--
6+
<?php
7+
8+
require dirname(__FILE__).'/connect.inc';
9+
10+
// Successful statements
11+
12+
$d = oci_new_descriptor($c, OCI_D_FILE);
13+
var_dump($d);
14+
15+
$d = oci_new_descriptor($c, OCI_DTYPE_FILE);
16+
var_dump($d);
17+
18+
$d = oci_new_descriptor($c, OCI_D_LOB);
19+
var_dump($d);
20+
21+
$d = oci_new_descriptor($c, OCI_DTYPE_LOB);
22+
var_dump($d);
23+
24+
$d = oci_new_descriptor($c, OCI_D_ROWID);
25+
var_dump($d);
26+
27+
$d = oci_new_descriptor($c, OCI_DTYPE_ROWID);
28+
var_dump($d);
29+
30+
// Unsuccessful statements
31+
32+
$d = oci_new_descriptor($c, OCI_B_CLOB);
33+
var_dump($d);
34+
35+
$d = oci_new_descriptor($c, OCI_B_CLOB);
36+
var_dump($d);
37+
38+
$d = oci_new_descriptor($c, OCI_DEFAULT);
39+
var_dump($d);
40+
41+
$d = oci_new_descriptor($c, 1);
42+
var_dump($d);
43+
44+
echo "Done\n";
45+
46+
?>
47+
--EXPECTF--
48+
object(OCI-Lob)#%d (1) {
49+
["descriptor"]=>
50+
resource(%d) of type (oci8 descriptor)
51+
}
52+
object(OCI-Lob)#%d (1) {
53+
["descriptor"]=>
54+
resource(%d) of type (oci8 descriptor)
55+
}
56+
object(OCI-Lob)#%d (1) {
57+
["descriptor"]=>
58+
resource(%d) of type (oci8 descriptor)
59+
}
60+
object(OCI-Lob)#%d (1) {
61+
["descriptor"]=>
62+
resource(%d) of type (oci8 descriptor)
63+
}
64+
object(OCI-Lob)#%d (1) {
65+
["descriptor"]=>
66+
resource(%d) of type (oci8 descriptor)
67+
}
68+
object(OCI-Lob)#%d (1) {
69+
["descriptor"]=>
70+
resource(%d) of type (oci8 descriptor)
71+
}
72+
73+
Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d
74+
NULL
75+
76+
Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d
77+
NULL
78+
79+
Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d
80+
NULL
81+
82+
Warning: oci_new_descriptor(): Unknown descriptor type %d. in %s on line %d
83+
NULL
84+
Done

ext/oci8/tests/lob_029.phpt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
--TEST--
2+
reading/writing BFILE LOBs
3+
--SKIPIF--
4+
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
5+
--FILE--
6+
<?php
7+
8+
require dirname(__FILE__).'/connect.inc';
9+
10+
$realdirname = dirname(__FILE__);
11+
$realfilename = "oci8bfiletest.txt";
12+
$fullname = $realdirname."/".$realfilename;
13+
14+
// Setup
15+
$s = oci_parse($c, "create directory TestDir as '$realdirname'");
16+
oci_execute($s);
17+
18+
file_put_contents($fullname, 'Some text in the bfile');
19+
20+
$s = oci_parse($c, "create table FileTest (FileNum number, FileDesc varchar2(30), Image bfile)");
21+
oci_execute($s);
22+
23+
$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (1, 'Description 1', bfilename('TESTDIR', '$realfilename'))");
24+
oci_execute($s);
25+
26+
// Run tests
27+
28+
echo "Test 1. Check how many rows in the table\n";
29+
30+
$s = oci_parse($c, "select count(*) numrows from FileTest");
31+
oci_execute($s);
32+
oci_fetch_all($s, $res);
33+
var_dump($res);
34+
35+
echo "Test 2\n";
36+
$s = oci_parse($c, "select * from FileTest");
37+
oci_execute($s);
38+
oci_fetch_all($s, $res);
39+
var_dump($res);
40+
41+
echo "Test 3\n";
42+
$d = oci_new_descriptor($c, OCI_D_FILE);
43+
44+
$s = oci_parse($c, "insert into FileTest (FileNum, FileDesc, Image) values (2, 'Description 2', bfilename('TESTDIR', '$realfilename')) returning Image into :im");
45+
oci_bind_by_name($s, ":im", $d, -1, OCI_B_BFILE);
46+
oci_execute($s);
47+
48+
$r = $d->read(40);
49+
var_dump($r);
50+
51+
unlink($fullname);
52+
53+
$s = oci_parse($c, "drop table FileTest");
54+
oci_execute($s);
55+
56+
$s = oci_parse($c, "drop directory TestDir");
57+
oci_execute($s);
58+
59+
echo "Done\n";
60+
?>
61+
--EXPECTF--
62+
Test 1. Check how many rows in the table
63+
array(1) {
64+
["NUMROWS"]=>
65+
array(1) {
66+
[0]=>
67+
string(1) "1"
68+
}
69+
}
70+
Test 2
71+
array(3) {
72+
["FILENUM"]=>
73+
array(1) {
74+
[0]=>
75+
string(1) "1"
76+
}
77+
["FILEDESC"]=>
78+
array(1) {
79+
[0]=>
80+
string(13) "Description 1"
81+
}
82+
["IMAGE"]=>
83+
array(1) {
84+
[0]=>
85+
string(22) "Some text in the bfile"
86+
}
87+
}
88+
Test 3
89+
string(22) "Some text in the bfile"
90+
Done

0 commit comments

Comments
 (0)