diff options
Diffstat (limited to 'ext/odbc/tests')
-rw-r--r-- | ext/odbc/tests/bug47803.phpt | 78 | ||||
-rw-r--r-- | ext/odbc/tests/bug60616.phpt | 48 | ||||
-rw-r--r-- | ext/odbc/tests/bug68087.phpt | 34 | ||||
-rw-r--r-- | ext/odbc/tests/bug69354.phpt | 14 | ||||
-rw-r--r-- | ext/odbc/tests/bug71171.phpt | 4 | ||||
-rw-r--r-- | ext/odbc/tests/bug73448.phpt | 34 | ||||
-rw-r--r-- | ext/odbc/tests/bug73725.phpt | 2 | ||||
-rw-r--r-- | ext/odbc/tests/bug78473.phpt | 8 | ||||
-rw-r--r-- | ext/odbc/tests/config.inc | 6 | ||||
-rw-r--r-- | ext/odbc/tests/odbc_data_source_001.phpt | 4 | ||||
-rw-r--r-- | ext/odbc/tests/odbc_exec_001.phpt | 4 | ||||
-rw-r--r-- | ext/odbc/tests/odbc_free_result_001.phpt | 34 | ||||
-rw-r--r-- | ext/odbc/tests/skipif.inc | 2 |
13 files changed, 132 insertions, 140 deletions
diff --git a/ext/odbc/tests/bug47803.phpt b/ext/odbc/tests/bug47803.phpt index e80b0de38b..f13da017ba 100644 --- a/ext/odbc/tests/bug47803.phpt +++ b/ext/odbc/tests/bug47803.phpt @@ -8,9 +8,9 @@ Bug #47803 Executing prepared statements is successful only for the first two st include __DIR__ . "/config.inc"; $create_table = "CREATE TABLE FOO( - [PAR_ID] [int] NOT NULL, - [PAR_INT] [int] NULL, - [PAR_CHR] [varchar](500) NULL + [PAR_ID] [int] NOT NULL, + [PAR_INT] [int] NULL, + [PAR_CHR] [varchar](500) NULL )"; $inserts = "INSERT INTO FOO @@ -19,16 +19,16 @@ $inserts = "INSERT INTO FOO ,[PAR_CHR]) VALUES (1,14,''), - (2,30,''), - (3,7,''), - (4,7,''), - (5,0,''), - (6,0,''), - (7,20130901,''), - (8,20140201,''), - (9,20140201,''), - (10,20140620,''), - (11,221,'')"; + (2,30,''), + (3,7,''), + (4,7,''), + (5,0,''), + (6,0,''), + (7,20130901,''), + (8,20140201,''), + (9,20140201,''), + (10,20140620,''), + (11,221,'')"; date_default_timezone_set('Europe/Warsaw'); @@ -40,47 +40,47 @@ odbc_exec($link, $create_table); odbc_exec($link, $inserts); $upd_params = array( - array('id'=>1, 'name'=>'test 1'), - array('id'=>2, 'name'=>'test 2'), - array('id'=>3, 'name'=>'test 3'), - array('id'=>4, 'name'=>'test 4'), - array('id'=>5, 'name'=>'test 5'), - array('id'=>10, 'name'=>'test 10'), - array('id'=>9, 'name'=>'test 9'), - array('id'=>8, 'name'=>'test 8'), - array('id'=>7, 'name'=>'test 7'), - array('id'=>6, 'name'=>'test 6'), + array('id'=>1, 'name'=>'test 1'), + array('id'=>2, 'name'=>'test 2'), + array('id'=>3, 'name'=>'test 3'), + array('id'=>4, 'name'=>'test 4'), + array('id'=>5, 'name'=>'test 5'), + array('id'=>10, 'name'=>'test 10'), + array('id'=>9, 'name'=>'test 9'), + array('id'=>8, 'name'=>'test 8'), + array('id'=>7, 'name'=>'test 7'), + array('id'=>6, 'name'=>'test 6'), ); $sql = "UPDATE FOO SET [PAR_CHR] = ? WHERE [PAR_ID] = ?"; $result = odbc_prepare($link, $sql); if (!$result) { - print ('[sql] prep: '.$sql); - goto out; + print ('[sql] prep: '.$sql); + goto out; } foreach ($upd_params as &$k) { - if(!odbc_execute($result, array($k['name'], $k['id']))) { - print ('[sql] exec: '."array({$k['name']}, {$k['id']})"); - goto out; - } + if(!odbc_execute($result, array($k['name'], $k['id']))) { + print ('[sql] exec: '."array({$k['name']}, {$k['id']})"); + goto out; + } } odbc_free_result($result); $sql = "SELECT * FROM FOO WHERE [PAR_ID] = ?"; $result = odbc_prepare($link, $sql); if (!$result) { - print ('[sql] prep: '.$sql); - goto out; + print ('[sql] prep: '.$sql); + goto out; } foreach ($upd_params as $k) { - if(!odbc_execute($result, array($k['id']))) { - print ('[sql] exec: '."array({$k['id']})"); - goto out; - } - while (($r = odbc_fetch_array($result)) !== false) { - var_dump($r); - } + if(!odbc_execute($result, array($k['id']))) { + print ('[sql] exec: '."array({$k['id']})"); + goto out; + } + while (($r = odbc_fetch_array($result)) !== false) { + var_dump($r); + } } out: @@ -88,7 +88,6 @@ if ($result) odbc_free_result($result); odbc_close($link); ?> -==DONE== --EXPECT-- array(3) { ["PAR_ID"]=> @@ -170,7 +169,6 @@ array(3) { ["PAR_CHR"]=> string(6) "test 7" } -==DONE== --CLEAN-- <?php include 'config.inc'; diff --git a/ext/odbc/tests/bug60616.phpt b/ext/odbc/tests/bug60616.phpt index 16536881af..9d98d46b08 100644 --- a/ext/odbc/tests/bug60616.phpt +++ b/ext/odbc/tests/bug60616.phpt @@ -31,31 +31,31 @@ odbc_exec($conn, "INSERT INTO FOO(ID, CHAR_COL, VARCHAR_COL, TEXT_COL) VALUES (2 $res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC'); while(odbc_fetch_row($res)) { - $char_col = odbc_result($res, "CHAR_COL"); - $varchar_col = odbc_result($res, "VARCHAR_COL"); - $id = odbc_result($res, "ID"); - $text_col = ""; - while (($chunk=odbc_result($res, "TEXT_COL")) !== false) { - $text_col .= $chunk; - } + $char_col = odbc_result($res, "CHAR_COL"); + $varchar_col = odbc_result($res, "VARCHAR_COL"); + $id = odbc_result($res, "ID"); + $text_col = ""; + while (($chunk=odbc_result($res, "TEXT_COL")) !== false) { + $text_col .= $chunk; + } - if ($id == 1) { - $euc_jp_check = $euc_jp . str_repeat(" ", (200 - mb_strlen($euc_jp))); - if (strcmp($char_col, $euc_jp_check) == 0 && strcmp($varchar_col, $euc_jp) == 0 && - strcmp($text_col, $euc_jp) == 0) { - print "EUC-JP matched\n"; - } else { - print "EUC-JP mismatched\n"; - } - } else { - $ascii_check = $ascii . str_repeat(" ", (200 - strlen($ascii))); - if (strcmp($char_col, $ascii_check) == 0 && strcmp($varchar_col, $ascii) == 0 && - strcmp($text_col, $ascii) == 0) { - print "ASCII matched\n"; - } else { - print "ASCII mismatched\n"; - } - } + if ($id == 1) { + $euc_jp_check = $euc_jp . str_repeat(" ", (200 - mb_strlen($euc_jp))); + if (strcmp($char_col, $euc_jp_check) == 0 && strcmp($varchar_col, $euc_jp) == 0 && + strcmp($text_col, $euc_jp) == 0) { + print "EUC-JP matched\n"; + } else { + print "EUC-JP mismatched\n"; + } + } else { + $ascii_check = $ascii . str_repeat(" ", (200 - strlen($ascii))); + if (strcmp($char_col, $ascii_check) == 0 && strcmp($varchar_col, $ascii) == 0 && + strcmp($text_col, $ascii) == 0) { + print "ASCII matched\n"; + } else { + print "ASCII mismatched\n"; + } + } } ?> diff --git a/ext/odbc/tests/bug68087.phpt b/ext/odbc/tests/bug68087.phpt index 3bc18125a6..64b232d9bc 100644 --- a/ext/odbc/tests/bug68087.phpt +++ b/ext/odbc/tests/bug68087.phpt @@ -22,23 +22,23 @@ odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL, DATE_COL) VALUES (2, 'helloag $res = odbc_exec($conn, 'SELECT * FROM FOO ORDER BY ID ASC'); while(odbc_fetch_row($res)) { - $id = odbc_result($res, "ID"); - $varchar_col = odbc_result($res, "VARCHAR_COL"); - $date = odbc_result($res, "DATE_COL"); - - if ($id == 1) { - if ($date != $id_1_date) { - print "Date_1 mismatched\n"; - } else { - print "Date_1 matched\n"; - } - } else { - if ($date != $id_2_date) { - print "Date_2 mismatched\n"; - } else { - print "Date_2 matched\n"; - } - } + $id = odbc_result($res, "ID"); + $varchar_col = odbc_result($res, "VARCHAR_COL"); + $date = odbc_result($res, "DATE_COL"); + + if ($id == 1) { + if ($date != $id_1_date) { + print "Date_1 mismatched\n"; + } else { + print "Date_1 matched\n"; + } + } else { + if ($date != $id_2_date) { + print "Date_2 mismatched\n"; + } else { + print "Date_2 matched\n"; + } + } } ?> diff --git a/ext/odbc/tests/bug69354.phpt b/ext/odbc/tests/bug69354.phpt index 0e53aceab3..cf4e9114ad 100644 --- a/ext/odbc/tests/bug69354.phpt +++ b/ext/odbc/tests/bug69354.phpt @@ -17,20 +17,18 @@ odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL) VALUES (1, '" . str_repeat("a $res = odbc_exec($conn,"select VARCHAR_COL from FOO"); if ($res) { - if (odbc_fetch_row($res)) { - $ret = odbc_result($res,'varchar_col'); - echo strlen($ret), "\n"; - echo $ret[0], "\n"; - echo $ret[strlen($ret)-1], "\n"; - } + if (odbc_fetch_row($res)) { + $ret = odbc_result($res,'varchar_col'); + echo strlen($ret), "\n"; + echo $ret[0], "\n"; + echo $ret[strlen($ret)-1], "\n"; + } } ?> -==DONE== --EXPECT-- 100 a a -==DONE== --CLEAN-- <?php include 'config.inc'; diff --git a/ext/odbc/tests/bug71171.phpt b/ext/odbc/tests/bug71171.phpt index 94cfb4d0e8..f7a856d14c 100644 --- a/ext/odbc/tests/bug71171.phpt +++ b/ext/odbc/tests/bug71171.phpt @@ -17,18 +17,16 @@ odbc_exec($conn, "INSERT INTO FOO(ID, VARCHAR_COL) VALUES (1, '" . chr(0x81) . " $res = odbc_exec($conn,"SELECT ID FROM FOO WHERE VARCHAR_COL = '" . chr(0x81) . "'"); if ($res) { - while($record = odbc_fetch_array($res)) var_dump($record); + while($record = odbc_fetch_array($res)) var_dump($record); } odbc_close($conn); ?> -==DONE== --EXPECT-- array(1) { ["ID"]=> string(1) "1" } -==DONE== --CLEAN-- <?php include 'config.inc'; diff --git a/ext/odbc/tests/bug73448.phpt b/ext/odbc/tests/bug73448.phpt index 5f0be913f2..ea6c585c0f 100644 --- a/ext/odbc/tests/bug73448.phpt +++ b/ext/odbc/tests/bug73448.phpt @@ -10,34 +10,33 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); $sqlCommandList = array( - "/* empty batch is without error */", - "/* non existent procedure xy */ execute xy", - "/* empty batch,error message is not empty */", - "/* valid select with result */ select * from sys.sysobjects", - "/* another erroneous query */ SELECT * FROM zwiebelfleisch", - "/* valid select with result */ select * from sys.sysobjects", + "/* empty batch is without error */", + "/* non existent procedure xy */ execute xy", + "/* empty batch,error message is not empty */", + "/* valid select with result */ select * from sys.sysobjects", + "/* another erroneous query */ SELECT * FROM zwiebelfleisch", + "/* valid select with result */ select * from sys.sysobjects", ); foreach ($sqlCommandList as $exampleNumber => $sql) { - $r = @odbc_exec($conn, $sql); + $r = @odbc_exec($conn, $sql); - if (false === $r) { - $e = odbc_errormsg($conn); - $n = odbc_error($conn); + if (false === $r) { + $e = odbc_errormsg($conn); + $n = odbc_error($conn); - var_dump($sql, $n, $e); - echo "\n"; - } + var_dump($sql, $n, $e); + echo "\n"; + } - if ($r) { - odbc_free_result($r); - } + if ($r) { + odbc_free_result($r); + } } odbc_close($conn); ?> -==DONE== --EXPECTF-- string(42) "/* non existent procedure xy */ execute xy" string(5) "37000" @@ -47,4 +46,3 @@ string(58) "/* another erroneous query */ SELECT * FROM zwiebelfleisch" string(5) "S0002" string(%d) "[Microsoft][%s][SQL Server]Invalid object name 'zwiebelfleisch'." -==DONE== diff --git a/ext/odbc/tests/bug73725.phpt b/ext/odbc/tests/bug73725.phpt index 1ab2ba0eaa..c48a9112e7 100644 --- a/ext/odbc/tests/bug73725.phpt +++ b/ext/odbc/tests/bug73725.phpt @@ -23,7 +23,6 @@ $r = odbc_fetch_array($rc); var_dump($r); ?> -==DONE== --EXPECT-- array(3) { ["i"]=> @@ -41,7 +40,6 @@ array(3) { ["k"]=> string(2) "34" } -==DONE== --CLEAN-- <?php include 'config.inc'; diff --git a/ext/odbc/tests/bug78473.phpt b/ext/odbc/tests/bug78473.phpt index fd73b6cc07..c595d51fad 100644 --- a/ext/odbc/tests/bug78473.phpt +++ b/ext/odbc/tests/bug78473.phpt @@ -6,9 +6,13 @@ if (!extension_loaded('odbc')) die('skip odbc extension not available'); ?> --FILE-- <?php -odbc_close(STDIN); +try { + odbc_close(STDIN); +} catch (TypeError $err) { + echo $err->getMessage(), PHP_EOL; +} var_dump(STDIN); ?> --EXPECTF-- -Warning: odbc_close(): supplied resource is not a valid ODBC-Link resource in %s on line %d +odbc_close(): supplied resource is not a valid ODBC-Link resource resource(%d) of type (stream) diff --git a/ext/odbc/tests/config.inc b/ext/odbc/tests/config.inc index d9da63d0b7..78be4b2d99 100644 --- a/ext/odbc/tests/config.inc +++ b/ext/odbc/tests/config.inc @@ -8,11 +8,11 @@ $user = getenv("ODBC_TEST_USER"); $pass = getenv("ODBC_TEST_PASS"); if (false === $dsn) { - $dsn = 'myodbc3'; + $dsn = 'myodbc3'; } if (false === $user) { - $user = 'root'; + $user = 'root'; } if (false == $pass) { - $pass = ''; + $pass = ''; } diff --git a/ext/odbc/tests/odbc_data_source_001.phpt b/ext/odbc/tests/odbc_data_source_001.phpt index 8f5767315a..fedbbc1b02 100644 --- a/ext/odbc/tests/odbc_data_source_001.phpt +++ b/ext/odbc/tests/odbc_data_source_001.phpt @@ -15,16 +15,12 @@ include 'config.inc'; $conn = odbc_connect($dsn, $user, $pass); var_dump(odbc_data_source($conn, NULL)); -var_dump(odbc_data_source($conn, '')); var_dump(odbc_data_source($conn, SQL_FETCH_FIRST)); ?> --EXPECTF-- Warning: odbc_data_source(): Invalid fetch type (0) in %s on line %d bool(false) - -Warning: odbc_data_source() expects parameter 2 to be int, string given in %s on line %d -NULL array(%d) { %a } diff --git a/ext/odbc/tests/odbc_exec_001.phpt b/ext/odbc/tests/odbc_exec_001.phpt index dd1fa26a67..b288bcd2d0 100644 --- a/ext/odbc/tests/odbc_exec_001.phpt +++ b/ext/odbc/tests/odbc_exec_001.phpt @@ -28,11 +28,11 @@ odbc_exec($conn, NULL); ?> --EXPECTF-- -Warning: odbc_exec() expects parameter 3 to be int, string given in %s on line %d +Warning: odbc_exec(): Argument #3 must be of type int, string given in %s on line %d Warning: odbc_exec(): SQL error: %s in %s on line %d -Warning: odbc_exec() expects parameter 3 to be int, string given in %s on line %d +Warning: odbc_exec(): Argument #3 must be of type int, string given in %s on line %d Warning: odbc_exec(): SQL error: %s in %s on line %d diff --git a/ext/odbc/tests/odbc_free_result_001.phpt b/ext/odbc/tests/odbc_free_result_001.phpt index cdc421117d..223b3f0a4c 100644 --- a/ext/odbc/tests/odbc_free_result_001.phpt +++ b/ext/odbc/tests/odbc_free_result_001.phpt @@ -22,10 +22,21 @@ $res = odbc_exec($conn, 'SELECT * FROM FOO'); var_dump(odbc_fetch_row($res)); var_dump(odbc_result($res, 'test')); var_dump(odbc_free_result($res)); -var_dump(odbc_free_result($conn)); -var_dump(odbc_free_result(NULL)); -var_dump(odbc_fetch_row($res)); -var_dump(odbc_result($res, 'test')); +try { + var_dump(odbc_free_result($conn)); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + var_dump(odbc_fetch_row($res)); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +try { + var_dump(odbc_result($res, 'test')); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} odbc_exec($conn, 'DROP TABLE FOO'); @@ -36,15 +47,6 @@ odbc_exec($conn, 'DROP DATABASE odbcTEST'); bool(true) string(1) "1" bool(true) - -Warning: odbc_free_result(): supplied resource is not a valid ODBC result resource in %s on line %d -bool(false) - -Warning: odbc_free_result() expects parameter 1 to be resource, null given in %s on line %d -NULL - -Warning: odbc_fetch_row(): supplied resource is not a valid ODBC result resource in %s on line %d -bool(false) - -Warning: odbc_result(): supplied resource is not a valid ODBC result resource in %s on line %d -bool(false) +odbc_free_result(): supplied resource is not a valid ODBC result resource +odbc_fetch_row(): supplied resource is not a valid ODBC result resource +odbc_result(): supplied resource is not a valid ODBC result resource diff --git a/ext/odbc/tests/skipif.inc b/ext/odbc/tests/skipif.inc index 4cd13d0be6..a2c9a4aade 100644 --- a/ext/odbc/tests/skipif.inc +++ b/ext/odbc/tests/skipif.inc @@ -6,5 +6,5 @@ include 'config.inc'; $conn = @odbc_connect($dsn, $user, $pass); if (!$conn) { - die('skip could not connect'); + die('skip could not connect'); } |