1--TEST-- 2MySQL PDO->__construct() - URI 3--SKIPIF-- 4<?php 5require_once(__DIR__ . DIRECTORY_SEPARATOR . 'skipif.inc'); 6require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 7MySQLPDOTest::skip(); 8?> 9--FILE-- 10<?php 11 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); 12 13 try { 14 15 if ($tmp = MySQLPDOTest::getTempDir()) { 16 17 $file = $tmp . DIRECTORY_SEPARATOR . 'pdomuri.tst'; 18 $dsn = MySQLPDOTest::getDSN(); 19 $user = PDO_MYSQL_TEST_USER; 20 $pass = PDO_MYSQL_TEST_PASS; 21 $uri = 'uri:file://' . $file; 22 23 if ($fp = @fopen($file, 'w')) { 24 fwrite($fp, $dsn); 25 fclose($fp); 26 clearstatcache(); 27 assert(file_exists($file)); 28 try { 29 $db = new PDO($uri, $user, $pass); 30 } catch (PDOException $e) { 31 printf("[002] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), %s\n", 32 $uri, $dsn, 33 $file, filesize($file), file_get_contents($file), 34 $e->getMessage()); 35 } 36 unlink($file); 37 } 38 39 if ($fp = @fopen($file, 'w')) { 40 fwrite($fp, $dsn . chr(0) . ';host=nonsense;unix_socket=nonsense'); 41 fclose($fp); 42 clearstatcache(); 43 assert(file_exists($file)); 44 try { 45 $db = new PDO($uri, $user, $pass); 46 } catch (PDOException $e) { 47 printf("[003] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), %s\n", 48 $uri, $dsn, 49 $file, filesize($file), file_get_contents($file), 50 $e->getMessage()); 51 } 52 unlink($file); 53 } 54 55 } 56 57 } catch (PDOException $e) { 58 printf("[001] %s, [%s] %s\n", 59 $e->getMessage(), 60 (is_object($db)) ? $db->errorCode() : 'n/a', 61 (is_object($db)) ? implode(' ', $db->errorInfo()) : 'n/a'); 62 } 63 64 print "done!"; 65?> 66--EXPECTF-- 67done! 68