sixd                                     Fri, 12 Mar 2010 00:27:57 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=296095

Log:
New and improved DBA tests

Changed paths:
    A   php/php-src/branches/PHP_5_3/ext/dba/tests/dba012.phpt
    A   php/php-src/branches/PHP_5_3/ext/dba/tests/dba013.phpt
    A   php/php-src/branches/PHP_5_3/ext/dba/tests/dba014.phpt
    A   php/php-src/branches/PHP_5_3/ext/dba/tests/dba015.phpt
    U   php/php-src/branches/PHP_5_3/ext/dba/tests/dba_db4_003.phpt

Added: php/php-src/branches/PHP_5_3/ext/dba/tests/dba012.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dba/tests/dba012.phpt                      
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/dba/tests/dba012.phpt      2010-03-12 
00:27:57 UTC (rev 296095)
@@ -0,0 +1,42 @@
+--TEST--
+DBA dba.default_handler tests
+--SKIPIF--
+<?php
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/skipif.inc');
+?>
+--INI--
+dba.default_handler=flatfile
+--FILE--
+<?php
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+echo "Test 1\n";
+
+ini_set('dba.default_handler', 'does_not_exist');
+
+var_dump(dba_open($db_filename, 'c'));
+
+echo "Test 2\n";
+
+ini_set('dba.default_handler', '');
+
+var_dump(dba_open($db_filename, 'n'));
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: flatfile
+Test 1
+
+Warning: ini_set(): No such handler: does_not_exist in %sdba012.php on line %d
+resource(%d) of type (dba)
+Test 2
+
+Warning: dba_open(%stest0.dbm,n): No default handler selected in %sdba012.php 
on line %d
+bool(false)


Property changes on: php/php-src/branches/PHP_5_3/ext/dba/tests/dba012.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Added: php/php-src/branches/PHP_5_3/ext/dba/tests/dba013.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dba/tests/dba013.phpt                      
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/dba/tests/dba013.phpt      2010-03-12 
00:27:57 UTC (rev 296095)
@@ -0,0 +1,27 @@
+--TEST--
+DBA with array key with empty array
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+    dba_insert(array(), "Content String 1", $db_file);
+} else {
+    echo "Error creating database\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+
+Catchable fatal error: dba_insert(): Key does not have exactly two elements: 
(key, name) in %sdba013.php on line %d


Property changes on: php/php-src/branches/PHP_5_3/ext/dba/tests/dba013.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Added: php/php-src/branches/PHP_5_3/ext/dba/tests/dba014.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dba/tests/dba014.phpt                      
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/dba/tests/dba014.phpt      2010-03-12 
00:27:57 UTC (rev 296095)
@@ -0,0 +1,27 @@
+--TEST--
+DBA with array key with array containing too many elements
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+    dba_insert(array("a", "b", "c"), "Content String 2", $db_file);
+} else {
+    echo "Error creating database\n";
+}
+
+?>
+--CLEAN--
+<?php
+require(dirname(__FILE__) .'/clean.inc');
+?>
+--EXPECTF--
+database handler: %s
+
+Catchable fatal error: dba_insert(): Key does not have exactly two elements: 
(key, name) in %sdba014.php on line %d


Property changes on: php/php-src/branches/PHP_5_3/ext/dba/tests/dba014.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Added: php/php-src/branches/PHP_5_3/ext/dba/tests/dba015.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dba/tests/dba015.phpt                      
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/dba/tests/dba015.phpt      2010-03-12 
00:27:57 UTC (rev 296095)
@@ -0,0 +1,76 @@
+--TEST--
+DBA with persistent connections
+--SKIPIF--
+<?php
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/skipif.inc');
+die("info $HND handler used");
+?>
+--FILE--
+<?php
+
+$handler = "flatfile";
+require_once(dirname(__FILE__) .'/test.inc');
+echo "database handler: $handler\n";
+
+echo "Test 1\n";
+$db_file1 = dba_popen($db_filename, 'n', 'flatfile');
+dba_insert("key1", "This is a test insert 1", $db_file1);
+echo dba_fetch("key1", $db_file1), "\n";
+
+
+echo "Test 2\n";
+$db_file2 = dba_popen($db_filename, 'n', 'flatfile');
+if ($db_file1 === $db_file2) {
+    echo "resources are the same\n";
+} else {
+    echo "resources are different\n";
+}
+
+
+echo "Test 3 - fetch both rows from second resource\n";
+dba_insert("key2", "This is a test insert 2", $db_file2);
+echo dba_fetch("key1", $db_file2), "\n";
+echo dba_fetch("key2", $db_file2), "\n";
+
+
+echo "Test 4 - fetch both rows from first resource\n";
+echo dba_fetch("key1", $db_file1), "\n";
+echo dba_fetch("key2", $db_file1), "\n";
+
+echo "Test 5 - close 2nd resource\n";
+dba_close($db_file2);
+var_dump($db_file1);
+var_dump($db_file2);
+
+echo "Test 6 - query after closing 2nd resource\n";
+echo dba_fetch("key1", $db_file1), "\n";
+echo dba_fetch("key2", $db_file1), "\n";
+
+?>
+===DONE===
+--CLEAN--
+<?php
+       require(dirname(__FILE__) .'/clean.inc');
+?>
+--XFAIL--
+Test 6 crashes in flatfile_findkey with dba pointer of NULL, bug 
http://bugs.php.net/bug.php?id=51278
+--EXPECTF--
+database handler: flatfile
+Test 1
+This is a test insert 1
+Test 2
+resources are different
+Test 3 - fetch both rows from second resource
+This is a test insert 1
+This is a test insert 2
+Test 4 - fetch both rows from first resource
+This is a test insert 1
+This is a test insert 2
+Test 5 - close 2nd resource
+resource(%d) of type (dba persistent)
+resource(%d) of type (Unknown)
+Test 6 - query after closing 2nd resource
+This is a test insert 1
+This is a test insert 2
+===DONE===


Property changes on: php/php-src/branches/PHP_5_3/ext/dba/tests/dba015.phpt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Revision
Added: svn:eol-style
   + native

Modified: php/php-src/branches/PHP_5_3/ext/dba/tests/dba_db4_003.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/dba/tests/dba_db4_003.phpt 2010-03-11 
22:42:35 UTC (rev 296094)
+++ php/php-src/branches/PHP_5_3/ext/dba/tests/dba_db4_003.phpt 2010-03-12 
00:27:57 UTC (rev 296095)
@@ -26,6 +26,10 @@
     echo "Error creating $db_filename\n";
 }

+// Check the file still exists
+$s = file_get_contents($db_filename);
+echo "$s\n";
+
 ?>
 --CLEAN--
 <?php
@@ -39,3 +43,4 @@

 Warning: dba_open(%stest0.dbm,c): Driver initialization failed for handler: 
db4: Invalid argument in %sdba_db4_003.php on line %d
 Error creating %stest0.dbm
+Dummy contents

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

Reply via email to