summaryrefslogtreecommitdiff
path: root/ext/dbx/tests/003.phpt
blob: 76fda4caf27aea2518b1171c08a01e192802b4bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--TEST--
dbx_connect
--SKIPIF--
<?php 
include_once("skipif.inc");
?>
--FILE--
<?php 
include_once("dbx_test.p");
$nonexisting_database="nonexisting_database";
$nonexisting_username="nonexisting_username";
$nonexisting_password="nonexisting_password";
$dlo = dbx_connect($module_name, $host, $database, $username, $password);
if ($dlo!=0) {
	print('connect using string ok'."\n");
	dbx_close($dlo);
	}
$dlo = dbx_connect($module, $host, $database, $username, $password);
if ($dlo!=0) {
	print('connect using constant ok'."\n");
	dbx_close($dlo);
	}
$dlo = @dbx_connect($module, $host, $nonexisting_database, $username, $password);
if ($dlo==0) {
	print('connect to non-existing database failed, so it\'s ok'."\n");
	}
else {
    print_r($dlo);
	dbx_close($dlo);
    }
$dlo = @dbx_connect($module, $host, $database, $nonexisting_username, $nonexisting_password);
if ($dlo==0) {
	print('connect with false username/password combi failed, so it\'s ok'."\n");
	}
else {
    print_r($dlo);
	dbx_close($dlo);
    }
$dlo = dbx_connect($module_name, $host, $database, $username, $password, DBX_PERSISTENT);
if ($dlo!=0) {
	print('persistent connect using string ok'."\n");
	dbx_close($dlo);
	}
$dlo = dbx_connect($module, $host, $database, $username, $password, DBX_PERSISTENT);
if ($dlo!=0) {
	print('persistent connect using constant ok'."\n");
	dbx_close($dlo);
	}
$dlo = @dbx_connect($module, $host, $nonexisting_database, $username, $password, DBX_PERSISTENT);
if ($dlo==0) {
	print('persistent connect to non-existing database failed, so it\'s ok'."\n");
	}
else {
    print_r($dlo);
	dbx_close($dlo);
    }
$dlo = @dbx_connect($module, $host, $database, $nonexisting_username, $nonexisting_password, DBX_PERSISTENT);
if ($dlo==0) {
	print('persistent connect with false username/password combi failed, so it\'s ok'."\n");
	}
else {
    print_r($dlo);
	dbx_close($dlo);
    }
$dlo = @dbx_connect($module, $host, $database, $username, $password, DBX_PERSISTENT, "12many");
if ($dlo==0) {
	print('too many parameters: connect failure works ok'."\n");
	}
else {
    print_r($dlo);
	dbx_close($dlo);
    }
$dlo = @dbx_connect($module, $host, $database, $username);
if ($dlo==0) {
	print('too few parameters: connect failure works ok'."\n");
	}
else {
    print_r($dlo);
	dbx_close($dlo);
    }
$dlo1 = dbx_connect($module, $host, $database, $username, $password);
$dlo2 = dbx_connect($module, $host, $database, $username, $password);
if ($dlo1!=0 && $dlo2!=0) {
	print('multiple connects ok'."\n");
	dbx_close($dlo1);
	dbx_close($dlo2);
	}
$dlo1 = dbx_connect($module, $host, $database, $username, $password);
$dlo2 = @dbx_connect($module, $host, $nonexisting_database, $username, $password);
if ($dlo1!=0 && $dlo2==0) {
    print('multiple connects (2nd fails on database-name) ok'."\n");
	dbx_close($dlo1);
	}
?>
--EXPECT--
connect using string ok
connect using constant ok
connect to non-existing database failed, so it's ok
connect with false username/password combi failed, so it's ok
persistent connect using string ok
persistent connect using constant ok
persistent connect to non-existing database failed, so it's ok
persistent connect with false username/password combi failed, so it's ok
too many parameters: connect failure works ok
too few parameters: connect failure works ok
multiple connects ok
multiple connects (2nd fails on database-name) ok