xref: /PHP-8.2/ext/oci8/tests/conn_attr_1.phpt (revision 93e509fd)
1--TEST--
2Set and get of connection attributes with all types of connections.
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7if (getenv('SKIP_REPEAT')) die('skip fails with repeat');
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require(__DIR__.'/skipif.inc');
10
11if (strcasecmp($user, "system") && strcasecmp($user, "sys"))
12    die("skip needs to be run as a DBA user");
13if ($test_drcp) die("skip output might vary with DRCP");
14
15preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
16if (!(isset($matches[0]) && $matches[1] >= 10)) {
17    die("skip expected output only valid when using Oracle 10g or greater database server");
18}
19?>
20--FILE--
21<?php
22
23$testuser     = 'testuser_attr_1';  // Used in conn_attr.inc
24$testpassword = 'testuser';
25
26require(__DIR__."/conn_attr.inc");
27
28$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
29
30echo"**Test 1.1 - Default values for the attributes **************\n";
31$c = get_conn(1);
32foreach($attr_array as $attr) {
33        get_attr($c,$attr);
34}
35
36echo"**Test 1.2 - Set and get values for the attributes **************\n";
37
38// With oci_connect, oci_pconnect, oci_new_connect
39
40$conn1 = get_conn(1); //oci_connect()
41foreach($attr_array as $attr) {
42    set_attr($conn1,$attr,1);
43    get_attr($conn1,$attr);
44}
45
46$conn2 = get_conn(2); //oci_pconnect()
47foreach($attr_array as $attr) {
48    set_attr($conn2,$attr,2);
49    get_attr($conn2,$attr);
50}
51
52$conn3 = get_conn(3); //oci_new_connect()
53foreach($attr_array as $attr) {
54    set_attr($conn3,$attr,3);
55    get_attr($conn3,$attr);
56}
57
58// clean up
59oci_close($conn1);
60oci_close($conn2);
61oci_close($conn3);
62clean_up($c);
63
64echo "Done\n";
65
66?>
67--EXPECTF--
68**Test 1.1 - Default values for the attributes **************
69Testing with oci_connect()
70The value of MODULE is %s
71The value of ACTION is
72The value of CLIENT_INFO is
73The value of CLIENT_IDENTIFIER is
74**Test 1.2 - Set and get values for the attributes **************
75Testing with oci_connect()
76Value of MODULE has been set successfully
77The value of MODULE is PHP TEST1
78Value of ACTION has been set successfully
79The value of ACTION is TASK1
80Value of CLIENT_INFO has been set successfully
81The value of CLIENT_INFO is INFO11
82Value of CLIENT_IDENTIFIER has been set successfully
83The value of CLIENT_IDENTIFIER is ID001
84Testing with oci_pconnect()
85Value of MODULE has been set successfully
86The value of MODULE is PHP TEST2
87Value of ACTION has been set successfully
88The value of ACTION is TASK2
89Value of CLIENT_INFO has been set successfully
90The value of CLIENT_INFO is INFO12
91Value of CLIENT_IDENTIFIER has been set successfully
92The value of CLIENT_IDENTIFIER is ID002
93Testing with oci_new_connect()
94Value of MODULE has been set successfully
95The value of MODULE is PHP TEST3
96Value of ACTION has been set successfully
97The value of ACTION is TASK3
98Value of CLIENT_INFO has been set successfully
99The value of CLIENT_INFO is INFO13
100Value of CLIENT_IDENTIFIER has been set successfully
101The value of CLIENT_IDENTIFIER is ID003
102Done
103