xref: /PHP-5.4/ext/oci8/tests/conn_attr_4.phpt (revision ac40c0b5)
1--TEST--
2Set and get of connection attributes with errors.
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request');
8
9if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
10if ($test_drcp) die("skip output might vary with DRCP");
11
12if (preg_match('/Release (11\.2|12)\./', oci_server_version($c), $matches) !== 1) {
13    // Bug fixed in 11.2 prevents client_info being rest
14	die("skip expected output only valid when using Oracle 11gR2 or greater database server");
15} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) {
16    die("skip test expected to work only with Oracle 10g or greater version of client");
17}
18?>
19--FILE--
20<?php
21
22
23require(dirname(__FILE__)."/conn_attr.inc");
24
25$user='testuser';
26$password='testuser';
27$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
28
29echo"**Test  Negative cases************\n";
30
31echo "\nInvalid Connection resource\n";
32$nc1=NULL;
33// Invalid connection handle.
34var_dump(oci_set_action($nc1,$nc1));
35
36// Variable instead of a connection resource.
37echo "\nInvalid Connection resource 2\n";
38$str1= 'not a conn';
39var_dump(oci_set_client_info($str1,$str1));
40
41// Setting an Invalid value.
42echo "\nInvalid Value \n";
43$c1=oci_connect($user,$password,$dbase);
44var_dump(oci_set_action($c1,$c1));
45
46// Setting values multiple times.
47echo "\nSet Values multiple times \n";
48var_dump(oci_set_action($c1,'ACTION1'));
49var_dump(oci_set_action($c1,'ACTION1'));
50var_dump(oci_set_action($c1,'ACTION2'));
51var_dump(oci_set_action($c1,'ACTION1'));
52get_attr($c1,'ACTION');
53
54// Testing with different types of values
55// NB.  This may diff in 11.1.0.6 due to a bug causing CLIENT_INFO of NULL to be ignored.
56echo "\nSetting to different values \n";
57$values_array = array(1000,NULL,'this is a very huge string with a length  > 64 !!!!!this is a very huge string with a length  > 64 !!!!!this is a very huge string with a length  > 64 !!!!!this is a very huge string with a length  > 64 !!!!!');
58
59foreach($values_array as $val ) {
60	oci_set_module_name($c1,$val);
61	oci_set_client_identifier($c1,$val);
62	oci_set_client_info($c1,$val);
63	$r = oci_set_action($c1,$val);
64	if ($r) {
65		echo "Values set successfully to $val\n";
66		foreach($attr_array as $attr) {
67            get_attr($c1,$attr);
68        }
69	}
70}
71
72clean_up($c);
73echo "Done\n";
74?>
75--EXPECTF--
76**Test  Negative cases************
77
78Invalid Connection resource
79
80Warning: oci_set_action() expects parameter 1 to be resource, null given in %s on line %d
81NULL
82
83Invalid Connection resource 2
84
85Warning: oci_set_client_info() expects parameter 1 to be resource, %s given in %s on line %d
86NULL
87
88Invalid Value
89
90Warning: oci_set_action() expects parameter 2 to be %s, resource given in %s on line %d
91NULL
92
93Set Values multiple times
94bool(true)
95bool(true)
96bool(true)
97bool(true)
98The value of ACTION is ACTION1
99
100Setting to different values
101Values set successfully to 1000
102The value of MODULE is 1000
103The value of ACTION is 1000
104The value of CLIENT_INFO is 1000
105The value of CLIENT_IDENTIFIER is 1000
106Values set successfully to
107The value of MODULE is
108The value of ACTION is
109The value of CLIENT_INFO is
110The value of CLIENT_IDENTIFIER is
111
112Warning: oci_set_module_name(): ORA-24960: %s OCI_ATTR_MODULE %s on line %d
113
114Warning: oci_set_client_identifier(): ORA-24960: %s OCI_ATTR_CLIENT_IDENTIFIER %s on line %d
115
116Warning: oci_set_client_info(): ORA-24960: %s OCI_ATTR_CLIENT_INFO %s on line %d
117
118Warning: oci_set_action(): ORA-24960: %s OCI_ATTR_ACTION %s on line %d
119Done
120