@@ -19,10 +19,9 @@ MySQLPDOTest::skip();
1919 $ dsn = MySQLPDOTest::getDSN ();
2020 $ user = PDO_MYSQL_TEST_USER ;
2121 $ 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 ;
2323
2424 if ($ fp = @fopen ($ file , 'w ' )) {
25- // ok, great we can create a file with a DSN in it
2625 fwrite ($ fp , $ dsn );
2726 fclose ($ fp );
2827 clearstatcache ();
@@ -39,38 +38,23 @@ MySQLPDOTest::skip();
3938 }
4039
4140 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 ' );
4442 fclose ($ fp );
4543 clearstatcache ();
4644 assert (file_exists ($ file ));
4745 try {
4846 $ db = new PDO ($ uri , $ user , $ pass );
4947 } 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 ());
6652 }
6753 unlink ($ file );
6854 }
6955
7056 }
7157
72- /* TODO: safe mode */
73-
7458 } catch (PDOException $ e ) {
7559 printf ("[001] %s, [%s] %s \n" ,
7660 $ e ->getMessage (),
@@ -81,5 +65,4 @@ MySQLPDOTest::skip();
8165 print "done! " ;
8266?>
8367--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
8568done!
0 commit comments