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

Commit

Permalink
Allow tests to run when no databases are setup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
weierophinney committed Apr 14, 2016
1 parent 8994b60 commit 920346e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Adapter/Driver/Pgsql/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public function connect()
$connection = $this->getConnectionString();
set_error_handler(function ($number, $string) {
throw new Exception\RuntimeException(
__METHOD__ . ': Unable to connect to database', null, new Exception\ErrorException($string, $number)
__METHOD__ . ': Unable to connect to database',
null,
new Exception\ErrorException($string, $number)
);
});
$this->resource = pg_connect($connection);
Expand Down
12 changes: 11 additions & 1 deletion test/Adapter/Driver/Pgsql/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public function testSetConnectionType()
$this->assertEquals($type, self::readAttribute($this->connection, 'type'));
}

/**
* @runInSeparateProcess
*/
public function testSetCharset()
{
if (! extension_loaded('pgsql')) {
Expand All @@ -130,11 +133,18 @@ public function testSetCharset()
'charset' => 'SQL_ASCII',
]);

$this->connection->connect();
try {
$this->connection->connect();
} catch (AdapterException\RuntimeException $e) {
$this->markTestSkipped('Skipping pgsql charset test due to inability to connecto to database');
}

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

/**
* @runInSeparateProcess
*/
public function testSetInvalidCharset()
{
if (! extension_loaded('pgsql')) {
Expand Down

0 comments on commit 920346e

Please sign in to comment.