Skip to content

Commit cf7101d

Browse files
committed
Support all possible configurations and simplify includes
1 parent 238abf8 commit cf7101d

13 files changed

+40
-44
lines changed

Diff for: ext/dba/tests/dba_cdb.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
DBA CDB handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'cdb';
56
require_once('skipif.inc');
6-
if (!in_array('cdb', dba_handlers())) die('skip CDB handler not available');
77
die('info CDB does not support replace or delete');
88
?>
99
--FILE--
1010
<?php
11-
require_once('test.inc');
1211
$handler = 'cdb';
12+
require_once('test.inc');
1313
require_once('dba_handler.inc');
1414
?>
1515
--EXPECT--

Diff for: ext/dba/tests/dba_cdb_make.phpt

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ DBA CDB_MAKE handler test
44
magic_quotes_runtime=1
55
--SKIPIF--
66
<?php
7+
$handler = 'cdb_make';
78
require_once('skipif.inc');
8-
if (!in_array('cdb_make', dba_handlers())) die('skip CDB_MAKE handler not available');
9+
die('info CDB_MAKE does not support reading');
910
?>
1011
--FILE--
1112
<?php
12-
require_once('test.inc');
1313
$handler = 'cdb_make';
14+
require_once('test.inc');
1415
echo "database handler: $handler\n";
1516
// print md5 checksum of test.cdb which is generated by cdb_make program
1617
var_dump(md5(implode('',file(dirname(__FILE__).'/test.cdb'))));

Diff for: ext/dba/tests/dba_cdb_read.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
DBA CDB handler test (read only)
33
--SKIPIF--
44
<?php
5-
if (!extension_loaded('dba')) die('skip dba extension not available');
6-
if (!in_array('cdb', dba_handlers())) die('skip CDB handler not available');
5+
$handler = 'cdb_make';
6+
require_once('skipif.inc');
77
?>
88
--FILE--
99
<?php

Diff for: ext/dba/tests/dba_db2.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA DB2 handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'db2';
56
require_once('skipif.inc');
6-
if (!in_array('db2', dba_handlers())) die('skip DB2 handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'db2';
11+
require_once('test.inc');
1212
require_once('dba_handler.inc');
1313
?>
1414
--EXPECT--

Diff for: ext/dba/tests/dba_db3.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA DB3 handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'db3';
56
require_once('skipif.inc');
6-
if (!in_array('db3', dba_handlers())) die('skip DB3 handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'db3';
11+
require_once('test.inc');
1212
require_once('dba_handler.inc');
1313
?>
1414
--EXPECT--

Diff for: ext/dba/tests/dba_db4.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA DB4 handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'db4';
56
require_once('skipif.inc');
6-
if (!in_array('db4', dba_handlers())) die('skip DB4 handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'db4';
11+
require_once('test.inc');
1212
require_once('dba_handler.inc');
1313
?>
1414
--EXPECT--

Diff for: ext/dba/tests/dba_dbm.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA DBM handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'dbm';
56
require_once('skipif.inc');
6-
if (!in_array('dbm', dba_handlers())) die('skip DBM handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'dbm';
11+
require_once('test.inc');
1212
require_once('dba_handler.inc');
1313
?>
1414
--EXPECT--

Diff for: ext/dba/tests/dba_flatfile.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA FlatFile handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'flatfile';
56
require_once('skipif.inc');
6-
if (!in_array('flatfile', dba_handlers())) die('skip FlatFile handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'flatfile';
11+
require_once('test.inc');
1212
require_once('dba_handler.inc');
1313
?>
1414
--EXPECT--

Diff for: ext/dba/tests/dba_gdbm.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA GDBM handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'gdbm';
56
require_once('skipif.inc');
6-
if (!in_array('gdbm', dba_handlers())) die('skip GDBM handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'gdbm';
11+
require_once('test.inc');
1212
$lock_flag = ''; // lock in library
1313
require_once('dba_handler.inc');
1414

Diff for: ext/dba/tests/dba_inifile.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA INIFILE handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'inifile';
56
require_once('skipif.inc');
6-
if (!in_array('inifile', dba_handlers())) die('skip INIFILE handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'inifile';
11+
require_once('test.inc');
1212
require_once('dba_handler.inc');
1313
?>
1414
--EXPECT--

Diff for: ext/dba/tests/dba_ndbm.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
DBA NDBM handler test
33
--SKIPIF--
44
<?php
5+
$handler = 'ndbm';
56
require_once('skipif.inc');
6-
if (!in_array('ndbm', dba_handlers())) die('skip NDBM handler not available');
77
?>
88
--FILE--
99
<?php
10-
require_once('test.inc');
1110
$handler = 'ndbm';
11+
require_once('test.inc');
1212
require_once('dba_handler.inc');
1313
?>
1414
--EXPECT--

Diff for: ext/dba/tests/skipif.inc

+15-10
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
if (!extension_loaded('dba')) die('skip dba extension not available');
33
if (!function_exists('dba_handlers')) die ('skip dba_handlers() not available');
44
if (!sizeof(dba_handlers())) die('skip no handlers installed');
5-
$handler = dba_handlers();
6-
if (in_array('flatfile', $handler)) {
7-
$handler = 'flatfile';
8-
} elseif ($handler[0]=='cdb') { // CDB currently supports only reading
9-
if (count($handler)==1) {
10-
die('skip CDB currently supports only reading');
5+
if (!isset($handler)) {
6+
$handlers = dba_handlers();
7+
$handler = false;
8+
$acceptable = array('flatfile','db4','db3','db2','gdbm','ndbm','dbm','inifile');
9+
foreach($acceptable as $hnd) {
10+
if (in_array($hnd, $handlers)) {
11+
$handler = $hnd;
12+
break;
13+
}
1114
}
12-
if ($handler[1]=='cdb_make' && count($handler)==2) {
13-
die('skip CDB currently supports only reading and creating');
15+
if ($handler === false) {
16+
die('skip No acceptable handler found');
1417
}
15-
$handler = $handler[1];
1618
} else {
17-
$handler = $handler[0];
19+
if (!in_array($handler, dba_handlers())) {
20+
$HND = strtoupper($handler);
21+
die("skip $HND handler not available");
22+
}
1823
}
1924
$HND = strtoupper($handler);
2025
?>

Diff for: ext/dba/tests/test.inc

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
<?php
2-
$db_filename = $db_file = dirname(__FILE__).'/test0.dbm';
3-
$handler = dba_handlers();
4-
if (in_array('flatfile', $handler)) {
5-
$handler = 'flatfile';
6-
} elseif ($handler[0]=='cdb') { // CDB currently supports only reading
7-
if (count($handler)==1) {
8-
die('CDB currently supports only reading ');
9-
}
10-
$handler = $handler[1];
11-
} else {
12-
$handler = $handler[0];
13-
}
2+
require_once('skipif.inc');
143
$lock_flag = 'l';
4+
$db_filename = $db_file = dirname(__FILE__).'/test0.dbm';
155
@unlink($db_filename);
166
@unlink($db_filename.'.lck');
177
?>

0 commit comments

Comments
 (0)