1--TEST--
2PDO Common: Pass credentials in dsn instead of constructor params
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9
10$driver = substr(getenv('PDOTEST_DSN'), 0, strpos(getenv('PDOTEST_DSN'), ':'));
11if (!in_array($driver, array('mssql','sybase','dblib','firebird','mysql','oci')))
12    die('skip not supported');
13
14require_once $dir . 'pdo_test.inc';
15PDOTest::skip();
16?>
17--FILE--
18<?php
19    require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
20
21    $orgDsn = getenv('PDOTEST_DSN');
22    $orgUser = getenv('PDOTEST_USER');
23    $orgPass = getenv('PDOTEST_PASS');
24
25    try
26    {
27        putenv("PDOTEST_DSN=$orgDsn;user=$orgUser;password=$orgPass");
28        putenv("PDOTEST_USER");
29        putenv("PDOTEST_PASS");
30
31        $link = PDOTest::factory();
32        echo "using credentials in dsn: done\n";
33
34
35        // test b/c - credentials in DSN are ignored when user/pass passed as separate params
36        putenv("PDOTEST_DSN=$orgDsn;user=incorrect;password=ignored");
37        putenv("PDOTEST_USER=$orgUser");
38        putenv("PDOTEST_PASS=$orgPass");
39
40        $link = PDOTest::factory();
41        echo "ignoring credentials in dsn: done\n";
42    }
43    finally
44    {
45        putenv("PDOTEST_DSN=$orgDsn");
46        putenv("PDOTEST_USER=$orgUser");
47        putenv("PDOTEST_PASS=$orgPass");
48    }
49?>
50--EXPECT--
51using credentials in dsn: done
52ignoring credentials in dsn: done
53