xref: /PHP-8.0/ext/oci8/tests/details.inc (revision 45475c2e)
1<?php
2
3/*
4 * Please change $user, $password and $dbase to match your configuration.
5 *
6 * Set $test_drcp to TRUE if you want to run the Oracle Database
7 * Resident Connection Pooling (DRCP) tests. For these tests to run
8 * successfully, you need a server and client which is Oracle 11g or
9 * greater, and $dbase should be set to the tnsnames.ora entry
10 * corresponding to the POOLED server instance or an Easy Connect
11 * string like hostname:port/service_name:POOLED
12 */
13
14if (file_exists(dirname(__FILE__)."/details_local.inc")) {
15    include(dirname(__FILE__)."/details_local.inc");   // this file is not part of the source distribution; make it your own local variant of details.inc
16} else {
17    if (false !== getenv('PHP_OCI8_TEST_DB')) {
18        $user		= getenv('PHP_OCI8_TEST_USER');	  // Database username for tests
19        $password	= getenv('PHP_OCI8_TEST_PASS');	  // Password for $user
20        $dbase		= getenv('PHP_OCI8_TEST_DB');	  // Database connection string
21        $test_drcp	= getenv('PHP_OCI8_TEST_DRCP');
22        if (false !== $test_drcp && 0 == strcasecmp($test_drcp,'TRUE')) {
23            $test_drcp = TRUE;
24        } else {
25            $test_drcp = FALSE;
26        }
27    } else {
28        $user						= "system";
29        $password					= "oracle";
30        $dbase						= "localhost/XE";
31        $test_drcp					= FALSE;
32    }
33
34    /*
35     * Common object names for scripts to use
36     */
37
38    $table_name = "tb".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5);
39    $type_name = strtoupper("tp".substr(str_replace(Array(".", "-"), "_", php_uname("n")), 0, 5));
40    $schema = '';
41}
42
43
44/*
45 * Used for creating/dropping schema objects used by a test
46 */
47
48if (!function_exists('oci8_test_sql_execute')) {
49    function oci8_test_sql_execute($c, $stmtarray)
50    {
51        foreach ($stmtarray as $stmt) {
52            $s = oci_parse($c, $stmt);
53            if (!$s) {
54                $m = oci_error($c);
55                echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL;
56            }
57            else {
58                $r = @oci_execute($s);
59                if (!$r) {
60                    $m = oci_error($s);
61                    if (!in_array($m['code'], array(   // ignore expected errors
62                                    942 // table or view does not exist
63                                ,  1918 // user does not exist
64                                ,  2024 // database link not found
65                                ,  2289 // sequence does not exist
66                                ,  4080 // trigger does not exist
67                                , 38802 // edition does not exist
68                            ))) {
69            echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL;
70                    }
71                }
72            }
73        }
74    }
75
76}
77
78?>