From e4757ecc801695b099d7e72fd2bd4ce7d9d97825 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 4 May 2019 10:46:08 +0200 Subject: [PATCH] Re-add common PDO tests to Firebird test suite These have been inadvertently dropped when changing the test suite to not require ext/interbase anymore, so we add them back. We also change the required environment variable names to match the usual PDO names. Particularly, we replace `PDO_FIREBIRD_TEST_HOSTNAME` and `_DATABASE` with the more flexible `PDO_FIREBIRD_TEST_DSN`. --- ext/pdo_firebird/tests/common.phpt | 27 +++++++++++++++++++++++++++ ext/pdo_firebird/tests/skipif.inc | 4 ++-- ext/pdo_firebird/tests/testdb.inc | 24 ++++++++---------------- 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 ext/pdo_firebird/tests/common.phpt diff --git a/ext/pdo_firebird/tests/common.phpt b/ext/pdo_firebird/tests/common.phpt new file mode 100644 index 0000000000..00d4b239ab --- /dev/null +++ b/ext/pdo_firebird/tests/common.phpt @@ -0,0 +1,27 @@ +--TEST-- +FIREBIRD +--SKIPIF-- + +--REDIRECTTEST-- +# magic auto-configuration + +$config = array( + 'TESTS' => 'ext/pdo/tests' +); + + +if (false !== getenv('PDO_FIREBIRD_TEST_DSN')) { + # user set them from their shell + $config['ENV']['PDOTEST_DSN'] = getenv('PDO_FIREBIRD_TEST_DSN'); + $config['ENV']['PDOTEST_USER'] = getenv('PDO_FIREBIRD_TEST_USER'); + $config['ENV']['PDOTEST_PASS'] = getenv('PDO_FIREBIRD_TEST_PASS'); + if (false !== getenv('PDO_FIREBIRD_TEST_ATTR')) { + $config['ENV']['PDOTEST_ATTR'] = getenv('PDO_FIREBIRD_TEST_ATTR'); + } +} else { + $config['ENV']['PDOTEST_DSN'] = 'firebird:dbname=/opt/firebird/test.gdb'; + $config['ENV']['PDOTEST_USER'] = 'SYSDBA'; + $config['ENV']['PDOTEST_PASS'] = 'password'; +} +return $config; diff --git a/ext/pdo_firebird/tests/skipif.inc b/ext/pdo_firebird/tests/skipif.inc index a066d21a71..1e4611ac63 100644 --- a/ext/pdo_firebird/tests/skipif.inc +++ b/ext/pdo_firebird/tests/skipif.inc @@ -4,9 +4,9 @@ if(!extension_loaded('pdo_firebird')) { die('skip: pdo_firebird not available'); } -elseif(!getenv('PDO_FIREBIRD_TEST_DATABASE')) +elseif(!getenv('PDO_FIREBIRD_TEST_DSN')) { - die('skip: PDO_FIREBIRD_TEST_DATABASE must be set'); + die('skip: PDO_FIREBIRD_TEST_DSN must be set'); } ?> \ No newline at end of file diff --git a/ext/pdo_firebird/tests/testdb.inc b/ext/pdo_firebird/tests/testdb.inc index c18df082fe..d345d090bb 100644 --- a/ext/pdo_firebird/tests/testdb.inc +++ b/ext/pdo_firebird/tests/testdb.inc @@ -6,24 +6,16 @@ // Password: phpfi // Database: // -// A path to a database must be specified by using PDO_FIREBIRD_TEST_DATABASE +// A DSN must be specified by using PDO_FIREBIRD_TEST_DSN -define('PDO_FIREBIRD_TEST_USERNAME', getenv('PDO_FIREBIRD_TEST_USERNAME') ?: 'SYSDBA'); -define('PDO_FIREBIRD_TEST_PASSWORD', getenv('PDO_FIREBIRD_TEST_PASSWORD') ?: 'phpfi'); -define('PDO_FIREBIRD_TEST_HOSTNAME', getenv('PDO_FIREBIRD_TEST_HOSTNAME') ?: 'localhost'); -define('PDO_FIREBIRD_TEST_DATABASE', getenv('PDO_FIREBIRD_TEST_DATABASE') ?: ''); +define('PDO_FIREBIRD_TEST_USER', getenv('PDO_FIREBIRD_TEST_USER') ?: 'SYSDBA'); +define('PDO_FIREBIRD_TEST_PASS', getenv('PDO_FIREBIRD_TEST_PASS') ?: 'phpfi'); +define('PDO_FIREBIRD_TEST_DSN', getenv('PDO_FIREBIRD_TEST_DSN') ?: ''); -if(!PDO_FIREBIRD_TEST_DATABASE) +if(!PDO_FIREBIRD_TEST_DSN) { - die('Error: PDO_FIREBIRD_TEST_DATABASE must be set'); + die('Error: PDO_FIREBIRD_TEST_DSN must be set'); } -if(PDO_FIREBIRD_TEST_HOSTNAME) -{ - $dbh = new PDO('firebird:dbname=' . PDO_FIREBIRD_TEST_HOSTNAME . ':' . PDO_FIREBIRD_TEST_DATABASE, PDO_FIREBIRD_TEST_USERNAME, PDO_FIREBIRD_TEST_PASSWORD) or die; -} -else -{ - $dbh = new PDO('firebird:dbname=' . PDO_FIREBIRD_TEST_DATABASE, PDO_FIREBIRD_TEST_USERNAME, PDO_FIREBIRD_TEST_PASSWORD) or die; -} -?> \ No newline at end of file +$dbh = new PDO(PDO_FIREBIRD_TEST_DSN, PDO_FIREBIRD_TEST_USER, PDO_FIREBIRD_TEST_PASS) or die; +?> -- 2.40.0