Skip to content

Commit 660370d

Browse files
committed
Test lock file combination
Also make test resilliants for 'any driver' as cdb and inifile are weird
1 parent a665115 commit 660370d

19 files changed

+433
-332
lines changed

ext/dba/tests/bug36436.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ check_skip('db4');
1212
require_once __DIR__ . '/setup/setup_dba_tests.inc';
1313
$db_name = 'bug36436.db';
1414

15-
$db = set_up_db_ex('db4', $db_name, false, true);
15+
$db = set_up_db_ex('db4', $db_name, LockFlag::DbLock, persistent: true);
1616

1717
var_dump($db, dba_fetch('key1', $db));
1818

ext/dba/tests/bug65708.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ require_once __DIR__ . '/setup/setup_dba_tests.inc';
3434
$db_name = 'bug65708.db';
3535
cleanup_standard_db($db_name);
3636
?>
37-
--EXPECT--
37+
--EXPECTF--
38+
Using handler: "%s"
3839
integer
3940
integer
4041
integer

ext/dba/tests/dba_array_keys.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ require_once __DIR__ . '/setup/setup_dba_tests.inc';
3131
$db_name = 'array_keys_basic.db';
3232
cleanup_standard_db($db_name);
3333
?>
34-
--EXPECT--
34+
--EXPECTF--
35+
Using handler: "%s"
3536
bool(true)
3637
bool(true)
3738
bool(true)

ext/dba/tests/dba_array_keys_errors.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ require_once __DIR__ . '/setup/setup_dba_tests.inc';
4747
$db_name = 'array_keys_errors.db';
4848
cleanup_standard_db($db_name);
4949
?>
50-
--EXPECT--
50+
--EXPECTF--
51+
Using handler: "%s"
5152
Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name"
5253
Error: dba_insert(): Argument #1 ($key) must have exactly two elements: "key" and "name"
5354
Error: Object of class stdClass could not be converted to string
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
DBA check behaviour of array keys (inifile version)
3+
--EXTENSIONS--
4+
dba
5+
--SKIPIF--
6+
<?php
7+
require_once __DIR__ . '/setup/setup_dba_tests.inc';
8+
check_skip('inifile');
9+
?>
10+
--FILE--
11+
<?php
12+
require_once __DIR__ . '/setup/setup_dba_tests.inc';
13+
$name = 'array_keys_inifle.db';
14+
15+
$db = dba_open($name, 'c', 'inifile');
16+
17+
var_dump(dba_insert(['group', 'name'], 'Normal group', $db));
18+
var_dump(dba_insert(['group', ''], 'Empty name', $db));
19+
var_dump(dba_insert(['', 'name'], 'Empty group', $db));
20+
var_dump(dba_insert(['', ''], 'Empty keys', $db));
21+
var_dump(dba_fetch(['group', 'name'], $db));
22+
var_dump(dba_fetch(['group', ''], $db));
23+
var_dump(dba_fetch(['', 'name'], $db));
24+
var_dump(dba_fetch(['', ''], $db));
25+
dba_close($db);
26+
27+
?>
28+
--CLEAN--
29+
<?php
30+
require_once __DIR__ . '/setup/setup_dba_tests.inc';
31+
$db_name = 'array_keys_basic.db';
32+
cleanup_standard_db($db_name);
33+
?>
34+
--EXPECTF--
35+
bool(true)
36+
bool(true)
37+
bool(true)
38+
bool(true)
39+
string(12) "Normal group"
40+
string(0) ""
41+
string(11) "Empty group"
42+
bool(false)

