mirror of
https://github.com/danog/postgres.git
synced 2024-11-26 20:15:02 +01:00
fac9041cac
Changed to match code styles used in other Amp packages.
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Amp\Postgres\Test;
|
|
|
|
use Amp\Loop;
|
|
use Amp\Postgres\Connection;
|
|
use PHPUnit\Framework\TestCase;
|
|
use function Amp\Postgres\connect;
|
|
|
|
class FunctionsTest extends 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::run(function () {
|
|
$connection = yield connect('host=localhost user=postgres');
|
|
$this->assertInstanceOf(Connection::class, $connection);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Postgres\FailureException
|
|
*/
|
|
public function testConnectInvalidUser() {
|
|
Loop::run(function () {
|
|
$connection = yield connect('host=localhost user=invalid');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Postgres\FailureException
|
|
*/
|
|
public function testConnectInvalidConnectionString() {
|
|
Loop::run(function () {
|
|
$connection = yield connect('invalid connection string');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @expectedException \Amp\Postgres\FailureException
|
|
*/
|
|
public function testConnectInvalidHost() {
|
|
Loop::run(function () {
|
|
$connection = yield connect('hostaddr=invalid.host user=postgres');
|
|
});
|
|
}
|
|
}
|