xref: /PHP-5.4/ext/oci8/tests/edition_2.phpt (revision c7a8bd6a)
1--TEST--
2Set and check Oracle 11gR2 "edition" attribute
3--SKIPIF--
4<?php
5if (!extension_loaded('oci8')) die("skip no oci8 extension");
6require(dirname(__FILE__)."/connect.inc");
7if (strcasecmp($user, "system") && strcasecmp($user, "sys"))
8    die("skip needs to be run as a DBA user");
9if ($test_drcp)
10    die("skip as Output might vary with DRCP");
11
12if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== 1) {
13	die("skip expected output only valid when using Oracle 11gR2 or greater databases");
14} else if (preg_match('/^(11\.2|12)\./', oci_client_version()) != 1) {
15    die("skip test expected to work only with Oracle 11gR2 or greater version of client");
16}
17
18?>
19--FILE--
20<?php
21
22/* In 11.2, there can only be one child edition.  So this test will
23 * fail to create the necessary editions if a child edition exists
24 * already
25 */
26
27require(dirname(__FILE__)."/conn_attr.inc");
28
29$user = 'testuser';
30$password = 'testuser';
31
32echo"**Test 1.1 - Default value for  the attribute **************\n";
33get_edit_attr($c);
34
35echo"\n\n**Test 1.2 - Set a value and get the same with different connections *********\n";
36set_edit_attr('MYEDITION');
37
38// With oci_connect, oci_pconnect, oci_new_connect
39$conn1 = get_conn(1);
40get_edit_attr($conn1);
41
42//pconnect
43$conn2 = get_conn(2);
44get_edit_attr($conn2);
45
46//new_connect
47$conn3 = get_conn(3);
48get_edit_attr($conn3);
49
50oci_close($conn1);
51
52// With a oci_pconnect with a different charset.
53$pc1 = oci_pconnect($user,$password,$dbase,"utf8");
54get_edit_attr($pc1);
55oci_close($pc1);
56
57
58echo"\n\n**Test 1.3 change the value and verify with existing conenctions.*********\n";
59set_edit_attr('MYEDITION1');
60get_edit_attr($conn2);
61get_edit_attr($conn3); // Old value
62oci_close($conn2);
63oci_close($conn3);
64
65//open a new connection and get the edition value . This will have the updated value.
66$c3 = get_conn(3); //oci_new_connect()
67get_edit_attr($c3);
68
69$c4 = get_conn(2); //oci_pconnect()
70get_edit_attr($c4);
71
72$c5 = get_conn(1); //oci_connect()
73get_edit_attr($c5);
74
75oci_close($c3);
76oci_close($c4);
77oci_close($c5);
78
79echo "\n\n**Test 1.4 - with different type of values *********\n";
80$values_array = array(123,NULL,'NO EDITION','edition name which has more than thirty chars!!!edition name which has more than thirty chars!!!');
81foreach ($values_array as $val ) {
82	set_edit_attr($val);
83	$c1 = get_conn(1); //oci_connect()
84	if ($c1) {
85		get_edit_attr($c1);
86		oci_close($c1);
87	}
88}
89
90echo "\n\n**Test 1.5 - Negative case with an invalid string value. *********\n";
91$c1 = get_conn(3);
92$r = set_edit_attr($c1);
93
94echo"\n\n**Test 1.6 - Set Multiple times.*****\n";
95set_edit_attr('MYEDITION');
96set_edit_attr('MYEDITION1');
97$c1 = get_conn(1);
98get_edit_attr($c1);
99oci_close($c1);
100
101echo "\n\n**Test 1.7 - Test with ALTER SESSION statement to change the edition *******\n";
102// Set the edition value to MYEDITION. open a conn .get the value.
103// execute the alter system set edition ='MYEDITION' .get the value .
104// set it back to MYEDITION using oci_set_edition. and get the value.
105
106set_edit_attr('MYEDITION');
107$c1 = get_conn(3);
108echo "get the value set to MYEDITION with oci_set_edition \n";
109get_edit_attr($c1);
110
111$alter_stmt = "alter session set edition = MYEDITION1";
112$s = oci_parse($c1,$alter_stmt);
113oci_execute($s);
114oci_commit($c1);
115echo "Get the value set to MYEDITION1 with alter session\n";
116get_edit_attr($c1);
117
118echo " Get the value with a new connection \n";
119$c2 = get_conn(1);
120get_edit_attr($c2);
121
122echo " Set the value back using oci-set_edition\n";
123set_edit_attr('MYEDITION');
124get_edit_attr($c2);
125
126echo " Get the value with a new conenction \n";
127$c3 = get_conn(1);
128get_edit_attr($c3);
129
130oci_close($c1);
131oci_close($c2);
132oci_close($c3);
133
134
135echo "\n\n**Test 1.8 - Test setting the attribute with scope ends*******\n";
136set_scope();
137get_scope();
138
139clean_up($c);
140echo "Done\n";
141
142
143function set_scope() {
144	$r = set_edit_attr('MYEDITION1');
145}
146
147function get_scope() {
148    $sc1 = oci_connect($GLOBALS['user'],$GLOBALS['password'],$GLOBALS['dbase']);
149    if ($sc1 === false) {
150        $m = oci_error();
151        die("Error:" . $m['message']);
152    }
153	get_edit_attr($sc1);
154	oci_close($sc1);
155}
156?>
157--EXPECTF--
158**Test 1.1 - Default value for  the attribute **************
159The value of current EDITION is ORA$BASE
160
161
162**Test 1.2 - Set a value and get the same with different connections *********
163 The value of edition has been successfully set
164Testing with oci_connect()
165The value of current EDITION is MYEDITION
166Testing with oci_pconnect()
167The value of current EDITION is MYEDITION
168Testing with oci_new_connect()
169The value of current EDITION is MYEDITION
170The value of current EDITION is MYEDITION
171
172
173**Test 1.3 change the value and verify with existing conenctions.*********
174 The value of edition has been successfully set
175The value of current EDITION is MYEDITION
176The value of current EDITION is MYEDITION
177Testing with oci_new_connect()
178The value of current EDITION is MYEDITION1
179Testing with oci_pconnect()
180The value of current EDITION is MYEDITION1
181Testing with oci_connect()
182The value of current EDITION is MYEDITION1
183
184
185**Test 1.4 - with different type of values *********
186 The value of edition has been successfully set
187Testing with oci_connect()
188
189Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
190 The value of edition has been successfully set
191Testing with oci_connect()
192The value of current EDITION is ORA$BASE
193 The value of edition has been successfully set
194Testing with oci_connect()
195
196Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
197 The value of edition has been successfully set
198Testing with oci_connect()
199
200Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
201
202
203**Test 1.5 - Negative case with an invalid string value. *********
204Testing with oci_new_connect()
205
206Warning: oci_new_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
207 The value of edition has been successfully set
208
209
210**Test 1.6 - Set Multiple times.*****
211 The value of edition has been successfully set
212 The value of edition has been successfully set
213Testing with oci_connect()
214The value of current EDITION is MYEDITION1
215
216
217**Test 1.7 - Test with ALTER SESSION statement to change the edition *******
218 The value of edition has been successfully set
219Testing with oci_new_connect()
220get the value set to MYEDITION with oci_set_edition
221The value of current EDITION is MYEDITION
222Get the value set to MYEDITION1 with alter session
223The value of current EDITION is MYEDITION1
224 Get the value with a new connection
225Testing with oci_connect()
226The value of current EDITION is MYEDITION
227 Set the value back using oci-set_edition
228 The value of edition has been successfully set
229The value of current EDITION is MYEDITION
230 Get the value with a new conenction
231Testing with oci_connect()
232The value of current EDITION is MYEDITION
233
234
235**Test 1.8 - Test setting the attribute with scope ends*******
236 The value of edition has been successfully set
237The value of current EDITION is MYEDITION1
238Done
239
240