helly           Fri Oct 25 05:42:29 2002 EDT

  Added files:                 
    /php4/ext/dba/tests .cvsignore 001.phpt 002.phpt 003.phpt 004.phpt 
                        005.phpt 006.phpt skipif.inc test.inc 
  Log:
  Added some tests for dba extension
  
  

Index: php4/ext/dba/tests/.cvsignore
+++ php4/ext/dba/tests/.cvsignore
phpt.*
*.diff
*.log
*.exp
*.out
*.php
test.dbm
test.dbm.lck

Index: php4/ext/dba/tests/001.phpt
+++ php4/ext/dba/tests/001.phpt
--TEST--
DBA File Creation Test
--SKIPIF--
<?php 
        require_once('skipif.inc');
?>
--FILE--
<?php
        require_once('test.inc');
        if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
        echo "database file created with $handler.\n";
        } else {
        echo "$db_file does not exist\n";
    }
        dba_close($db_file);
?>
--EXPECTF--
database file created with %s.
Index: php4/ext/dba/tests/002.phpt
+++ php4/ext/dba/tests/002.phpt
--TEST--
DBA Insert/Fetch Test
--SKIPIF--
<?php 
        require_once('skipif.inc');
?>
--FILE--
<?php
        require_once('test.inc');
        if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
                dba_insert("key1", "This is a test insert", $db_file);
                echo dba_fetch("key1", $db_file);
                dba_close($db_file);
        } else {
                echo "Error creating database\n";
        }
?>
--EXPECT--
This is a test insert

Index: php4/ext/dba/tests/003.phpt
+++ php4/ext/dba/tests/003.phpt
--TEST--
DBA Insert/Replace/Fetch Test
--SKIPIF--
<?php 
        require_once('skipif.inc');
?>
--FILE--
<?php
        require_once('test.inc');
        if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
                dba_insert("key1", "This is a test insert", $db_file);
                dba_replace("key1", "This is the replacement text", $db_file);
                $a = dba_fetch("key1", $db_file);
                dba_close($db_file);
                echo $a;
        } else {
                echo "Error creating database\n";
        }
?>
--EXPECT--
This is the replacement text

Index: php4/ext/dba/tests/004.phpt
+++ php4/ext/dba/tests/004.phpt
--TEST--
DBA Multiple Insert/Fetch Test
--SKIPIF--
<?php 
        require_once('skipif.inc');
?>
--FILE--
<?php
        require_once('test.inc');
        if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
                dba_insert("key1", "Content String 1", $db_file);
                dba_insert("key2", "Content String 2", $db_file);
                dba_insert("key3", "Third Content String", $db_file);
                dba_insert("key4", "Another Content String", $db_file);
                dba_insert("key5", "The last content string", $db_file);
                $a = dba_fetch("key4", $db_file);
                $b = dba_fetch("key2", $db_file);
                dba_close($db_file);
                echo "$a $b";
        } else {
                echo "Error creating database\n";
        }
?>
--EXPECT--
Another Content String Content String 2

Index: php4/ext/dba/tests/005.phpt
+++ php4/ext/dba/tests/005.phpt
--TEST--
DBA FirstKey/NextKey Loop Test With 5 Items
--SKIPIF--
<?php 
        require_once('skipif.inc');
?>
--FILE--
<?php
        require_once('test.inc');
        if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
                dba_insert("key1", "Content String 1", $db_file);
                dba_insert("key2", "Content String 2", $db_file);
                dba_insert("key3", "Third Content String", $db_file);
                dba_insert("key4", "Another Content String", $db_file);
                dba_insert("key5", "The last content string", $db_file);
                $a = dba_firstkey($db_file);
                $i=0;
                while($a) {
                        $a = dba_nextkey($db_file);
                        $i++;
                }
                echo $i;
                for ($i=1; $i<6; $i++) {
                        echo dba_exists("key$i", $db_file) ? "Y" : "N";
                }
                dba_close($db_file);
        } else {
                echo "Error creating database\n";
        }
?>
--EXPECT--
5YYYYY

Index: php4/ext/dba/tests/006.phpt
+++ php4/ext/dba/tests/006.phpt
--TEST--
DBA FirstKey/NextKey with 2 deletes
--SKIPIF--
<?php 
        require_once('skipif.inc');
?>
--FILE--
<?php
        require_once('test.inc');
        if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
                dba_insert("key1", "Content String 1", $db_file);
                dba_insert("key2", "Content String 2", $db_file);
                dba_insert("key3", "Third Content String", $db_file);
                dba_insert("key4", "Another Content String", $db_file);
                dba_insert("key5", "The last content string", $db_file);
                dba_delete("key3", $db_file);
                dba_delete("key1", $db_file);
                $a = dba_firstkey($db_file);
                $i=0;
                while($a) {
                        $a = dba_nextkey($db_file);
                        $i++;
                }
                echo $i;
                for ($i=1; $i<6; $i++) {
                        echo dba_exists("key$i", $db_file) ? "Y" : "N";
                }
                dba_close($db_file);
        } else {
                echo "Error creating database\n";
        }
?>
--EXPECT--
3NYNYY
Index: php4/ext/dba/tests/skipif.inc
+++ php4/ext/dba/tests/skipif.inc
<?php
        if (!extension_loaded('dba')) die('skip dba extension not available');
        if (!function_exists('dba_handlers')) die ('skip dba_handlers() not 
available');
        if (!sizeof(dba_handlers())) die('skip no handlers installed');
?>

Index: php4/ext/dba/tests/test.inc
+++ php4/ext/dba/tests/test.inc
<?php
        $db_file = dirname(__FILE__).'/test.dbm'; 
        $handler = dba_handlers(); 
        $handler = $handler[0];
?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to