xref: /PHP-7.2/ext/oci8/tests/coll_019.phpt (revision bdd67d81)
1--TEST--
2Test collection Oracle error handling collections and numbers (2)
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__)."/connect.inc";
12
13$ora_sql = "DROP TYPE ".$type_name;
14$statement = oci_parse($c,$ora_sql);
15@oci_execute($statement);
16
17
18echo "Test 0\n";
19$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF BLOB";
20$statement = oci_parse($c,$ora_sql);
21oci_execute($statement);
22
23$coll1 = oci_new_collection($c, $type_name);
24
25var_dump($coll1->append('a long string'));              // invalid type for append
26var_dump($coll1->assignElem(1, 'a long string')); 	// invalid type for assignelem()
27var_dump($coll1->getElem(0));
28
29require dirname(__FILE__)."/drop_type.inc";
30
31echo "Test 1\n";
32$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF NUMBER";
33$statement = oci_parse($c,$ora_sql);
34oci_execute($statement);
35
36$coll1 = oci_new_collection($c, $type_name);
37
38var_dump($coll1->assignElem(1, null));			// invalid location for null
39var_dump($coll1->getElem(0));
40
41echo "Test 2\n";
42var_dump($coll1->assignElem(1, 1234));  		// invalid location for number
43var_dump($coll1->getElem(0));
44
45require dirname(__FILE__)."/drop_type.inc";
46
47echo "Test 3\n";
48$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF VARCHAR2(1)";
49$statement = oci_parse($c,$ora_sql);
50oci_execute($statement);
51
52$coll1 = oci_new_collection($c, $type_name);
53
54var_dump($coll1->assignElem(1, 'abc')); 		// invalid location for string
55var_dump($coll1->getElem(0));
56
57require dirname(__FILE__)."/drop_type.inc";
58
59echo "Test 4\n";
60$ora_sql = "CREATE TYPE ".$type_name." AS TABLE OF DATE";
61$statement = oci_parse($c,$ora_sql);
62oci_execute($statement);
63
64$coll1 = oci_new_collection($c, $type_name);
65
66var_dump($coll1->append(1));                   		// invalid date format
67var_dump($coll1->assignElem(1, '01-JAN-06'));  		// invalid location for date
68var_dump($coll1->getElem(0));
69
70require dirname(__FILE__)."/drop_type.inc";
71
72echo "Done\n";
73
74?>
75--EXPECTF--
76Test 0
77
78Notice: OCI-Collection::append(): Unknown or unsupported type of element: 113 in %s on line %d
79bool(false)
80
81Notice: OCI-Collection::assignelem(): Unknown or unsupported type of element: 113 in %s on line %d
82bool(false)
83bool(false)
84Test 1
85
86Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
87bool(false)
88bool(false)
89Test 2
90
91Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
92bool(false)
93bool(false)
94Test 3
95
96Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
97bool(false)
98bool(false)
99Test 4
100
101Warning: OCI-Collection::append(): OCI-01840: input value not long enough for date format in %s on line %d
102bool(false)
103
104Warning: OCI-Collection::assignelem(): OCI-22165: given index [1] must be in the range of %s in %s on line %d
105bool(false)
106bool(false)
107Done
108