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