Skip to content

Commit 4f84b15

Browse files
ext/pdo_pgsql: Improve tests cleanup (#11855)
1 parent 8293474 commit 4f84b15

13 files changed

+80
-21
lines changed

ext/pdo_pgsql/tests/bug46274.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ try {
2121
} catch (Exception $e) {
2222
}
2323

24-
$db->query('DROP TABLE IF EXISTS test_one_blob_46274_1 CASCADE');
2524
$db->query('CREATE TABLE test_one_blob_46274_1 (id SERIAL NOT NULL, blob1 BYTEA)');
2625

2726
$stmt = $db->prepare("INSERT INTO test_one_blob_46274_1 (blob1) VALUES (:foo)");
@@ -62,9 +61,12 @@ var_dump($res->fetch());
6261

6362
// NULL
6463
var_dump($res->fetch());
65-
66-
$db->query('DROP TABLE test_one_blob_46274_1');
67-
64+
?>
65+
--CLEAN--
66+
<?php
67+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
68+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
69+
$db->query('DROP TABLE IF EXISTS test_one_blob_46274_1');
6870
?>
6971
--EXPECT--
7072
array(2) {

ext/pdo_pgsql/tests/bug46274_2.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ try {
2121
} catch (Exception $e) {
2222
}
2323

24-
$db->query('DROP TABLE IF EXISTS test_one_blob_46274_2 CASCADE');
2524
$db->query('CREATE TABLE test_one_blob_46274_2 (id SERIAL NOT NULL, blob1 BYTEA)');
2625

2726
$stmt = $db->prepare("INSERT INTO test_one_blob_46274_2 (blob1) VALUES (:foo)");
@@ -65,9 +64,12 @@ var_dump(fread($x['blob1'], 10));
6564

6665
// NULL
6766
var_dump($res->fetch());
68-
69-
$db->query('DROP TABLE test_one_blob_46274_2');
70-
67+
?>
68+
--CLEAN--
69+
<?php
70+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
71+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
72+
$db->query('DROP TABLE IF EXISTS test_one_blob_46274_2');
7173
?>
7274
--EXPECTF--
7375
array(2) {

ext/pdo_pgsql/tests/bug66584.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ function run($pdo, $data)
5656
var_dump($stmt->fetchColumn());
5757
}
5858

59+
?>
60+
--CLEAN--
61+
<?php
62+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
63+
$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
64+
$pdo->query("DROP TABLE IF EXISTS b66584");
5965
?>
6066
--EXPECTF--
6167
int(3)

ext/pdo_pgsql/tests/bug67462.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ try {
2929
var_dump($pdo->beginTransaction());
3030
}
3131

32+
?>
33+
--CLEAN--
34+
<?php
35+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
36+
$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
37+
$pdo->query("DROP TABLE IF EXISTS b67462");
3238
?>
3339
--EXPECT--
3440
bool(true)

ext/pdo_pgsql/tests/bug70861.phpt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ try {
2121
} catch (Exception $e) {
2222
}
2323

24-
$db->query('DROP TABLE IF EXISTS test_blob_crash_70861 CASCADE');
2524
$db->query('CREATE TABLE test_blob_crash_70861 (id SERIAL NOT NULL, blob1 BYTEA)');
2625

2726
class HelloWrapper {
@@ -41,8 +40,16 @@ $stmt->execute();
4140

4241
fclose($f);
4342

43+
$db->exec('DROP TABLE test_blob_crash');
44+
4445
?>
4546
+++DONE+++
47+
--CLEAN--
48+
<?php
49+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
50+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
51+
$db->query('DROP TABLE IF EXISTS test_blob_crash_70861 CASCADE');
52+
?>
4653
--EXPECTF--
4754
%a
4855
+++DONE+++

ext/pdo_pgsql/tests/bug72633.phpt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1818

1919
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
2020

21-
$db->query('DROP TABLE IF EXISTS test_last_id_72633 CASCADE');
2221
$db->query('CREATE TABLE test_last_id_72633 (id SERIAL NOT NULL, field1 VARCHAR(10))');
2322

2423
$stmt = $db->prepare("INSERT INTO test_last_id_72633 (field1) VALUES ('test')");
@@ -34,8 +33,12 @@ var_dump($db->lastInsertId());
3433
*/
3534
var_dump($db->lastInsertId('test_last_id_72633_id_seq'));
3635

37-
$db->query('DROP TABLE test_last_id_72633');
38-
36+
?>
37+
--CLEAN--
38+
<?php
39+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
40+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
41+
$db->query('DROP TABLE IF EXISTS test_last_id_72633');
3942
?>
4043
--EXPECTREGEX--
4144
string\([0-9]*\)\ \"[0-9]*\"

ext/pdo_pgsql/tests/bug75402.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1717
$resp = new \stdClass();
1818
$resp->entries = [];
1919

20-
$db->query('DROP TABLE IF EXISTS bug75402 CASCADE');
2120
$db->query('CREATE TABLE bug75402 (
2221
"id" character varying(64) NOT NULL,
2322
"group_id" character varying(64) NOT NULL,
@@ -84,6 +83,12 @@ if ($db) {
8483

8584
var_dump($resp);
8685
?>
86+
--CLEAN--
87+
<?php
88+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
89+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
90+
$db->exec('DROP TABLE IF EXISTS bug75402');
91+
?>
8792
--EXPECT--
8893
object(stdClass)#2 (1) {
8994
["entries"]=>

ext/pdo_pgsql/tests/bug_33876.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1616
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
1717

1818
$db->exec("SET LC_MESSAGES='C'");
19-
$db->query('DROP TABLE IF EXISTS b33876 CASCADE');
2019
$db->exec('CREATE TABLE b33876 (foo varchar(5) NOT NULL, bar bool NOT NULL)');
2120
$db->exec("INSERT INTO b33876 VALUES('false','f')");
2221
$db->exec("INSERT INTO b33876 VALUES('true', 't')");
@@ -95,6 +94,12 @@ function normalizeErrorInfo(array $err): array {
9594
return $err;
9695
}
9796

97+
?>
98+
--CLEAN--
99+
<?php
100+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
101+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
102+
$db->query('DROP TABLE IF EXISTS b33876 CASCADE');
98103
?>
99104
--EXPECTF--
100105
Array

ext/pdo_pgsql/tests/bug_49985.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
1515
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1616
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1717

18-
$db->query('DROP TABLE IF EXISTS b49985 CASCADE');
1918
$db->exec("CREATE TABLE b49985 (a int PRIMARY KEY)");
2019

2120
for ($i = 0; $i < 3; $i++) {
@@ -30,6 +29,12 @@ for ($i = 0; $i < 3; $i++) {
3029
}
3130
}
3231

32+
?>
33+
--CLEAN--
34+
<?php
35+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
36+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
37+
$db->query('DROP TABLE IF EXISTS b49985 CASCADE');
3338
?>
3439
--EXPECTF--
3540
bool(true)

ext/pdo_pgsql/tests/copy_from.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1616
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1717
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
1818

19-
$db->query('DROP TABLE IF EXISTS test_copy_from CASCADE');
2019
$db->exec('CREATE TABLE test_copy_from (a integer not null primary key, b text, c integer)');
2120

2221
echo "Preparing test file and array for CopyFrom tests\n";
@@ -127,6 +126,12 @@ foreach (array($filename, $filenameWithDifferentNullValues, $filenameWithDiffere
127126
@unlink($f);
128127
}
129128
?>
129+
--CLEAN--
130+
<?php
131+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
132+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
133+
$db->query('DROP TABLE IF EXISTS test_copy_from CASCADE');
134+
?>
130135
--EXPECTF--
131136
Preparing test file and array for CopyFrom tests
132137
Testing pgsqlCopyFromArray() with default parameters

ext/pdo_pgsql/tests/copy_to.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1616
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1717
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
1818

19-
$db->query('DROP TABLE IF EXISTS test_copy_to CASCADE');
2019
$db->exec('CREATE TABLE test_copy_to (a integer not null primary key, b text, c integer)');
2120

2221
$db->beginTransaction();
@@ -80,6 +79,12 @@ if(isset($filename)) {
8079
@unlink($filename);
8180
}
8281
?>
82+
--CLEAN--
83+
<?php
84+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
85+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
86+
$db->exec('DROP TABLE test_copy_to');
87+
?>
8388
--EXPECTF--
8489
Preparing test table for CopyTo tests
8590
Testing pgsqlCopyToArray() with default parameters

ext/pdo_pgsql/tests/is_in_transaction.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1616
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1717
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
1818

19-
$db->query('DROP TABLE IF EXISTS test_is_in_transaction CASCADE');
2019
$db->exec('CREATE TABLE test_is_in_transaction (a integer not null primary key, b text)');
2120

2221
$db->beginTransaction();
@@ -56,7 +55,12 @@ var_dump($db->inTransaction());
5655
echo "Exception! at line ", $e->getLine(), "\n";
5756
var_dump($e->getMessage());
5857
}
59-
58+
?>
59+
--CLEAN--
60+
<?php
61+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
62+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
63+
$db->exec('DROP TABLE test_is_in_transaction');
6064
?>
6165
--EXPECT--
6266
Test PDO::PGSQL_TRANSACTION_INTRANS

ext/pdo_pgsql/tests/large_objects.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
1616
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1717
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
1818

19-
$db->query('DROP TABLE IF EXISTS test_large_objects CASCADE');
2019
$db->exec('CREATE TABLE test_large_objects (blobid integer not null primary key, bloboid OID)');
2120

2221
$db->beginTransaction();
@@ -78,7 +77,12 @@ echo "Fetched!\n";
7877
/* Now to remove the large object from the database, so it doesn't
7978
* linger and clutter up the storage */
8079
$db->pgsqlLOBUnlink($oid);
81-
80+
?>
81+
--CLEAN--
82+
<?php
83+
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
84+
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
85+
$db->exec('DROP TABLE test_large_objects');
8286
?>
8387
--EXPECT--
8488
Fetching:

0 commit comments

Comments
 (0)