Skip to content

Commit 2619c7b

Browse files
Move pdo_dsn_containing_credentials from pdo_mysql to pdo
1 parent 5e1a99e commit 2619c7b

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
PDO Common: Pass credentials in dsn instead of constructor params
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo')) die('skip');
6+
$dir = getenv('REDIR_TEST_DIR');
7+
if (false == $dir) die('skip no driver');
8+
9+
$driver = substr(getenv('PDOTEST_DSN'), 0, strpos(getenv('PDOTEST_DSN'), ':'));
10+
if (!in_array($driver, array('mssql','sybase','dblib','firebird','mysql','oci')))
11+
die('not supported');
12+
13+
require_once $dir . 'pdo_test.inc';
14+
PDOTest::skip();
15+
?>
16+
--FILE--
17+
<?php
18+
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
19+
20+
class PDOTestDiscardCredentialParams extends PDOTest {
21+
public function __construct($dsn, $user, $pass, $attr) {
22+
return parent::__construct($dsn, null, null, $attr);
23+
}
24+
}
25+
26+
$link = PDOTestDiscardCredentialParams::factory('PDO', false, null, ['user' => getenv('PDOTEST_USER'), 'password' => getenv('PDOTEST_PASS')]);
27+
echo "using credentials in dsn: done\n";
28+
29+
// test b/c - credentials in DSN are ignored when user/pass passed as separate params
30+
$link = PDOTest::factory('PDO', false, null, ['user' => 'incorrect', 'password' => 'ignored']);
31+
echo "ignoring credentials in dsn: done\n";
32+
?>
33+
--EXPECTF--
34+
using credentials in dsn: done
35+
ignoring credentials in dsn: done

ext/pdo_mysql/tests/pdo_mysql_dsn_containing_credentials.phpt

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)