Skip to content

Commit c6afdf8

Browse files
committed
Fix PDO URI test
1 parent 0df2886 commit c6afdf8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ext/pdo_mysql/tests/pdo_mysql___construct_uri.phpt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ MySQLPDOTest::skip();
1818
$dsn = MySQLPDOTest::getDSN();
1919
$user = PDO_MYSQL_TEST_USER;
2020
$pass = PDO_MYSQL_TEST_PASS;
21-
$uri = sprintf('uri:file://%s', (substr(PHP_OS, 0, 3) == 'WIN' ? str_replace('\\', '/', $file) : $file));
21+
$uri = 'uri:file://' . $file;
2222

2323
if ($fp = @fopen($file, 'w')) {
2424
// ok, great we can create a file with a DSN in it
@@ -38,8 +38,8 @@ MySQLPDOTest::skip();
3838
}
3939

4040
if ($fp = @fopen($file, 'w')) {
41-
fwrite($fp, sprintf('mysql:dbname=letshopeinvalid;%s%s',
42-
chr(0), $dsn));
41+
$dsnUnknownDatabase = preg_replace('~dbname=[^;]+~', 'dbname=letshopeinvalid', $dsn);
42+
fwrite($fp, $dsnUnknownDatabase);
4343
fclose($fp);
4444
clearstatcache();
4545
assert(file_exists($file));
@@ -49,9 +49,8 @@ MySQLPDOTest::skip();
4949
$expected = array(
5050
"SQLSTATE[HY000] [1049] Unknown database 'letshopeinvalid'",
5151
"SQLSTATE[42000] [1049] Unknown database 'letshopeinvalid'",
52-
"SQLSTATE[HY000] [2002] No such file or directory"
5352
);
54-
printf("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), chr(0) test, %s\n",
53+
printf("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), %s\n",
5554
$uri, $dsn,
5655
$file, filesize($file), file_get_contents($file),
5756
(in_array($e->getMessage(), $expected) ? 'EXPECTED ERROR' : $e->getMessage()));
@@ -73,5 +72,5 @@ MySQLPDOTest::skip();
7372
print "done!";
7473
?>
7574
--EXPECTF--
76-
[003] URI=uri:file://%spdomuri.tst, DSN=mysql%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql%sdbname=letshopeinvalid%s'), chr(0) test, EXPECTED ERROR
75+
[003] URI=uri:file://%spdomuri.tst, DSN=mysql:%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql:%sdbname=letshopeinvalid%S'), EXPECTED ERROR
7776
done!

0 commit comments

Comments
 (0)