Blame | Letzte Änderung | Log anzeigen | RSS feed
--TEST--DB::parseDSN--SKIPIF--<?php chdir(dirname(__FILE__)); require_once './skipif.inc'; ?>--FILE--<?php // -*- C++ -*-require_once './include.inc';require_once 'DB.php';function test($dsn) {echo "DSN: $dsn\n";print_r(DB::parseDSN($dsn));}function testArray($dsn) {echo "DSN: array\n";print_r(DB::parseDSN($dsn));}print "testing DB::parseDSN...\n\n";test("mysql");test("odbc(mssql)");test('odbc(db2)://user:password@/database');test('odbc(access):///database');test('odbc://admin@/datasourceName');test("mysql://localhost");test("mysql://remote.host.com/db");test("oci8://system:manager@");test("oci8://user:pass@tns-name");test("odbc(solid)://foo:bar@tcp+localhost+1313"); // deprecatedtest("pgsql://user@unix+localhost/pear"); // deprecatedtest("ibase://user%40domain:password@host");test("ibase://user@domain:pass@word@/database"); // also supportedtest("ifx://user@domain:pass@word@host.com//usr/db/general.db");test('ifx://remote.host.com/c:\windows\my.db');test('oci8://SHOOTOUT:******@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.101.161)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=TIS)))');// new formatstest("odbc(solid)://foo:bar@localhost:1313");test("pgsql://user@unix()/pear");test("mysql://user@unix(/path/to/socket)/pear");test("pgsql://user@tcp()/pear");test("pgsql://user@tcp(somehost)/pear");test("pgsql://user:pass@word@tcp(somehost:7777)/pear");// special backend optionstest('ibase://user:pass@localhost//var/lib/dbase.dbf?role=foo');test('dbase://@/?role=foo&dialect=bar');test('sqlite:////unix/path/to/database?option=value&anotheroption=anothervalue');test('sqlite:///c:/win/path/to/database?option=value');// some examples from manualtest('mysql://username@hostspec');test('mysql://hostspec/database');test('mysql://hostspec');test('mysql:///database');// array tests$array = array('phptype' => 'mysql','hostspec' => 'foobar',);testArray($array);?>--GET----POST----EXPECT--testing DB::parseDSN...DSN: mysqlArray([phptype] => mysql[dbsyntax] => mysql[username] =>[password] =>[protocol] =>[hostspec] =>[port] =>[socket] =>[database] =>)DSN: odbc(mssql)Array([phptype] => odbc[dbsyntax] => mssql[username] =>[password] =>[protocol] =>[hostspec] =>[port] =>[socket] =>[database] =>)DSN: odbc(db2)://user:password@/databaseArray([phptype] => odbc[dbsyntax] => db2[username] => user[password] => password[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => database)DSN: odbc(access):///databaseArray([phptype] => odbc[dbsyntax] => access[username] =>[password] =>[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => database)DSN: odbc://admin@/datasourceNameArray([phptype] => odbc[dbsyntax] => odbc[username] => admin[password] =>[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => datasourceName)DSN: mysql://localhostArray([phptype] => mysql[dbsyntax] => mysql[username] =>[password] =>[protocol] => tcp[hostspec] => localhost[port] =>[socket] =>[database] =>)DSN: mysql://remote.host.com/dbArray([phptype] => mysql[dbsyntax] => mysql[username] =>[password] =>[protocol] => tcp[hostspec] => remote.host.com[port] =>[socket] =>[database] => db)DSN: oci8://system:manager@Array([phptype] => oci8[dbsyntax] => oci8[username] => system[password] => manager[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] =>)DSN: oci8://user:pass@tns-nameArray([phptype] => oci8[dbsyntax] => oci8[username] => user[password] => pass[protocol] => tcp[hostspec] => tns-name[port] =>[socket] =>[database] =>)DSN: odbc(solid)://foo:bar@tcp+localhost+1313Array([phptype] => odbc[dbsyntax] => solid[username] => foo[password] => bar[protocol] => tcp[hostspec] => localhost+1313[port] =>[socket] =>[database] =>)DSN: pgsql://user@unix+localhost/pearArray([phptype] => pgsql[dbsyntax] => pgsql[username] => user[password] =>[protocol] => unix[hostspec] =>[port] =>[socket] => localhost[database] => pear)DSN: ibase://user%40domain:password@hostArray([phptype] => ibase[dbsyntax] => ibase[username] => user@domain[password] => password[protocol] => tcp[hostspec] => host[port] =>[socket] =>[database] =>)DSN: ibase://user@domain:pass@word@/databaseArray([phptype] => ibase[dbsyntax] => ibase[username] => user@domain[password] => pass@word[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => database)DSN: ifx://user@domain:pass@word@host.com//usr/db/general.dbArray([phptype] => ifx[dbsyntax] => ifx[username] => user@domain[password] => pass@word[protocol] => tcp[hostspec] => host.com[port] =>[socket] =>[database] => /usr/db/general.db)DSN: ifx://remote.host.com/c:\windows\my.dbArray([phptype] => ifx[dbsyntax] => ifx[username] =>[password] =>[protocol] => tcp[hostspec] => remote.host.com[port] =>[socket] =>[database] => c:\windows\my.db)DSN: oci8://SHOOTOUT:******@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.101.161)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=TIS)))Array([phptype] => oci8[dbsyntax] => oci8[username] => SHOOTOUT[password] => ******[protocol] => tcp[hostspec] => (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.101.161)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=TIS)))[port] =>[socket] =>[database] =>)DSN: odbc(solid)://foo:bar@localhost:1313Array([phptype] => odbc[dbsyntax] => solid[username] => foo[password] => bar[protocol] => tcp[hostspec] => localhost[port] => 1313[socket] =>[database] =>)DSN: pgsql://user@unix()/pearArray([phptype] => pgsql[dbsyntax] => pgsql[username] => user[password] =>[protocol] => unix[hostspec] =>[port] =>[socket] =>[database] => pear)DSN: mysql://user@unix(/path/to/socket)/pearArray([phptype] => mysql[dbsyntax] => mysql[username] => user[password] =>[protocol] => unix[hostspec] =>[port] =>[socket] => /path/to/socket[database] => pear)DSN: pgsql://user@tcp()/pearArray([phptype] => pgsql[dbsyntax] => pgsql[username] => user[password] =>[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => pear)DSN: pgsql://user@tcp(somehost)/pearArray([phptype] => pgsql[dbsyntax] => pgsql[username] => user[password] =>[protocol] => tcp[hostspec] => somehost[port] =>[socket] =>[database] => pear)DSN: pgsql://user:pass@word@tcp(somehost:7777)/pearArray([phptype] => pgsql[dbsyntax] => pgsql[username] => user[password] => pass@word[protocol] => tcp[hostspec] => somehost[port] => 7777[socket] =>[database] => pear)DSN: ibase://user:pass@localhost//var/lib/dbase.dbf?role=fooArray([phptype] => ibase[dbsyntax] => ibase[username] => user[password] => pass[protocol] => tcp[hostspec] => localhost[port] =>[socket] =>[database] => /var/lib/dbase.dbf[role] => foo)DSN: dbase://@/?role=foo&dialect=barArray([phptype] => dbase[dbsyntax] => dbase[username] =>[password] =>[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] =>[role] => foo[dialect] => bar)DSN: sqlite:////unix/path/to/database?option=value&anotheroption=anothervalueArray([phptype] => sqlite[dbsyntax] => sqlite[username] =>[password] =>[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => /unix/path/to/database[option] => value[anotheroption] => anothervalue)DSN: sqlite:///c:/win/path/to/database?option=valueArray([phptype] => sqlite[dbsyntax] => sqlite[username] =>[password] =>[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => c:/win/path/to/database[option] => value)DSN: mysql://username@hostspecArray([phptype] => mysql[dbsyntax] => mysql[username] => username[password] =>[protocol] => tcp[hostspec] => hostspec[port] =>[socket] =>[database] =>)DSN: mysql://hostspec/databaseArray([phptype] => mysql[dbsyntax] => mysql[username] =>[password] =>[protocol] => tcp[hostspec] => hostspec[port] =>[socket] =>[database] => database)DSN: mysql://hostspecArray([phptype] => mysql[dbsyntax] => mysql[username] =>[password] =>[protocol] => tcp[hostspec] => hostspec[port] =>[socket] =>[database] =>)DSN: mysql:///databaseArray([phptype] => mysql[dbsyntax] => mysql[username] =>[password] =>[protocol] => tcp[hostspec] =>[port] =>[socket] =>[database] => database)DSN: arrayArray([phptype] => mysql[dbsyntax] => mysql[username] =>[password] =>[protocol] =>[hostspec] => foobar[port] =>[socket] =>[database] =>)