mirror of
https://github.com/danog/postgres.git
synced 2024-12-02 09:27:54 +01:00
2a1c96761b
Timeout wasn't being properly used and the implementation assumed single watchers on sockets, so it was more complex than needed.
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Amp\Postgres\Test;
|
|
|
|
use Amp\Postgres\{ Connection, function connect };
|
|
use AsyncInterop\Loop;
|
|
|
|
class FunctionsTest extends \PHPUnit_Framework_TestCase {
|
|
public function setUp() {
|
|
if (!\extension_loaded('pgsql') && !\extension_loaded('pq')) {
|
|
$this->markTestSkipped('This test requires either ext/pgsql or pecl/pq');
|
|
}
|
|
}
|
|
|
|
public function testConnect() {
|
|
Loop::execute(\Amp\wrap(function () {
|
|
$connection = yield connect('host=localhost user=postgres', 100);
|
|
$this->assertInstanceOf(Connection::class, $connection);
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Postgres\FailureException
|
|
*/
|
|
public function testConnectInvalidUser() {
|
|
Loop::execute(\Amp\wrap(function () {
|
|
$connection = yield connect('host=localhost user=invalid', 100);
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Postgres\FailureException
|
|
*/
|
|
public function testConnectInvalidConnectionString() {
|
|
Loop::execute(\Amp\wrap(function () {
|
|
$connection = yield connect('invalid connection string', 100);
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Postgres\FailureException
|
|
*/
|
|
public function testConnectInvalidHost() {
|
|
Loop::execute(\Amp\wrap(function () {
|
|
$connection = yield connect('hostaddr=invalid.host user=postgres', 100);
|
|
}));
|
|
}
|
|
}
|