Skip to content

Commit 96ab6e8

Browse files
committed
More transaction tests
1 parent 7a44bbd commit 96ab6e8

File tree

5 files changed

+93
-7
lines changed

5 files changed

+93
-7
lines changed

tests/functions.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,8 @@ function ibase_query_bulk(array $queries, $tr = null) {
147147
}
148148
}
149149
}
150+
151+
/** @var Exception $e */
152+
function php_ibase_exception_handler($e) {
153+
echo "Fatal error: Uncaught ".get_class($e).": ", $e->getMessage(), "\n";
154+
}

tests/ibase_trans_004.phpt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
--TEST--
22
ibase_trans(): handles
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php
5+
include("skipif.inc");
6+
// TODO: Further investigation needed.
7+
// On FB2.5 server "invalid transaction handle" happens on fetch.
8+
// Related to tests/ibase_trans_012.phpt
9+
skip_if_fb_lt(3.0);
10+
?>
511
--FILE--
612
<?php
713

814
require("interbase.inc");
915

1016
(function() {
11-
$t = ibase_trans();
17+
var_dump($t = ibase_trans());
1218
var_dump(ibase_query($t, "COMMIT"));
1319
var_dump($t);
14-
ibase_query($t, "SELECT * FROM TEST1");
20+
var_dump(ibase_query($t, "SELECT * FROM TEST1"));
1521
})();
1622

1723
?>
1824
--EXPECTF--
25+
resource(12) of type (Firebird/InterBase transaction)
1926
bool(true)
2027
resource(%d) of type (Firebird/InterBase transaction)
2128

2229
Warning: ibase_query(): invalid transaction handle (expecting explicit transaction start)%s
30+
bool(false)

tests/ibase_trans_006.phpt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
--TEST--
22
ibase_trans(): handles
33
--SKIPIF--
4-
<?php include("skipif.inc"); ?>
4+
<?php
5+
include("skipif.inc");
6+
// On FB2.5 server "invalid transaction handle" happens on fetch.
7+
// TODO: Further investigation needed.
8+
// Related to tests/ibase_trans_013.phpt
9+
skip_if_fb_lt(3.0);
10+
?>
511
--FILE--
612
<?php
713

814
require("interbase.inc");
915

1016
(function() {
11-
$t = ibase_query("SET TRANSACTION");
12-
ibase_rollback($t);
17+
var_dump($t = ibase_query("SET TRANSACTION"));
18+
var_dump(ibase_rollback($t));
1319
var_dump($t);
14-
ibase_query($t, "SELECT * FROM TEST1");
20+
var_dump(ibase_query($t, "SELECT * FROM TEST1"));
1521
})();
1622

1723
?>
1824
--EXPECTF--
1925
resource(%d) of type (Firebird/InterBase transaction)
26+
bool(true)
27+
resource(%d) of type (Firebird/InterBase transaction)
2028

2129
Warning: ibase_query(): invalid transaction handle (expecting explicit transaction start)%s
30+
bool(false)

tests/ibase_trans_012.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
ibase_trans(): handles
3+
--SKIPIF--
4+
<?php
5+
include("skipif.inc");
6+
// TODO: Further investigation needed.
7+
// On FB2.5 server "invalid transaction handle" happens on fetch.
8+
// Related to tests/ibase_trans_004.phpt
9+
skip_if_fb_gt(2.5);
10+
?>
11+
--FILE--
12+
<?php
13+
14+
require("interbase.inc");
15+
16+
(function() {
17+
var_dump($t = ibase_trans());
18+
var_dump(ibase_query($t, "COMMIT"));
19+
var_dump($t);
20+
var_dump($q = ibase_query($t, "SELECT * FROM TEST1"));
21+
var_dump(ibase_fetch_assoc($q));
22+
})();
23+
24+
?>
25+
--EXPECTF--
26+
resource(%d) of type (Firebird/InterBase transaction)
27+
bool(true)
28+
resource(%d) of type (Firebird/InterBase transaction)
29+
resource(%d) of type (interbase %s)
30+
31+
Warning: ibase_fetch_assoc(): Dynamic SQL Error SQL error code = -901 invalid transaction handle (expecting explicit transaction start)%s
32+
bool(false)

tests/ibase_trans_013.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
ibase_trans(): handles
3+
--SKIPIF--
4+
<?php
5+
include("skipif.inc");
6+
// On FB2.5 server "invalid transaction handle" happens on fetch.
7+
// TODO: Further investigation needed.
8+
// Related to tests/ibase_trans_013.phpt
9+
skip_if_fb_gt(2.5);
10+
?>
11+
--FILE--
12+
<?php
13+
14+
require("interbase.inc");
15+
16+
(function() {
17+
var_dump($t = ibase_query("SET TRANSACTION"));
18+
var_dump(ibase_rollback($t));
19+
var_dump($t);
20+
var_dump($q = ibase_query($t, "SELECT * FROM TEST1"));
21+
var_dump(ibase_fetch_assoc($q));
22+
})();
23+
24+
?>
25+
--EXPECTF--
26+
resource(%d) of type (Firebird/InterBase transaction)
27+
bool(true)
28+
resource(%d) of type (Firebird/InterBase transaction)
29+
resource(%d) of type (interbase %s)
30+
31+
Warning: ibase_fetch_assoc(): Dynamic SQL Error SQL error code = -901 invalid transaction handle (expecting explicit transaction start) %s
32+
bool(false)

0 commit comments

Comments
 (0)