cvs: php-src /ext/interbase/tests 002.phpt 005.phpt interbase.inc skipif.inc

From: Date: Thu, 01 Apr 2004 16:25:51 +0000
Subject: cvs: php-src /ext/interbase/tests 002.phpt 005.phpt interbase.inc skipif.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-26911@lists.php.net to get a copy of this message
abies Thu Apr 1 11:25:51 2004 EDT Modified files: /php-src/ext/interbase/tests 002.phpt 005.phpt interbase.inc skipif.inc Log: Don't rely on isql anymore, as creating databases is now supported by the API Changed tests to include ibase_query("SET TRANSACTION ...") http://cvs.php.net/diff.php/php-src/ext/interbase/tests/002.phpt?r1=1.4&r2=1.5&ty=u Index: php-src/ext/interbase/tests/002.phpt diff -u php-src/ext/interbase/tests/002.phpt:1.4 php-src/ext/interbase/tests/002.phpt:1.5 --- php-src/ext/interbase/tests/002.phpt:1.4 Tue Aug 12 05:57:57 2003 +++ php-src/ext/interbase/tests/002.phpt Thu Apr 1 11:25:51 2004 @@ -5,7 +5,7 @@ --POST-- --GET-- --FILE-- -<?php /* $Id: 002.phpt,v 1.4 2003/08/12 09:57:57 abies Exp $ */ +<?php /* $Id: 002.phpt,v 1.5 2004/04/01 16:25:51 abies Exp $ */ require("interbase.inc"); @@ -17,16 +17,19 @@ $pcon1 = ibase_pconnect($test_base); $pcon2 = ibase_pconnect($test_base); ibase_close($con); + unset($con); ibase_close($pcon1); + unset($pcon1); out_table("test1"); ibase_close($pcon2); + unset($pcon2); ?> --EXPECT-- --- test1 --- -1 test table created with isql +1 test table not created with isql --- --- test1 --- -1 test table created with isql +1 test table not created with isql --- http://cvs.php.net/diff.php/php-src/ext/interbase/tests/005.phpt?r1=1.6&r2=1.7&ty=u Index: php-src/ext/interbase/tests/005.phpt diff -u php-src/ext/interbase/tests/005.phpt:1.6 php-src/ext/interbase/tests/005.phpt:1.7 --- php-src/ext/interbase/tests/005.phpt:1.6 Fri Sep 5 13:02:02 2003 +++ php-src/ext/interbase/tests/005.phpt Thu Apr 1 11:25:51 2004 @@ -5,7 +5,7 @@ --POST-- --GET-- --FILE-- -<?php /* $Id: 005.phpt,v 1.6 2003/09/05 17:02:02 abies Exp $ */ +<?php /* $Id: 005.phpt,v 1.7 2004/04/01 16:25:51 abies Exp $ */ require("interbase.inc"); @@ -113,8 +113,8 @@ ibase_free_result($res); - $tr_1 = ibase_trans(); /* this default transaction also */ - $tr_2 = ibase_trans(IBASE_READ); + $tr_1 = ibase_query("SET TRANSACTION"); + $tr_2 = ibase_query("SET TRANSACTION READ ONLY"); $tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT); $tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT); http://cvs.php.net/diff.php/php-src/ext/interbase/tests/interbase.inc?r1=1.4&r2=1.5&ty=u Index: php-src/ext/interbase/tests/interbase.inc diff -u php-src/ext/interbase/tests/interbase.inc:1.4 php-src/ext/interbase/tests/interbase.inc:1.5 --- php-src/ext/interbase/tests/interbase.inc:1.4 Sat Jun 14 12:45:38 2003 +++ php-src/ext/interbase/tests/interbase.inc Thu Apr 1 11:25:51 2004 @@ -1,46 +1,40 @@ -<?php - -/* $Id: interbase.inc,v 1.4 2003/06/14 16:45:38 daniela Exp $ */ -/* used in tests */ +<?php /* $Id: interbase.inc,v 1.5 2004/04/01 16:25:51 abies Exp $ */ srand((double)microtime()*1000000); -$test_base = dirname(__FILE__)."/ibase_test.tmp"; -@unlink($test_base); +/* we need just the generated name, not the file itself */ +unlink($test_base = tempnam('/tmp',"php_ibase_test")); + +function init_db() +{ + global $test_base; -$name = tempnam(dirname(__FILE__), "CREATEDB"); -$ftmp = fopen($name,"w"); -fwrite($ftmp, -" - create database \"$test_base\"; - create table test1 (i integer, c varchar(100)); - commit; - insert into test1(i, c) values(1, 'test table created with isql'); - exit; -" -); -fclose($ftmp); - -/* set the correct binary */ -if (is_executable('isql')) { - $cmd = 'isql'; -} else { - $cmd = '/opt/interbase/bin/isql'; + $test_db = ibase_query("CREATE DATABASE \"$test_base\""); + $tr = ibase_trans($test_db); + ibase_query($tr,"create table test1 (i integer, c varchar(100))"); + ibase_commit_ret($tr); + ibase_query($tr,"insert into test1(i, c) values(1, 'test table not created with isql')"); + ibase_commit($tr); + ibase_close($test_db); } -exec("$cmd -i $name 2>&1"); -@unlink($name); +function cleanup_db() +{ + global $test_base; + + $r = ibase_connect($test_base); + ibase_drop_db($r); +} +register_shutdown_function('cleanup_db'); +init_db(); function out_table($table_name) { echo "--- $table_name ---\n"; $res = ibase_query("select * from $table_name"); - $f = ibase_num_fields($res); - while ($r = ibase_fetch_row($res)){ - for($i = 0; $i < $f; $i++) - echo "$r[$i]\t"; - echo "\n"; + while ($r = ibase_fetch_row($res)) { + echo join("\t",$r)."\t\n"; } ibase_free_result($res); echo "---\n"; @@ -49,34 +43,28 @@ function out_result($result, $table_name = "") { echo "--- $table_name ---\n"; - $f = ibase_num_fields($result); - while ($r = ibase_fetch_row($result)){ - for($i = 0; $i < $f; $i++) - echo "$r[$i]\t"; - echo "\n"; + while ($r = ibase_fetch_row($result)) { + echo join("\t",$r)."\t\n"; } echo "---\n"; } function out_result_trap_error($result, $table_name = "") -{ +{ echo "--- $table_name ---\n"; - while ($r = @ibase_fetch_assoc($result)){ - while (list($k, $v) = each($r) ){ - echo "$r[$k]\t"; - } - echo "\n"; + while ($r = ibase_fetch_row($result)) { + echo join("\t",$r)."\t\n"; } echo "errmsg [" . ibase_errmsg() . "]\t\n"; echo "---\n"; -} +} /* M/D/Y H:M:S */ function rand_datetime() { return sprintf("%02d/%02d/%4d %02d:%02d:%02d", - rand()%12+1, rand()%28+1, rand()%100+1910, - rand()%24, rand()%60, rand()%60); + rand()%12+1, rand()%28+1, rand()%100+1910, + rand()%24, rand()%60, rand()%60); } /* random binary string */ @@ -84,8 +72,9 @@ { $len = rand() % $max_len; $s = ""; - while($len--) + while($len--) { $s .= sprintf("%c", rand() % 256); + } return $s; } @@ -93,25 +82,28 @@ { $len = rand() % $max_len; $s = ""; - while($len--) - $s .= sprintf("%c", rand() % 26 + 65);; + while ($len--) { + $s .= sprintf("%c", rand() % 26 + 65); + } return $s; } function rand_number($len , $prec = -1, $sign = 1) { - if($prec == -1){ + if ($prec == -1) { $n = substr(rand() . rand(), 0, rand() % $len + 1); - if(strlen($n) < $len) + if (strlen($n) < $len) { $n .= "." . substr(rand(), 0, rand() % ($len - strlen($n)) + 1); - }elseif ($prec == 0){ + } + } else if ($prec == 0) { $n = substr(rand() . rand(), 0, rand() % $len + 1); - }else{ + } else { $n = substr(rand() . rand(), 0, rand() % ($len - $prec) + 1); $n .= "." . substr(rand(), 0, $prec); } - if($sign && (rand() % 3 == 0)) + if ($sign && (rand() % 3 == 0)) { $n = "-" .$n; + } return $n; } http://cvs.php.net/diff.php/php-src/ext/interbase/tests/skipif.inc?r1=1.2&r2=1.3&ty=u Index: php-src/ext/interbase/tests/skipif.inc diff -u php-src/ext/interbase/tests/skipif.inc:1.2 php-src/ext/interbase/tests/skipif.inc:1.3 --- php-src/ext/interbase/tests/skipif.inc:1.2 Wed Apr 30 06:42:24 2003 +++ php-src/ext/interbase/tests/skipif.inc Thu Apr 1 11:25:51 2004 @@ -1,9 +1,5 @@ -<?php - -/* $Id: skipif.inc,v 1.2 2003/04/30 10:42:24 sniper Exp $ */ -/* used in tests */ +<?php /* $Id: skipif.inc,v 1.3 2004/04/01 16:25:51 abies Exp $ */ if (!extension_loaded("interbase")) print "skip"; -if (!is_executable("isql") && !is_executable("/opt/interbase/bin/isql")) print "skip"; ?>

« previous php.cvs (#26911) next »