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