xref: /PHP-8.1/ext/oci8/tests/bug42134.phpt (revision b5a14e6c)
1--TEST--
2Bug #42134 (Collection error for invalid collection name)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require(__DIR__.'/details.inc');
14
15// Test collection creation error for normal connection
16
17if (!empty($dbase)) {
18    $c = oci_connect($user,$password,$dbase);
19}
20else {
21    $c = oci_connect($user,$password);
22}
23
24$collection = oci_new_collection($c, "ABC");
25if (!$collection) {
26    echo "Normal connection: New Collection error\n";
27    $m = oci_error($c);
28    var_dump($m);
29}
30
31// Test collection creation error for new connection
32
33if (!empty($dbase)) {
34    $c = oci_new_connect($user,$password,$dbase);
35}
36else {
37    $c = oci_new_connect($user,$password);
38}
39
40$collection = oci_new_collection($c, "DEF");
41if (!$collection) {
42    echo "New connection: New Collection error\n";
43    $m = oci_error($c);
44    var_dump($m);
45}
46
47// Test collection creation error for persistent connection
48
49if (!empty($dbase)) {
50    $c = oci_pconnect($user,$password,$dbase);
51}
52else {
53    $c = oci_pconnect($user,$password);
54}
55
56$collection = oci_new_collection($c, "GHI");
57if (!$collection) {
58    echo "Persistent connection: New Collection error\n";
59    $m = oci_error($c);
60    var_dump($m);
61}
62
63echo "Done\n";
64
65?>
66--EXPECTF--
67Warning: oci_new_collection(): OCI-22303: type ""."ABC" not found in %s on line %d
68Normal connection: New Collection error
69array(4) {
70  ["code"]=>
71  int(22303)
72  ["message"]=>
73  string(34) "OCI-22303: type ""."ABC" not found"
74  ["offset"]=>
75  int(0)
76  ["sqltext"]=>
77  string(0) ""
78}
79
80Warning: oci_new_collection(): OCI-22303: type ""."DEF" not found in %s on line %d
81New connection: New Collection error
82array(4) {
83  ["code"]=>
84  int(22303)
85  ["message"]=>
86  string(34) "OCI-22303: type ""."DEF" not found"
87  ["offset"]=>
88  int(0)
89  ["sqltext"]=>
90  string(0) ""
91}
92
93Warning: oci_new_collection(): OCI-22303: type ""."GHI" not found in %s on line %d
94Persistent connection: New Collection error
95array(4) {
96  ["code"]=>
97  int(22303)
98  ["message"]=>
99  string(34) "OCI-22303: type ""."GHI" not found"
100  ["offset"]=>
101  int(0)
102  ["sqltext"]=>
103  string(0) ""
104}
105Done
106