@@ -6,23 +6,42 @@ if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not lo
6
6
require dirname (__FILE__ ) . '/config.inc ' ;
7
7
require dirname (__FILE__ ) . '/../../../ext/pdo/tests/pdo_test.inc ' ;
8
8
PDOTest::skip ();
9
- if (!isset ($ conf ['ENV ' ]['PDOTEST_DSN ' ])) die ('no dsn found in env ' );
9
+
10
+ $ dsn = getenv ('PDOTEST_DSN ' );
11
+ if (empty ($ dsn )) die ('skip no dsn found in env ' );
12
+
10
13
$ db = PDOTest::test_factory (dirname (__FILE__ ) . '/common.phpt ' );
11
- $ rand = rand (5 , 5 );
14
+ $ db ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
15
+
16
+
17
+ $ user = 'pdo_test_ ' .rand (5 , 400 );
18
+ $ pass = 'testpass ' ;
19
+
20
+ // Assume that if we can't create or drop a user, this test needs to be skipped
21
+ try {
22
+ $ db ->exec ("DROP USER IF EXISTS $ user " );
23
+ $ db ->exec ("CREATE USER $ user WITH PASSWORD ' $ pass' " );
24
+ } catch (PDOException $ e ) {
25
+ die ("skip You need CREATEUSER permissions to run the test " );
26
+ }
27
+
28
+ // Peer authentication might prevent the test from properly running
29
+ try {
30
+ $ testConn = new PDO ($ dsn , $ user , $ pass );
31
+ } catch (PDOException $ e ) {
32
+ echo "skip " .$ e ->getMessage ();
33
+ }
34
+
35
+ $ db ->exec ("DROP USER $ user " );
12
36
13
- // Assume that if we can't create a user, this test needs to be skipped
14
- $ testQuery = "CREATE USER pdo_ $ rand WITH PASSWORD 'testpass' " ;
15
- $ db ->query ($ testQuery );
16
- $ testQuery = "DROP USER pdo_ $ rand " ;
17
- $ db ->query ($ testQuery );
18
37
?>
19
38
--FILE--
20
39
<?php
21
40
require dirname (__FILE__ ) . '/../../../ext/pdo/tests/pdo_test.inc ' ;
22
41
$ pdo = PDOTest::test_factory (dirname (__FILE__ ) . '/common.phpt ' );
23
42
$ pdo ->setAttribute (PDO ::ATTR_EMULATE_PREPARES , true );
24
43
$ rand = rand (5 , 400 );
25
- $ user = "pdo_ $ rand " ;
44
+ $ user = "pdo_test_ $ rand " ;
26
45
$ template = "CREATE USER $ user WITH PASSWORD '%s' " ;
27
46
$ dropUser = "DROP USER $ user " ;
28
47
$ testQuery = 'SELECT 1 as verification ' ;
0 commit comments