Skip to content

Improve ext/pdo_pgsql tests cleanup #11855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ext/pdo_pgsql/tests/bug46274.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ try {
} catch (Exception $e) {
}

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

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

// NULL
var_dump($res->fetch());

$db->query('DROP TABLE test_one_blob_46274_1');

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->query('DROP TABLE IF EXISTS test_one_blob_46274_1');
?>
--EXPECT--
array(2) {
Expand Down
10 changes: 6 additions & 4 deletions ext/pdo_pgsql/tests/bug46274_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ try {
} catch (Exception $e) {
}

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

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

// NULL
var_dump($res->fetch());

$db->query('DROP TABLE test_one_blob_46274_2');

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->query('DROP TABLE IF EXISTS test_one_blob_46274_2');
?>
--EXPECTF--
array(2) {
Expand Down
6 changes: 6 additions & 0 deletions ext/pdo_pgsql/tests/bug66584.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ function run($pdo, $data)
var_dump($stmt->fetchColumn());
}

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
$pdo->query("DROP TABLE IF EXISTS b66584");
?>
--EXPECTF--
int(3)
Expand Down
6 changes: 6 additions & 0 deletions ext/pdo_pgsql/tests/bug67462.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ try {
var_dump($pdo->beginTransaction());
}

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
$pdo->query("DROP TABLE IF EXISTS b67462");
?>
--EXPECT--
bool(true)
Expand Down
9 changes: 8 additions & 1 deletion ext/pdo_pgsql/tests/bug70861.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ try {
} catch (Exception $e) {
}

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

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

fclose($f);

$db->exec('DROP TABLE test_blob_crash');

?>
+++DONE+++
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->query('DROP TABLE IF EXISTS test_blob_crash_70861 CASCADE');
?>
--EXPECTF--
%a
+++DONE+++
9 changes: 6 additions & 3 deletions ext/pdo_pgsql/tests/bug72633.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');

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

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

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

$db->query('DROP TABLE test_last_id_72633');

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->query('DROP TABLE IF EXISTS test_last_id_72633');
?>
--EXPECTREGEX--
string\([0-9]*\)\ \"[0-9]*\"
Expand Down
7 changes: 6 additions & 1 deletion ext/pdo_pgsql/tests/bug75402.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$resp = new \stdClass();
$resp->entries = [];

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

var_dump($resp);
?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->exec('DROP TABLE IF EXISTS bug75402');
?>
--EXPECT--
object(stdClass)#2 (1) {
["entries"]=>
Expand Down
7 changes: 6 additions & 1 deletion ext/pdo_pgsql/tests/bug_33876.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);

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

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->query('DROP TABLE IF EXISTS b33876 CASCADE');
?>
--EXPECTF--
Array
Expand Down
7 changes: 6 additions & 1 deletion ext/pdo_pgsql/tests/bug_49985.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

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

for ($i = 0; $i < 3; $i++) {
Expand All @@ -30,6 +29,12 @@ for ($i = 0; $i < 3; $i++) {
}
}

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->query('DROP TABLE IF EXISTS b49985 CASCADE');
?>
--EXPECTF--
bool(true)
Expand Down
7 changes: 6 additions & 1 deletion ext/pdo_pgsql/tests/copy_from.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);

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

echo "Preparing test file and array for CopyFrom tests\n";
Expand Down Expand Up @@ -127,6 +126,12 @@ foreach (array($filename, $filenameWithDifferentNullValues, $filenameWithDiffere
@unlink($f);
}
?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->query('DROP TABLE IF EXISTS test_copy_from CASCADE');
?>
--EXPECTF--
Preparing test file and array for CopyFrom tests
Testing pgsqlCopyFromArray() with default parameters
Expand Down
7 changes: 6 additions & 1 deletion ext/pdo_pgsql/tests/copy_to.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);

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

$db->beginTransaction();
Expand Down Expand Up @@ -80,6 +79,12 @@ if(isset($filename)) {
@unlink($filename);
}
?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->exec('DROP TABLE test_copy_to');
?>
--EXPECTF--
Preparing test table for CopyTo tests
Testing pgsqlCopyToArray() with default parameters
Expand Down
8 changes: 6 additions & 2 deletions ext/pdo_pgsql/tests/is_in_transaction.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);

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

$db->beginTransaction();
Expand Down Expand Up @@ -56,7 +55,12 @@ var_dump($db->inTransaction());
echo "Exception! at line ", $e->getLine(), "\n";
var_dump($e->getMessage());
}

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->exec('DROP TABLE test_is_in_transaction');
?>
--EXPECT--
Test PDO::PGSQL_TRANSACTION_INTRANS
Expand Down
8 changes: 6 additions & 2 deletions ext/pdo_pgsql/tests/large_objects.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);

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

$db->beginTransaction();
Expand Down Expand Up @@ -78,7 +77,12 @@ echo "Fetched!\n";
/* Now to remove the large object from the database, so it doesn't
* linger and clutter up the storage */
$db->pgsqlLOBUnlink($oid);

?>
--CLEAN--
<?php
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$db->exec('DROP TABLE test_large_objects');
?>
--EXPECT--
Fetching:
Expand Down