@@ -19,10 +19,9 @@ MySQLPDOTest::skip();
19
19
$ dsn = MySQLPDOTest::getDSN ();
20
20
$ user = PDO_MYSQL_TEST_USER ;
21
21
$ pass = PDO_MYSQL_TEST_PASS ;
22
- $ uri = sprintf ( 'uri:file://%s ' , ( substr ( PHP_OS , 0 , 3 ) == ' WIN ' ? str_replace ( '\\' , ' / ' , $ file) : $ file )) ;
22
+ $ uri = 'uri:file:// ' . $ file ;
23
23
24
24
if ($ fp = @fopen ($ file , 'w ' )) {
25
- // ok, great we can create a file with a DSN in it
26
25
fwrite ($ fp , $ dsn );
27
26
fclose ($ fp );
28
27
clearstatcache ();
@@ -39,38 +38,23 @@ MySQLPDOTest::skip();
39
38
}
40
39
41
40
if ($ fp = @fopen ($ file , 'w ' )) {
42
- fwrite ($ fp , sprintf ('mysql:dbname=letshopeinvalid;%s%s ' ,
43
- chr (0 ), $ dsn ));
41
+ fwrite ($ fp , $ dsn . chr (0 ) . ';host=nonsense;unix_socket=nonsense ' );
44
42
fclose ($ fp );
45
43
clearstatcache ();
46
44
assert (file_exists ($ file ));
47
45
try {
48
46
$ db = new PDO ($ uri , $ user , $ pass );
49
47
} catch (PDOException $ e ) {
50
- $ expected = array (
51
- "SQLSTATE[HY000] [1049] " ,
52
- "SQLSTATE[42000] [1049] " ,
53
- "SQLSTATE[HY000] [2002] "
54
- );
55
- $ isExpected = false ;
56
- foreach ($ expected as $ prefix ) {
57
- if (str_starts_with ($ e ->getMessage (), $ prefix )) {
58
- $ isExpected = true ;
59
- }
60
- }
61
-
62
- printf ("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), chr(0) test, %s \n" ,
63
- $ uri , $ dsn ,
64
- $ file , filesize ($ file ), file_get_contents ($ file ),
65
- ($ isExpected ? 'EXPECTED ERROR ' : $ e ->getMessage ()));
48
+ printf ("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), %s \n" ,
49
+ $ uri , $ dsn ,
50
+ $ file , filesize ($ file ), file_get_contents ($ file ),
51
+ $ e ->getMessage ());
66
52
}
67
53
unlink ($ file );
68
54
}
69
55
70
56
}
71
57
72
- /* TODO: safe mode */
73
-
74
58
} catch (PDOException $ e ) {
75
59
printf ("[001] %s, [%s] %s \n" ,
76
60
$ e ->getMessage (),
@@ -81,5 +65,4 @@ MySQLPDOTest::skip();
81
65
print "done! " ;
82
66
?>
83
67
--EXPECTF--
84
- [003] URI=uri:file://%spdomuri.tst, DSN=mysql%sdbname=%s, File=%spdomuri.tst (%d bytes, 'mysql%sdbname=letshopeinvalid%s'), chr(0) test, EXPECTED ERROR
85
68
done!
0 commit comments