From 315f4f5658cf22a17ba06fa2ca2f3d890355873f Mon Sep 17 00:00:00 2001 From: Stig Bakken Date: Sun, 27 Aug 2000 19:46:06 +0000 Subject: @PHP 3 regression testing framework re-born (Stig) Took the old PHP 3 regression testing framework and rewrote it in PHP. Should work on both Windows and UNIX, however I have not tested it on Windows. See tests/README for how to write tests. Added the PHP 3 tests and converted most of them. --- ext/interbase/tests/001.phpt | 34 +++++ ext/interbase/tests/002.phpt | 35 +++++ ext/interbase/tests/003.phpt | 93 +++++++++++++ ext/interbase/tests/004.phpt | 179 +++++++++++++++++++++++++ ext/interbase/tests/005.phpt | 275 ++++++++++++++++++++++++++++++++++++++ ext/interbase/tests/006.phpt | 227 +++++++++++++++++++++++++++++++ ext/interbase/tests/extension | 1 + ext/interbase/tests/interbase.inc | 77 +++++++++++ 8 files changed, 921 insertions(+) create mode 100644 ext/interbase/tests/001.phpt create mode 100644 ext/interbase/tests/002.phpt create mode 100644 ext/interbase/tests/003.phpt create mode 100644 ext/interbase/tests/004.phpt create mode 100644 ext/interbase/tests/005.phpt create mode 100644 ext/interbase/tests/006.phpt create mode 100755 ext/interbase/tests/extension create mode 100755 ext/interbase/tests/interbase.inc (limited to 'ext/interbase/tests') diff --git a/ext/interbase/tests/001.phpt b/ext/interbase/tests/001.phpt new file mode 100644 index 0000000000..79263d6f5c --- /dev/null +++ b/ext/interbase/tests/001.phpt @@ -0,0 +1,34 @@ +--TEST-- +InterBase: create test database +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- +&1"); + unlink($name); +?> +--EXPECT-- + diff --git a/ext/interbase/tests/002.phpt b/ext/interbase/tests/002.phpt new file mode 100644 index 0000000000..6ea1b498ba --- /dev/null +++ b/ext/interbase/tests/002.phpt @@ -0,0 +1,35 @@ +--TEST-- +InterBase: connect, close and pconnect +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- + +--EXPECT-- +--- test1 --- +1 test table created with isql +--- +--- test1 --- +1 test table created with isql +--- diff --git a/ext/interbase/tests/003.phpt b/ext/interbase/tests/003.phpt new file mode 100644 index 0000000000..5398b52850 --- /dev/null +++ b/ext/interbase/tests/003.phpt @@ -0,0 +1,93 @@ +--TEST-- +InterBase: misc sql types (may take a while) +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- +V_CHAR,0,strlen($v_char)) != $v_char){ + echo " CHAR fail:\n"; + echo " in: $v_char\n"; + echo " out: $row->V_CHAR\n"; + } + if($row->V_DATE != $v_date){ + echo " DATE fail\n"; + echo " in: $v_date\n"; + echo " out: $row->V_DATE\n"; + } + if($row->V_DECIMAL != $v_decimal){ + echo " DECIMAL fail\n"; + echo " in: $v_decimal\n"; + echo " out: $row->V_DECIMAL\n"; + } + if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){ + echo " DOUBLE fail\n"; + echo " in: $v_double\n"; + echo " out: $row->V_DOUBLE\n"; + } + if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){ + echo " FLOAT fail\n"; + echo " in: $v_float\n"; + echo " out: $row->V_FLOAT\n"; + } + if($row->V_INTEGER != $v_integer){ + echo " INTEGER fail\n"; + echo " in: $v_integer\n"; + echo " out: $row->V_INTEGER\n"; + } + ibase_free_result($sel); + }/* for($iter)*/ + + ibase_close(); + echo "end of test\n"; +?> +--EXPECT-- + +end of test + + diff --git a/ext/interbase/tests/004.phpt b/ext/interbase/tests/004.phpt new file mode 100644 index 0000000000..04df7ae991 --- /dev/null +++ b/ext/interbase/tests/004.phpt @@ -0,0 +1,179 @@ +--TEST-- +InterBase: BLOB test +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- +V_BLOB); + + while($piece = ibase_blob_get($bl_h, rand() % 1024)) + $blob .= $piece; + if($blob != $blob_str) + echo " BLOB 1 fail\n"; + ibase_blob_close($bl_h); + ibase_free_result($q); + unset($blob); + + echo "create blob 2\n"; + + $bl_h = ibase_blob_create(); + $ftmp = fopen($name,"r"); + while($piece = fread($ftmp, rand() % 1024)){ + ibase_blob_add($bl_h, $piece); + } + fclose($ftmp); + $bl_s = ibase_blob_close($bl_h); + ibase_query("insert into test4 (v_integer, v_blob) values (2, ?)", $bl_s); + + echo "test blob 2\n"; + + $q = ibase_query("select v_blob from test4 where v_integer = 2"); + $row = ibase_fetch_object($q); + $bl_h = ibase_blob_open($row->V_BLOB); + while($piece = ibase_blob_get($bl_h, rand() % 1024)) + $blob .= $piece; + if($blob != $blob_str) + echo " BLOB 2 fail\n"; + ibase_blob_close($bl_h); + ibase_free_result($q); + unset($blob); + + + echo "create blob 3\n"; + + $bl_h = ibase_blob_create(); + + ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); + ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n"); + ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); + ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n"); + ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); + ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n"); + ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n"); + ibase_blob_add($bl_h, "| |\n"); + ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n"); + ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n"); + ibase_blob_add($bl_h, "| any later version. |\n"); + ibase_blob_add($bl_h, "| |\n"); + ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n"); + ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n"); + ibase_blob_add($bl_h, "| |\n"); + ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n"); + ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n"); + ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n"); + ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n"); + ibase_blob_add($bl_h, "| |\n"); + ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n"); + ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n"); + ibase_blob_add($bl_h, "| contact core@php.net. |\n"); + ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); + $bl_s = ibase_blob_close($bl_h); + ibase_query("insert into test4 (v_integer, v_blob) values (3, ?)", $bl_s); + + echo "echo blob 3\n"; + + $q = ibase_query("select v_blob from test4 where v_integer = 3"); + $row = ibase_fetch_object($q); + ibase_blob_echo($row->V_BLOB); + ibase_free_result($q); + + echo "fetch blob 3\n"; + $q = ibase_query("select v_blob from test4 where v_integer = 3"); + $row = ibase_fetch_object($q,IBASE_TEXT); + echo $row->V_BLOB; + ibase_free_result($q); + + ibase_close(); + unlink($name); + echo "end of test\n"; +?> +--EXPECT-- +import blob 1 +test blob 1 +create blob 2 +test blob 2 +create blob 3 +echo blob 3 ++----------------------------------------------------------------------+ +| PHP HTML Embedded Scripting Language Version 3.0 | ++----------------------------------------------------------------------+ +| Copyright (c) 1997-2000 PHP Development Team (See Credits file) | ++----------------------------------------------------------------------+ +| This program is free software; you can redistribute it and/or modify | +| it under the terms of one of the following licenses: | +| | +| A) the GNU General Public License as published by the Free Software | +| Foundation; either version 2 of the License, or (at your option) | +| any later version. | +| | +| B) the PHP License as published by the PHP Development Team and | +| included in the distribution in the file: LICENSE | +| | +| This program is distributed in the hope that it will be useful, | +| but WITHOUT ANY WARRANTY; without even the implied warranty of | +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +| GNU General Public License for more details. | +| | +| You should have received a copy of both licenses referred to here. | +| If you did not, or have any questions about PHP licensing, please | +| contact core@php.net. | ++----------------------------------------------------------------------+ +fetch blob 3 ++----------------------------------------------------------------------+ +| PHP HTML Embedded Scripting Language Version 3.0 | ++----------------------------------------------------------------------+ +| Copyright (c) 1997-2000 PHP Development Team (See Credits file) | ++----------------------------------------------------------------------+ +| This program is free software; you can redistribute it and/or modify | +| it under the terms of one of the following licenses: | +| | +| A) the GNU General Public License as published by the Free Software | +| Foundation; either version 2 of the License, or (at your option) | +| any later version. | +| | +| B) the PHP License as published by the PHP Development Team and | +| included in the distribution in the file: LICENSE | +| | +| This program is distributed in the hope that it will be useful, | +| but WITHOUT ANY WARRANTY; without even the implied warranty of | +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | +| GNU General Public License for more details. | +| | +| You should have received a copy of both licenses referred to here. | +| If you did not, or have any questions about PHP licensing, please | +| contact core@php.net. | ++----------------------------------------------------------------------+ +end of test diff --git a/ext/interbase/tests/005.phpt b/ext/interbase/tests/005.phpt new file mode 100644 index 0000000000..5cf77667e0 --- /dev/null +++ b/ext/interbase/tests/005.phpt @@ -0,0 +1,275 @@ +--TEST-- +InterBase: transactions +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- + +--EXPECT-- +default transaction: +empty table +--- test5 --- +--- +one row +--- test5 --- +1 +--- +after rollback table empty again +--- test5 --- +--- +one row +--- test5 --- +2 +--- +one row +--- test5 --- +2 +--- +one row... again. +--- test5 --- +2 +--- +one row. +--- test5 --- +2 +--- +one row +--- test5 --- +2 +--- +three rows +--- test5 --- +2 +3 +4 +--- +three rows again +--- test5 --- +2 +3 +4 +--- +one row in second transaction +--- test5 --- +2 +--- +three rows in third transaction +--- test5 --- +2 +3 +4 +--- +three rows +--- test5 --- +2 +3 +4 +--- +four rows +--- test5 --- +2 +3 +4 +5 +--- +four rows again +--- test5 --- +2 +3 +4 +5 +--- +end of test + diff --git a/ext/interbase/tests/006.phpt b/ext/interbase/tests/006.phpt new file mode 100644 index 0000000000..bad07e3315 --- /dev/null +++ b/ext/interbase/tests/006.phpt @@ -0,0 +1,227 @@ +--TEST-- +InterBase: binding (may take a while) +--SKIPIF-- + +--POST-- +--GET-- +--FILE-- +V_CHAR,0,strlen($v_char)) != $v_char){ + echo " CHAR fail:\n"; + echo " in: $v_char\n"; + echo " out: $row->V_CHAR\n"; + } + if($row->V_DATE != $v_date){ + echo " DATE fail\n"; + echo " in: $v_date\n"; + echo " out: $row->V_DATE\n"; + } + if($row->V_DECIMAL != $v_decimal){ + echo " DECIMAL fail\n"; + echo " in: $v_decimal\n"; + echo " out: $row->V_DECIMAL\n"; + } + if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){ + echo " DOUBLE fail\n"; + echo " in: $v_double\n"; + echo " out: $row->V_DOUBLE\n"; + } + if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){ + echo " FLOAT fail\n"; + echo " in: $v_float\n"; + echo " out: $row->V_FLOAT\n"; + } + if($row->V_INTEGER != $v_integer){ + echo " INTEGER fail\n"; + echo " in: $v_integer\n"; + echo " out: $row->V_INTEGER\n"; + } + ibase_free_result($sel); + }/* for($iter)*/ + + echo "select\n"; + for($iter = 0; $iter < 3; $iter++){ + /* prepare data */ + $v_char = rand_str(1000); + $v_date = rand_datetime(); + $v_decimal = rand_number(12,3); + $v_double = rand_number(20); + $v_float = rand_number(7); + $v_integer = rand_number(9,0); + $v_numeric = rand_number(4,2); + $v_smallint = rand_number(5) % 32767; + $v_varchar = rand_str(10000); + + /* clear table*/ + ibase_query("delete from test6"); + + /* make one record */ + ibase_query("insert into test6 + (iter, v_char,v_date,v_decimal, + v_integer,v_numeric,v_smallint,v_varchar) + values (666, '$v_char','$v_date',$v_decimal, $v_integer, + $v_numeric, $v_smallint, '$v_varchar')"); + + /* test all types */ + if(!($sel = ibase_query( + "select iter from test6 where v_char = ?", $v_char))) + echo "CHAR fail\n"; + ibase_free_result($sel); + if(!($sel = ibase_query( + "select iter from test6 where v_date = ?", $v_date))) + echo "DATE fail\n"; + ibase_free_result($sel); + if(!($sel = ibase_query( + "select iter from test6 where v_decimal = ?", $v_decimal))) + echo "DECIMAL fail\n"; + ibase_free_result($sel); + if(!($sel = ibase_query( + "select iter from test6 where v_integer = ?", $v_integer))) + echo "INTEGER fail\n"; + ibase_free_result($sel); + if(!($sel = ibase_query( + "select iter from test6 where v_numeric = ?", $v_numeric))) + echo "NUMERIC fail\n"; + ibase_free_result($sel); + if(!($sel = ibase_query( + "select iter from test6 where v_smallint = ?", $v_smallint))) + echo "SMALLINT fail\n"; + ibase_free_result($sel); + if(!($sel = ibase_query( + "select iter from test6 where v_varchar = ?", $v_varchar))) + echo "VARCHAR fail\n"; + ibase_free_result($sel); + + }/*for iter*/ + + echo "prepare and exec insert\n"; + + /* prepare table */ + ibase_query("delete from test6"); + + /* prepare query */ + $query = ibase_prepare( + "insert into test6 (v_integer) values (?)"); + + for($i = 0; $i < 10; $i++) + ibase_execute($query, $i); + + out_table("test6"); + + ibase_free_query($query); + + + echo "prepare and exec select\n"; + + /* prepare query */ + $query = ibase_prepare("select * from test6 + where v_integer between ? and ?"); + + $low_border = 2; + $high_border = 6; + + $res = ibase_execute($query, $low_border, $high_border); + out_result($res, "test6"); + ibase_free_result($res); + + $low_border = 0; + $high_border = 4; + $res = ibase_execute($query, $low_border, $high_border); + out_result($res, "test6"); + ibase_free_result($res); + + $res = ibase_execute($query, "5", 7.5); + out_result($res, "test6"); + ibase_free_result($res); + + ibase_free_query($query); + ibase_close(); + echo "end of test\n"; +?> +--EXPECT-- +insert +select +prepare and exec insert +--- test6 --- + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +--- +prepare and exec select +--- test6 --- + 2 + 3 + 4 + 5 + 6 +--- +--- test6 --- + 0 + 1 + 2 + 3 + 4 +--- +--- test6 --- + 5 + 6 + 7 +--- +end of test + diff --git a/ext/interbase/tests/extension b/ext/interbase/tests/extension new file mode 100755 index 0000000000..3b561c46a9 --- /dev/null +++ b/ext/interbase/tests/extension @@ -0,0 +1 @@ +InterBase diff --git a/ext/interbase/tests/interbase.inc b/ext/interbase/tests/interbase.inc new file mode 100755 index 0000000000..f261cb01b5 --- /dev/null +++ b/ext/interbase/tests/interbase.inc @@ -0,0 +1,77 @@ + \ No newline at end of file -- cgit v1.2.1