From 920346ee760ed7f8276f00f652fb0b2e7bf2d1ec Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 14 Apr 2016 09:22:25 -0500 Subject: [PATCH 1/2] 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. --- src/Adapter/Driver/Pgsql/Connection.php | 4 +++- test/Adapter/Driver/Pgsql/ConnectionTest.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Adapter/Driver/Pgsql/Connection.php b/src/Adapter/Driver/Pgsql/Connection.php index 82e6776c2c..77630bc022 100644 --- a/src/Adapter/Driver/Pgsql/Connection.php +++ b/src/Adapter/Driver/Pgsql/Connection.php @@ -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); diff --git a/test/Adapter/Driver/Pgsql/ConnectionTest.php b/test/Adapter/Driver/Pgsql/ConnectionTest.php index 5b96345fbd..0f948cf41a 100644 --- a/test/Adapter/Driver/Pgsql/ConnectionTest.php +++ b/test/Adapter/Driver/Pgsql/ConnectionTest.php @@ -114,6 +114,9 @@ public function testSetConnectionType() $this->assertEquals($type, self::readAttribute($this->connection, 'type')); } + /** + * @runInSeparateProcess + */ public function testSetCharset() { if (! extension_loaded('pgsql')) { @@ -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')) { From 59c12938afbfb6bf7d09e8a404e32550deab25fb Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 14 Apr 2016 09:26:19 -0500 Subject: [PATCH 2/2] Added CHANGELOG for #106 --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67237b9dcd..62c5149329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 2.8.1 - TBD +## 2.8.1 - 2016-04-14 ### Added @@ -20,6 +20,8 @@ All notable changes to this project will be documented in this file, in reverse - [#100](https://github.com/zendframework/zend-db/pull/100) fixes the JOIN behavior to re-allow selecting an empty column set from the joined table. +- [#106](https://github.com/zendframework/zend-db/pull/106) fixes an issue in + the test suite when ext/pgsql is enabled, but no databases are avaiable. ## 2.8.0 - 2016-04-12