Annotation of embedaddon/php/ext/oci8/tests/error_parse.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test error handling when persistent connection is passed to oci_error()
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: // As part of the fix for Bug 42134, an error handling difference was
                      9: // noticed when oci_error() was passed a persistent connection.  This
                     10: // was fixed and the behavior of oci_error() for all connections types
                     11: // was made consistent.
                     12: 
                     13: require(dirname(__FILE__).'/details.inc');
                     14: 
                     15: // Test parse error for normal connection
                     16: 
                     17: if (!empty($dbase)) {
                     18:        $c1 = oci_connect($user,$password,$dbase);
                     19: }
                     20: else {
                     21:        $c1 = oci_connect($user,$password);
                     22: }
                     23: 
                     24: $s = @oci_parse($c1, "select ' from dual");
                     25: if (!$s) {
                     26:        echo "Normal connection: Parse error\n";
                     27:        $m = oci_error($c1);
                     28:        var_dump($m);
                     29: }
                     30: 
                     31: // Test parse error for new connection
                     32: 
                     33: if (!empty($dbase)) {
                     34:        $c2 = oci_new_connect($user,$password,$dbase);
                     35: }
                     36: else {
                     37:        $c2 = oci_new_connect($user,$password);
                     38: }
                     39: 
                     40: $s = @oci_parse($c2, "select ' from dual");
                     41: if (!$s) {
                     42:        echo "New connection: Parse error\n";
                     43:        $m = oci_error($c2);
                     44:        var_dump($m);
                     45: }
                     46: 
                     47: // Test parse error for persistent connection
                     48: 
                     49: if (!empty($dbase)) {
                     50:        $c3 = oci_pconnect($user,$password,$dbase);
                     51: }
                     52: else {
                     53:        $c3 = oci_pconnect($user,$password);
                     54: }
                     55: 
                     56: $s = @oci_parse($c3, "select ' from dual");
                     57: if (!$s) {
                     58:        echo "Persistent connection: Parse error\n";
                     59:        $m = oci_error($c3);
                     60:        var_dump($m);
                     61: }
                     62: 
                     63: // Verify that passing no connection doesn't affect future calls
                     64: 
                     65: $m = oci_error();
                     66: echo "No connection: error: ";
                     67: var_dump($m);
                     68: 
                     69: // Check the errors are still accessible in the respective handles
                     70: 
                     71: $m = oci_error($c1);
                     72: echo "Normal connection (take #2): Parse error: ";
                     73: echo $m["message"], "\n";
                     74: 
                     75: $m = oci_error($c2);
                     76: echo "New connection (take #2): Parse error: ";
                     77: echo $m["message"], "\n";
                     78: 
                     79: $m = oci_error($c3);
                     80: echo "Persistent connection (take #2): Parse error: ";
                     81: echo $m["message"], "\n";
                     82: 
                     83: // Now create a new error for a normal connection and check all again
                     84: 
                     85: $s = @oci_new_collection($c1, "ABC");
                     86: $m = oci_error($c1);
                     87: echo "Normal connection: New Collection error: ";
                     88: echo $m["message"], "\n";
                     89: 
                     90: $m = oci_error($c2);
                     91: echo "New connection (take #3): Parse error: ";
                     92: echo $m["message"], "\n";
                     93: 
                     94: $m = oci_error($c3);
                     95: echo "Persistent connection (take #3): Parse error: ";
                     96: echo $m["message"], "\n";
                     97: 
                     98: echo "Done\n";
                     99: 
                    100: ?>
                    101: --EXPECTF--
                    102: Normal connection: Parse error
                    103: array(4) {
                    104:   ["code"]=>
                    105:   int(1756)
                    106:   ["message"]=>
                    107:   string(48) "ORA-01756: %s"
                    108:   ["offset"]=>
                    109:   int(0)
                    110:   ["sqltext"]=>
                    111:   string(0) ""
                    112: }
                    113: New connection: Parse error
                    114: array(4) {
                    115:   ["code"]=>
                    116:   int(1756)
                    117:   ["message"]=>
                    118:   string(48) "ORA-01756: %s"
                    119:   ["offset"]=>
                    120:   int(0)
                    121:   ["sqltext"]=>
                    122:   string(0) ""
                    123: }
                    124: Persistent connection: Parse error
                    125: array(4) {
                    126:   ["code"]=>
                    127:   int(1756)
                    128:   ["message"]=>
                    129:   string(48) "ORA-01756: %s"
                    130:   ["offset"]=>
                    131:   int(0)
                    132:   ["sqltext"]=>
                    133:   string(0) ""
                    134: }
                    135: No connection: error: bool(false)
                    136: Normal connection (take #2): Parse error: ORA-01756: %s
                    137: New connection (take #2): Parse error: ORA-01756: %s
                    138: Persistent connection (take #2): Parse error: ORA-01756: %s
                    139: Normal connection: New Collection error: OCI-22303: type ""."ABC" not found
                    140: New connection (take #3): Parse error: ORA-01756: %s
                    141: Persistent connection (take #3): Parse error: ORA-01756: %s
                    142: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>