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 12preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); 13if (!(isset($matches[0]) && 14 (($matches[1] == 11 && $matches[2] >= 2) || 15 ($matches[1] >= 12) 16 ))) { 17 // Bug fixed in 11.2 prevents client_info being reset 18 die("skip expected output only valid when using Oracle 11gR2 or greater database server"); 19} 20?> 21--FILE-- 22<?php 23 24$testuser = 'testuser_attr_4'; // Used in conn_attr.inc 25$testpassword = 'testuser'; 26 27require(dirname(__FILE__)."/conn_attr.inc"); 28 29$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); 30 31echo"**Test Negative cases************\n"; 32 33echo "\nInvalid Connection resource\n"; 34$nc1=NULL; 35// Invalid connection handle. 36var_dump(oci_set_action($nc1,$nc1)); 37 38// Variable instead of a connection resource. 39echo "\nInvalid Connection resource 2\n"; 40$str1= 'not a conn'; 41var_dump(oci_set_client_info($str1,$str1)); 42 43// Setting an Invalid value. 44echo "\nInvalid Value \n"; 45$c1=oci_connect($testuser,$testpassword,$dbase); 46var_dump(oci_set_action($c1,$c1)); 47 48// Setting values multiple times. 49echo "\nSet Values multiple times \n"; 50var_dump(oci_set_action($c1,'ACTION1')); 51var_dump(oci_set_action($c1,'ACTION1')); 52var_dump(oci_set_action($c1,'ACTION2')); 53var_dump(oci_set_action($c1,'ACTION1')); 54get_attr($c1,'ACTION'); 55 56// Testing with different types of values 57// NB. This may diff in 11.1.0.6 due to a bug causing CLIENT_INFO of NULL to be ignored. 58echo "\nSetting to different values \n"; 59$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 !!!!!'); 60 61foreach($values_array as $val ) { 62 oci_set_module_name($c1,$val); 63 oci_set_client_identifier($c1,$val); 64 oci_set_client_info($c1,$val); 65 $r = oci_set_action($c1,$val); 66 if ($r) { 67 echo "Values set successfully to $val\n"; 68 foreach($attr_array as $attr) { 69 get_attr($c1,$attr); 70 } 71 } 72} 73 74clean_up($c); 75echo "Done\n"; 76?> 77--EXPECTF-- 78**Test Negative cases************ 79 80Invalid Connection resource 81 82Warning: oci_set_action() expects parameter 1 to be resource, null given in %s on line %d 83NULL 84 85Invalid Connection resource 2 86 87Warning: oci_set_client_info() expects parameter 1 to be resource, %s given in %s on line %d 88NULL 89 90Invalid Value 91 92Warning: oci_set_action() expects parameter 2 to be %s, resource given in %s on line %d 93NULL 94 95Set Values multiple times 96bool(true) 97bool(true) 98bool(true) 99bool(true) 100The value of ACTION is ACTION1 101 102Setting to different values 103Values set successfully to 1000 104The value of MODULE is 1000 105The value of ACTION is 1000 106The value of CLIENT_INFO is 1000 107The value of CLIENT_IDENTIFIER is 1000 108Values set successfully to 109The value of MODULE is 110The value of ACTION is 111The value of CLIENT_INFO is 112The value of CLIENT_IDENTIFIER is 113 114Warning: oci_set_module_name(): ORA-24960: %s OCI_ATTR_MODULE %s on line %d 115 116Warning: oci_set_client_identifier(): ORA-24960: %s OCI_ATTR_CLIENT_IDENTIFIER %s on line %d 117 118Warning: oci_set_client_info(): ORA-24960: %s OCI_ATTR_CLIENT_INFO %s on line %d 119 120Warning: oci_set_action(): ORA-24960: %s OCI_ATTR_ACTION %s on line %d 121Done 122