Skip to content

Commit faabc3f

Browse files
refactor(ext/pgsql/tests): delete table in --CLEAN--
1 parent 7b507cd commit faabc3f

20 files changed

+134
-35
lines changed

ext/pgsql/tests/06copy_2.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ pg_put_line($db, "\\.\n");
2121
pg_end_copy($db);
2222

2323
var_dump(pg_fetch_all_columns(pg_query($db, 'SELECT * FROM test_copy ORDER BY 1')));
24+
?>
25+
--CLEAN--
26+
<?php
27+
include('inc/config.inc');
28+
$db = pg_connect($conn_str);
2429

2530
pg_query($db, 'DROP TABLE test_copy');
26-
2731
?>
2832
--EXPECT--
2933
array(2) {

ext/pgsql/tests/80_bug24499.phpt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ if (!$dbh) {
1616
die ("Could not connect to the server");
1717
}
1818

19-
@pg_query($dbh, "DROP SEQUENCE id_id_seq");
20-
@pg_query($dbh, "DROP TABLE id");
2119
pg_query($dbh, "CREATE TABLE id (id SERIAL, t INT)");
2220

2321
for ($i=0; $i<4; $i++) {
@@ -48,6 +46,13 @@ pg_close($dbh);
4846

4947
echo "Done\n";
5048

49+
?>
50+
--CLEAN--
51+
<?php
52+
require_once('inc/config.inc');
53+
$dbh = pg_connect($conn_str);
54+
55+
pg_query($dbh, "DROP TABLE id CASCADE");
5156
?>
5257
--EXPECTF--
5358
Array

ext/pgsql/tests/80_bug27597.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ if (!$dbh) {
1616
die ("Could not connect to the server");
1717
}
1818

19-
@pg_query($dbh, "DROP TABLE id");
2019
pg_query($dbh, "CREATE TABLE id (id INT)");
2120

2221
for ($i=0; $i<4; $i++) {
@@ -40,6 +39,13 @@ while($row = xi_fetch_array($res)) {
4039

4140
pg_close($dbh);
4241

42+
?>
43+
--CLEAN--
44+
<?php
45+
require_once('inc/config.inc');
46+
$dbh = pg_connect($conn_str);
47+
48+
pg_query($dbh, "DROP TABLE id");
4349
?>
4450
--EXPECT--
4551
Array

ext/pgsql/tests/80_bug39971.phpt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ require_once('inc/skipif.inc');
1111

1212
require_once('inc/config.inc');
1313

14-
$dbh = @pg_connect($conn_str);
15-
if (!$dbh) {
16-
die ("Could not connect to the server");
17-
}
14+
$dbh = pg_connect($conn_str);
1815

1916
pg_query($dbh, "CREATE TABLE php_test (id SERIAL, tm timestamp NOT NULL)");
2017

@@ -24,9 +21,15 @@ pg_insert($dbh, 'php_test', $values);
2421
$ids = array('id' => 1);
2522
pg_update($dbh, 'php_test', $values, $ids);
2623

27-
pg_query($dbh, "DROP TABLE php_test");
2824
pg_close($dbh);
2925
?>
3026
===DONE===
27+
--CLEAN--
28+
<?php
29+
require_once('inc/config.inc');
30+
$dbh = pg_connect($conn_str);
31+
32+
pg_query($dbh, "DROP TABLE php_test");
33+
?>
3134
--EXPECT--
3235
===DONE===

ext/pgsql/tests/80_bug42783.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ pg_insert($dbh, 'php_test', array());
2222

2323
var_dump(pg_fetch_assoc(pg_query($dbh, "SELECT * FROM php_test")));
2424

25-
pg_query($dbh, "DROP TABLE php_test");
2625
pg_close($dbh);
2726
?>
27+
--CLEAN--
28+
<?php
29+
require_once('inc/config.inc');
30+
$dbh = pg_connect($conn_str);
31+
32+
pg_query($dbh, "DROP TABLE php_test");
33+
?>
2834
--EXPECTF--
2935
array(2) {
3036
["id"]=>

ext/pgsql/tests/bug37100.phpt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ include 'inc/config.inc';
1515
$db = pg_connect($conn_str);
1616
@pg_query("SET bytea_output = 'escape'");
1717

18-
@pg_query('DROP TABLE test_bug');
19-
2018
pg_query('CREATE TABLE test_bug (binfield byteA) ;');
2119
pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
2220

@@ -35,12 +33,13 @@ var_dump(strlen($res));
3533
var_dump(bin2hex($res));
3634

3735
pg_close($db);
38-
36+
?>
37+
--CLEAN--
38+
<?php
39+
require_once('inc/config.inc');
3940
$db = pg_connect($conn_str);
40-
pg_query('DROP TABLE test_bug');
41-
pg_close($db);
42-
4341

42+
pg_query('DROP TABLE test_bug');
4443
?>
4544
--EXPECT--
4645
string(24) "\001\003\252\000\010\022"

ext/pgsql/tests/bug37100_9.phpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ include 'inc/config.inc';
1414

1515
$db = pg_connect($conn_str);
1616

17-
@pg_query($db, 'DROP TABLE test_bug');
18-
1917
pg_query($db, 'CREATE TABLE test_bug (binfield byteA) ;');
2018
pg_query($db, "INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
2119

@@ -36,10 +34,16 @@ var_dump(bin2hex($res));
3634
pg_close($db);
3735

3836
$db = pg_connect($conn_str);
39-
pg_query($db, 'DROP TABLE test_bug');
4037
pg_close($db);
4138

4239

40+
?>
41+
--CLEAN--
42+
<?php
43+
require_once('inc/config.inc');
44+
$db = pg_connect($conn_str);
45+
46+
pg_query($db, 'DROP TABLE test_bug');
4347
?>
4448
--EXPECT--
4549
string(14) "\x0103aa000812"

ext/pgsql/tests/bug47199.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require_once('inc/config.inc');
1313

1414
$dbh = pg_connect($conn_str);
1515
$tbl_name = 'test_47199';
16-
@pg_query($dbh, "DROP TABLE $tbl_name");
1716
pg_query($dbh, "CREATE TABLE $tbl_name (null_field INT, not_null_field INT NOT NULL)");
1817

1918
pg_insert($dbh, $tbl_name, array('null_field' => null, 'not_null_field' => 1));
@@ -31,11 +30,18 @@ echo $query, "\n";
3130

3231
var_dump(pg_fetch_all(pg_query($dbh, 'SELECT * FROM '. $tbl_name)));
3332

34-
@pg_query($dbh, "DROP TABLE $tbl_name");
3533
pg_close($dbh);
3634

3735
echo PHP_EOL."Done".PHP_EOL;
3836

37+
?>
38+
--CLEAN--
39+
<?php
40+
require_once('inc/config.inc');
41+
$dbh = pg_connect($conn_str);
42+
43+
$tbl_name = 'test_47199';
44+
pg_query($dbh, "DROP TABLE $tbl_name");
3945
?>
4046
--EXPECT--
4147
array(2) {

ext/pgsql/tests/bug68638.phpt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ while ($row = pg_fetch_assoc($rs)) {
3030
var_dump($row);
3131
}
3232

33-
pg_query($conn, "DROP TABLE $table");
3433

34+
?>
35+
--CLEAN--
36+
<?php
37+
require_once('inc/config.inc');
38+
$conn = pg_connect($conn_str);
39+
$table='test_68638';
40+
41+
pg_query($conn, "DROP TABLE $table");
3542
?>
3643
--EXPECT--
3744
string(52) "UPDATE "test_68638" SET "value"=E'inf' WHERE "id"=1;"

ext/pgsql/tests/bug71062.phpt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,16 @@ pg_convert($db, $table, ['test_field' => $date_string_modified_iso8601]);
3030

3131
print "done\n";
3232

33-
pg_query($db, "DROP TABLE $table");
34-
3533
?>
3634
==OK==
35+
--CLEAN--
36+
<?php
37+
require_once('inc/config.inc');
38+
$db = @pg_connect($conn_str);
39+
$table = "public.test_table_bug71062_bug71062";
40+
41+
pg_query($db, "DROP TABLE $table");
42+
?>
3743
--EXPECT--
3844
trying format Y-m-d\TH:i:sO
3945
trying format Y-m-d H:i:sO

ext/pgsql/tests/bug71998.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ while (false != ($row = pg_fetch_row($r))) {
8080
}
8181
echo $errors, " errors caught\n";
8282

83-
pg_query($db, "DROP TABLE tmp_statistics");
8483
pg_close($db);
8584

85+
?>
86+
--CLEAN--
87+
<?php
88+
require_once('inc/config.inc');
89+
$db = @pg_connect($conn_str);
90+
91+
pg_query($db, "DROP TABLE tmp_statistics");
8692
?>
8793
--EXPECT--
8894
pg_insert(): Field "remote_addr" must be a valid IPv4 or IPv6 address string, "256.257.258.259" given

ext/pgsql/tests/bug72028.phpt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include('inc/config.inc');
1212

1313
$conn = pg_connect($conn_str);
1414

15-
$table = "bug72028_" . md5(uniqid(time()));
15+
$table = "bug72028";
1616

1717
pg_query($conn, "CREATE TABLE $table (value TEXT, details TEXT);");
1818

@@ -33,9 +33,14 @@ $r = pg_query($conn, "SELECT * FROM $table");
3333
while (false !== ($i = pg_fetch_assoc($r))) {
3434
var_dump($i);
3535
}
36+
?>
37+
--CLEAN--
38+
<?php
39+
require_once('inc/config.inc');
40+
$table = "bug72028";;
41+
$conn = pg_connect($conn_str);
3642

3743
pg_query($conn, "DROP TABLE $table");
38-
3944
?>
4045
--EXPECT--
4146
array(2) {

ext/pgsql/tests/bug77047.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ include 'inc/config.inc';
1414

1515
$db = pg_connect($conn_str);
1616

17-
pg_query($db, "DROP TABLE IF EXISTS bug77047");
1817
pg_query($db, "CREATE TABLE bug77047 (
1918
t TIME WITHOUT TIME ZONE
2019
)");
@@ -39,6 +38,13 @@ while (false !== ($row = pg_fetch_row($res))) {
3938
var_dump(array_pop($row));
4039
}
4140

41+
?>
42+
--CLEAN--
43+
<?php
44+
require_once('inc/config.inc');
45+
$db = pg_connect($conn_str);
46+
47+
pg_query($db, "DROP TABLE IF EXISTS bug77047");
4248
?>
4349
--EXPECTF--
4450
pg_insert(): Field "t" must be of type string|null, time given

ext/pgsql/tests/gh10672.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ declare(strict_types=1);
1313
include "inc/config.inc";
1414

1515
$db = pg_connect($conn_str);
16-
pg_query($db, "DROP TABLE IF EXISTS gh10672");
1716
pg_query($db, "CREATE TABLE gh10672 (bar text);");
1817

1918
// Begin a transaction
@@ -35,5 +34,12 @@ if ($oid === false) {
3534

3635
echo 'The large object has been opened successfully.', PHP_EOL;
3736
?>
37+
--CLEAN--
38+
<?php
39+
require_once('inc/config.inc');
40+
$dbh = pg_connect($conn_str);
41+
42+
pg_query($dbh, "DROP TABLE IF EXISTS gh10672");
43+
?>
3844
--EXPECT--
3945
The large object has been opened successfully.

ext/pgsql/tests/gh8253.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,18 @@ $a = ["bar" => "testing"];
1515
fee($a["bar"]);
1616

1717
$db = pg_connect($conn_str);
18-
pg_query($db, "DROP TABLE IF EXISTS gh8253");
1918
pg_query($db, "CREATE TABLE gh8253 (bar text);");
2019
pg_insert($db, "gh8253", $a);
2120
$res = pg_query($db, "SELECT * FROM gh8253");
2221
var_dump(pg_fetch_all($res));
2322
?>
23+
--CLEAN--
24+
<?php
25+
require_once('inc/config.inc');
26+
$db = pg_connect($conn_str);
27+
28+
pg_query($db, "DROP TABLE IF EXISTS gh8253");
29+
?>
2430
--EXPECT--
2531
array(1) {
2632
[0]=>

ext/pgsql/tests/pg_delete_001.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ var_dump(pg_fetch_all(pg_query($conn, 'SELECT * FROM phptests.foo')));
4141
pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2));
4242
var_dump(pg_delete($conn, 'bar', array('id' => 1, 'id2' => 2), PGSQL_DML_STRING));
4343

44+
?>
45+
--CLEAN--
46+
<?php
47+
require_once('inc/config.inc');
48+
$conn = pg_connect($conn_str);
49+
4450
pg_query($conn, 'DROP TABLE foo');
4551
pg_query($conn, 'DROP TABLE phptests.foo');
4652
pg_query($conn, 'DROP SCHEMA phptests');
47-
4853
?>
4954
--EXPECTF--
5055
string(43) "DELETE FROM "foo" WHERE "id"=1 AND "id2"=2;"

ext/pgsql/tests/pg_insert_001.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ var_dump(pg_insert($conn, 'phptests.foo', array('id' => 1, 'id2' => 2), PGSQL_DM
2323

2424
var_dump(pg_select($conn, 'phptests.foo', array('id' => 1)));
2525

26+
?>
27+
--CLEAN--
28+
<?php
29+
require_once('inc/config.inc');
30+
$conn = pg_connect($conn_str);
31+
2632
pg_query($conn, 'DROP TABLE phptests.foo');
2733
pg_query($conn, 'DROP SCHEMA phptests');
28-
2934
?>
3035
--EXPECTF--
3136
Warning: pg_insert(): Table 'foo' doesn't exists in %s on line %d

ext/pgsql/tests/pg_meta_data_001.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ var_dump(pg_meta_data($conn, 'foo'));
2222
var_dump(pg_meta_data($conn, 'phptests.foo'));
2323
var_dump(pg_meta_data($conn, 'phptests.foo', TRUE));
2424

25+
?>
26+
--CLEAN--
27+
<?php
28+
require_once('inc/config.inc');
29+
$conn = pg_connect($conn_str);
2530

2631
pg_query($conn, 'DROP TABLE foo');
2732
pg_query($conn, 'DROP TABLE phptests.foo');
2833
pg_query($conn, 'DROP SCHEMA phptests');
29-
3034
?>
3135
--EXPECT--
3236
array(2) {

ext/pgsql/tests/pg_select_001.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ var_dump(pg_select($conn, 'phptests.bar', array()));
4242
/* No array */
4343
var_dump(pg_select($conn, 'phptests.bar'));
4444

45+
?>
46+
--CLEAN--
47+
<?php
48+
require_once('inc/config.inc');
49+
$conn = pg_connect($conn_str);
50+
4551
pg_query($conn, 'DROP TABLE phptests.foo');
4652
pg_query($conn, 'DROP TABLE phptests.bar');
4753
pg_query($conn, 'DROP SCHEMA phptests');
48-
4954
?>
5055
--EXPECTF--
5156
Warning: pg_select(): Table 'foo' doesn't exists in %s on line %d

0 commit comments

Comments
 (0)