ext/dba/tests/dba_array_keys_var_non_string.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ require_once __DIR__ . '/setup/setup_dba_tests.inc';
3131
$db_name = 'array_keys_non_string.db';
3232
cleanup_standard_db($db_name);
3333
?>
34-
--EXPECT--
34+
--EXPECTF--
35+
Using handler: "%s"
3536
array(2) {
3637
[0]=>
3738
int(5)

ext/dba/tests/dba_db1.phpt

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require_once __DIR__ . '/setup/setup_dba_tests.inc';
1313
$db_name = 'dba_db1.db';
1414

1515
$handler = 'db1';
16-
set_up_db($handler, $db_name);
1716
run_standard_tests($handler, $db_name);
1817

1918
?>
@@ -24,15 +23,19 @@ $db_name = 'dba_db1.db';
2423
cleanup_standard_db($db_name);
2524
?>
2625
--EXPECT--
26+
=== RUNNING WITH FILE LOCK ===
2727
Remove key 1 and 3
2828
bool(true)
2929
bool(true)
3030
Try to remove key 1 again
3131
bool(false)
32+
[key10]name10: Content String 10
33+
[key30]name30: Content String 30
3234
key2: Content String 2
3335
key4: Another Content String
3436
key5: The last content string
35-
Total keys: 3
37+
name9: Content String 9
38+
Total keys: 6
3639
Key 1 exists? N
3740
Key 2 exists? Y
3841
Key 3 exists? N
@@ -50,46 +53,21 @@ Delete "key4"
5053
bool(true)
5154
Fetch "key2": Content 2 replaced 2nd time
5255
Fetch "key number 6": The 6th value
53-
array(3) {
54-
["key number 6"]=>
55-
string(13) "The 6th value"
56-
["key2"]=>
57-
string(27) "Content 2 replaced 2nd time"
58-
["key5"]=>
59-
string(23) "The last content string"
60-
}
61-
--NO-LOCK--
62-
Remove key 1 and 3
63-
bool(true)
64-
bool(true)
65-
Try to remove key 1 again
66-
bool(false)
67-
key2: Content String 2
68-
key4: Another Content String
69-
key5: The last content string
70-
Total keys: 3
71-
Key 1 exists? N
72-
Key 2 exists? Y
73-
Key 3 exists? N
74-
Key 4 exists? Y
75-
Key 5 exists? Y
76-
Replace second key data
77-
bool(true)
78-
Content 2 replaced
79-
Read during write: not allowed
80-
Expected: Added a new data entry
81-
Expected: Failed to insert data for already used key
82-
Replace second key data
83-
bool(true)
84-
Delete "key4"
85-
bool(true)
86-
Fetch "key2": Content 2 replaced 2nd time
87-
Fetch "key number 6": The 6th value
88-
array(3) {
56+
array(6) {
57+
["[key10]name10"]=>
58+
string(17) "Content String 10"
59+
["[key30]name30"]=>
60+
string(17) "Content String 30"
8961
["key number 6"]=>
9062
string(13) "The 6th value"
9163
["key2"]=>
9264
string(27) "Content 2 replaced 2nd time"
9365
["key5"]=>
9466
string(23) "The last content string"
67+
["name9"]=>
68+
string(16) "Content String 9"
9569
}
70+
=== RUNNING WITH DB LOCK (default) ===
71+
SAME OUTPUT AS PREVIOUS RUN
72+
=== RUNNING WITH NO LOCK ===
73+
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

ext/dba/tests/dba_db2.phpt

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require_once __DIR__ . '/setup/setup_dba_tests.inc';
1313
$db_name = 'dba_db2.db';
1414

1515
$handler = 'db2';
16-
set_up_db($handler, $db_name);
1716
run_standard_tests($handler, $db_name);
1817

1918
?>
@@ -24,15 +23,19 @@ $db_name = 'dba_db2.db';
2423
cleanup_standard_db($db_name);
2524
?>
2625
--EXPECT--
26+
=== RUNNING WITH FILE LOCK ===
2727
Remove key 1 and 3
2828
bool(true)
2929
bool(true)
3030
Try to remove key 1 again
3131
bool(false)
32+
[key10]name10: Content String 10
33+
[key30]name30: Content String 30
3234
key2: Content String 2
3335
key4: Another Content String
3436
key5: The last content string
35-
Total keys: 3
37+
name9: Content String 9
38+
Total keys: 6
3639
Key 1 exists? N
3740
Key 2 exists? Y
3841
Key 3 exists? N
@@ -50,46 +53,21 @@ Delete "key4"
5053
bool(true)
5154
Fetch "key2": Content 2 replaced 2nd time
5255
Fetch "key number 6": The 6th value
53-
array(3) {
54-
["key number 6"]=>
55-
string(13) "The 6th value"
56-
["key2"]=>
57-
string(27) "Content 2 replaced 2nd time"
58-
["key5"]=>
59-
string(23) "The last content string"
60-
}
61-
--NO-LOCK--
62-
Remove key 1 and 3
63-
bool(true)
64-
bool(true)
65-
Try to remove key 1 again
66-
bool(false)
67-
key2: Content String 2
68-
key4: Another Content String
69-
key5: The last content string
70-
Total keys: 3
71-
Key 1 exists? N
72-
Key 2 exists? Y
73-
Key 3 exists? N
74-
Key 4 exists? Y
75-
Key 5 exists? Y
76-
Replace second key data
77-
bool(true)
78-
Content 2 replaced
79-
Read during write: not allowed
80-
Expected: Added a new data entry
81-
Expected: Failed to insert data for already used key
82-
Replace second key data
83-
bool(true)
84-
Delete "key4"
85-
bool(true)
86-
Fetch "key2": Content 2 replaced 2nd time
87-
Fetch "key number 6": The 6th value
88-
array(3) {
56+
array(6) {
57+
["[key10]name10"]=>
58+
string(17) "Content String 10"
59+
["[key30]name30"]=>
60+
string(17) "Content String 30"
8961
["key number 6"]=>
9062
string(13) "The 6th value"
9163
["key2"]=>
9264
string(27) "Content 2 replaced 2nd time"
9365
["key5"]=>
9466
string(23) "The last content string"
67+
["name9"]=>
68+
string(16) "Content String 9"
9569
}
70+
=== RUNNING WITH DB LOCK (default) ===
71+
SAME OUTPUT AS PREVIOUS RUN
72+
=== RUNNING WITH NO LOCK ===
73+
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

ext/dba/tests/dba_db3.phpt

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require_once __DIR__ . '/setup/setup_dba_tests.inc';
1313
$db_name = 'dba_db3.db';
1414

1515
$handler = 'db3';
16-
set_up_db($handler, $db_name);
1716
run_standard_tests($handler, $db_name);
1817

1918
?>
@@ -24,15 +23,19 @@ $db_name = 'dba_db3.db';
2423
cleanup_standard_db($db_name);
2524
?>
2625
--EXPECT--
26+
=== RUNNING WITH FILE LOCK ===
2727
Remove key 1 and 3
2828
bool(true)
2929
bool(true)
3030
Try to remove key 1 again
3131
bool(false)
32+
[key10]name10: Content String 10
33+
[key30]name30: Content String 30
3234
key2: Content String 2
3335
key4: Another Content String
3436
key5: The last content string
35-
Total keys: 3
37+
name9: Content String 9
38+
Total keys: 6
3639
Key 1 exists? N
3740
Key 2 exists? Y
3841
Key 3 exists? N
@@ -50,46 +53,21 @@ Delete "key4"
5053
bool(true)
5154
Fetch "key2": Content 2 replaced 2nd time
5255
Fetch "key number 6": The 6th value
53-
array(3) {
54-
["key number 6"]=>
55-
string(13) "The 6th value"
56-
["key2"]=>
57-
string(27) "Content 2 replaced 2nd time"
58-
["key5"]=>
59-
string(23) "The last content string"
60-
}
61-
--NO-LOCK--
62-
Remove key 1 and 3
63-
bool(true)
64-
bool(true)
65-
Try to remove key 1 again
66-
bool(false)
67-
key2: Content String 2
68-
key4: Another Content String
69-
key5: The last content string
70-
Total keys: 3
71-
Key 1 exists? N
72-
Key 2 exists? Y
73-
Key 3 exists? N
74-
Key 4 exists? Y
75-
Key 5 exists? Y
76-
Replace second key data
77-
bool(true)
78-
Content 2 replaced
79-
Read during write: not allowed
80-
Expected: Added a new data entry
81-
Expected: Failed to insert data for already used key
82-
Replace second key data
83-
bool(true)
84-
Delete "key4"
85-
bool(true)
86-
Fetch "key2": Content 2 replaced 2nd time
87-
Fetch "key number 6": The 6th value
88-
array(3) {
56+
array(6) {
57+
["[key10]name10"]=>
58+
string(17) "Content String 10"
59+
["[key30]name30"]=>
60+
string(17) "Content String 30"
8961
["key number 6"]=>
9062
string(13) "The 6th value"
9163
["key2"]=>
9264
string(27) "Content 2 replaced 2nd time"
9365
["key5"]=>
9466
string(23) "The last content string"
67+
["name9"]=>
68+
string(16) "Content String 9"
9569
}
70+
=== RUNNING WITH DB LOCK (default) ===
71+
SAME OUTPUT AS PREVIOUS RUN
72+
=== RUNNING WITH NO LOCK ===
73+
SAME OUTPUT AS PREVIOUS RUN (modulo read during write due to no lock)

0 commit comments

Comments
 (0)