From 660209270dd4a8fc127fc0e7550148efb70359a9 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Sun, 1 Jul 2018 12:34:55 -0500 Subject: [PATCH] Fix Transaction; Fix tests; Remove extension repo directories after install on travis --- src/PqHandle.php | 1 + src/Transaction.php | 2 +- test/AbstractLinkTest.php | 4 ++-- test/PgSqlPoolTest.php | 4 +++- test/PoolTest.php | 4 ++-- travis/install-pq.sh | 1 + travis/install-raphf.sh | 1 + 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/PqHandle.php b/src/PqHandle.php index b2e1407..74cc27b 100644 --- a/src/PqHandle.php +++ b/src/PqHandle.php @@ -10,6 +10,7 @@ use Amp\Loop; use Amp\Promise; use Amp\Sql\ConnectionException; use Amp\Sql\FailureException; +use Amp\Sql\QueryError; use Amp\Success; use pq; use function Amp\call; diff --git a/src/Transaction.php b/src/Transaction.php index 3cd704d..1e8e713 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -81,7 +81,7 @@ final class Transaction implements Handle, SqlTransaction */ public function isAlive(): bool { - return $this->handle->isAlive(); + return $this->handle && $this->handle->isAlive(); } /** diff --git a/test/AbstractLinkTest.php b/test/AbstractLinkTest.php index 67510a7..712cd69 100644 --- a/test/AbstractLinkTest.php +++ b/test/AbstractLinkTest.php @@ -103,7 +103,7 @@ abstract class AbstractLinkTest extends TestCase } /** - * @expectedException QueryError + * @expectedException \Amp\Sql\QueryError */ public function testQueryWithEmptyQuery() { @@ -669,7 +669,7 @@ abstract class AbstractLinkTest extends TestCase /** * @depends testListen - * @expectedException QueryError + * @expectedException \Amp\Sql\QueryError * @expectedExceptionMessage Already listening on channel */ public function testListenOnSameChannel() diff --git a/test/PgSqlPoolTest.php b/test/PgSqlPoolTest.php index 4e549e1..ada0903 100644 --- a/test/PgSqlPoolTest.php +++ b/test/PgSqlPoolTest.php @@ -4,6 +4,7 @@ namespace Amp\Postgres\Test; use Amp\Postgres\ConnectionConfig; use Amp\Postgres\Link; +use Amp\Postgres\PgSqlConnection; use Amp\Postgres\Pool; use Amp\Promise; use Amp\Sql\Connector; @@ -32,8 +33,9 @@ class PgSqlPoolTest extends AbstractLinkTest if (!isset($this->handles[$count])) { $this->fail("createConnection called too many times"); } + $handle = $this->handles[$count]; ++$count; - return new Success(); + return new Success(new PgSqlConnection($handle, \pg_socket($handle))); })); $pool = new Pool(new ConnectionConfig('connection string'), \count($this->handles), $connector); diff --git a/test/PoolTest.php b/test/PoolTest.php index bb9bcab..1515809 100644 --- a/test/PoolTest.php +++ b/test/PoolTest.php @@ -4,11 +4,11 @@ namespace Amp\Postgres\Test; use Amp\Delayed; use Amp\Loop; -use Amp\Postgres\Pool; use Amp\Postgres\ConnectionConfig; +use Amp\Postgres\Pool; use PHPUnit\Framework\TestCase; -class DefaultPoolTest extends TestCase +class PoolTest extends TestCase { /** * @expectedException \Error diff --git a/travis/install-pq.sh b/travis/install-pq.sh index 152d319..54e0a49 100755 --- a/travis/install-pq.sh +++ b/travis/install-pq.sh @@ -8,3 +8,4 @@ make; make install; popd; echo "extension=pq.so" >> "$(php -r 'echo php_ini_loaded_file();')"; +rm -rf ext-pq diff --git a/travis/install-raphf.sh b/travis/install-raphf.sh index 8347f04..222f34c 100755 --- a/travis/install-raphf.sh +++ b/travis/install-raphf.sh @@ -8,3 +8,4 @@ make; make install; popd; echo "extension=raphf.so" >> "$(php -r 'echo php_ini_loaded_file();')"; +rm -rf ext-raphf