Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 920346e

Browse files
committed
Allow tests to run when no databases are setup
Prior to 2.7.1, tests ran when: - ext/pgsql was enabled - but no databases were setup for pgsql With the changes introduced to resolve #70, however, the above combination causes cascading failures across the test suite. Marking the two tests introduced to run in separate processes largely solves the issues. Updating the first test to test for a connection exception prevents a test failure when no database is setup.
1 parent 8994b60 commit 920346e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Adapter/Driver/Pgsql/Connection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ public function connect()
123123
$connection = $this->getConnectionString();
124124
set_error_handler(function ($number, $string) {
125125
throw new Exception\RuntimeException(
126-
__METHOD__ . ': Unable to connect to database', null, new Exception\ErrorException($string, $number)
126+
__METHOD__ . ': Unable to connect to database',
127+
null,
128+
new Exception\ErrorException($string, $number)
127129
);
128130
});
129131
$this->resource = pg_connect($connection);

test/Adapter/Driver/Pgsql/ConnectionTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public function testSetConnectionType()
114114
$this->assertEquals($type, self::readAttribute($this->connection, 'type'));
115115
}
116116

117+
/**
118+
* @runInSeparateProcess
119+
*/
117120
public function testSetCharset()
118121
{
119122
if (! extension_loaded('pgsql')) {
@@ -130,11 +133,18 @@ public function testSetCharset()
130133
'charset' => 'SQL_ASCII',
131134
]);
132135

133-
$this->connection->connect();
136+
try {
137+
$this->connection->connect();
138+
} catch (AdapterException\RuntimeException $e) {
139+
$this->markTestSkipped('Skipping pgsql charset test due to inability to connecto to database');
140+
}
134141

135142
$this->assertEquals('SQL_ASCII', pg_client_encoding($this->connection->getResource()));
136143
}
137144

145+
/**
146+
* @runInSeparateProcess
147+
*/
138148
public function testSetInvalidCharset()
139149
{
140150
if (! extension_loaded('pgsql')) {

0 commit comments

Comments
 (0)