Skip to content

Commit 9218922

Browse files
committed
Split tests/ibase_drop_db_001.phpt into 4 tests
This patch splits `tests/ibase_drop_db_001.phpt` into 4 tests so that we can check for different error messages depending on which PHP version we are running.
1 parent 7017460 commit 9218922

File tree

4 files changed

+89
-8
lines changed

4 files changed

+89
-8
lines changed

tests/ibase_drop_db_001.phpt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,8 @@ $db = ibase_query(IBASE_CREATE,
1616

1717
var_dump($db);
1818
var_dump(ibase_drop_db($db));
19-
var_dump(ibase_drop_db(1));
20-
var_dump(ibase_drop_db(NULL));
2119

2220
?>
2321
--EXPECTF--
2422
resource(%d) of type (Firebird/InterBase link)
2523
bool(true)
26-
27-
Warning: ibase_drop_db() expects parameter 1 to be resource, int given in %s on line %d
28-
NULL
29-
30-
Warning: ibase_drop_db() expects parameter 1 to be resource, null given in %s on line %d
31-
NULL

tests/ibase_drop_db_002.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
ibase_drop_db(): Make sure passing an integer or null to the function emits a warning
3+
--SKIPIF--
4+
<?php
5+
include("skipif.inc");
6+
include("skipif-php8-or-newer.inc");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require("config.inc");
12+
13+
unlink($file = tempnam('/tmp',"php_ibase_test"));
14+
15+
$db = ibase_query(IBASE_CREATE,
16+
sprintf("CREATE SCHEMA '%s' USER '%s' PASSWORD '%s' DEFAULT CHARACTER SET %s",$file,
17+
$user, $password, ($charset = ini_get('ibase.default_charset')) ? $charset : 'NONE'));
18+
19+
var_dump($db);
20+
var_dump(ibase_drop_db($db));
21+
var_dump(ibase_drop_db(1));
22+
var_dump(ibase_drop_db(NULL));
23+
24+
?>
25+
--EXPECTF--
26+
resource(%d) of type (Firebird/InterBase link)
27+
bool(true)
28+
29+
Warning: ibase_drop_db() expects parameter 1 to be resource, int given in %s on line %d
30+
NULL
31+
32+
Warning: ibase_drop_db() expects parameter 1 to be resource, null given in %s on line %d
33+
NULL

tests/ibase_drop_db_003.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
ibase_drop_db(): Make sure passing an integer to the function throws an error.
3+
--SKIPIF--
4+
<?php
5+
include("skipif.inc");
6+
include("skipif-php7-or-older.inc");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require("config.inc");
12+
13+
unlink($file = tempnam('/tmp',"php_ibase_test"));
14+
15+
$db = ibase_query(IBASE_CREATE,
16+
sprintf("CREATE SCHEMA '%s' USER '%s' PASSWORD '%s' DEFAULT CHARACTER SET %s",$file,
17+
$user, $password, ($charset = ini_get('ibase.default_charset')) ? $charset : 'NONE'));
18+
19+
var_dump($db);
20+
var_dump(ibase_drop_db($db));
21+
var_dump(ibase_drop_db(1));
22+
23+
?>
24+
--EXPECTF--
25+
resource(%d) of type (Firebird/InterBase link)
26+
bool(true)
27+
28+
Fatal error: Uncaught TypeError: ibase_drop_db(): Argument #1 ($link_identifier) must be of type resource, int given in %a

tests/ibase_drop_db_004.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
ibase_drop_db(): Make sure passing null to the function throws an error.
3+
--SKIPIF--
4+
<?php
5+
include("skipif.inc");
6+
include("skipif-php7-or-older.inc");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require("config.inc");
12+
13+
unlink($file = tempnam('/tmp',"php_ibase_test"));
14+
15+
$db = ibase_query(IBASE_CREATE,
16+
sprintf("CREATE SCHEMA '%s' USER '%s' PASSWORD '%s' DEFAULT CHARACTER SET %s",$file,
17+
$user, $password, ($charset = ini_get('ibase.default_charset')) ? $charset : 'NONE'));
18+
19+
var_dump($db);
20+
var_dump(ibase_drop_db($db));
21+
var_dump(ibase_drop_db(NULL));
22+
23+
?>
24+
--EXPECTF--
25+
resource(%d) of type (Firebird/InterBase link)
26+
bool(true)
27+
28+
Fatal error: Uncaught TypeError: ibase_drop_db(): Argument #1 ($link_identifier) must be of type resource, null given in %a

0 commit comments

Comments
 (0)