mirror of
https://github.com/danog/postgres.git
synced 2024-11-30 04:29:12 +01:00
36 lines
933 B
PHP
36 lines
933 B
PHP
<?php
|
|
|
|
namespace Amp\Postgres\Test;
|
|
|
|
use Amp\PHPUnit\AsyncTestCase;
|
|
use Amp\Postgres\Connection;
|
|
use Amp\Postgres\ConnectionConfig;
|
|
use Amp\Promise;
|
|
use Amp\Sql\FailureException;
|
|
use function Amp\Postgres\connect;
|
|
|
|
class FunctionsTest extends AsyncTestCase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
if (!\extension_loaded('pgsql') && !\extension_loaded('pq')) {
|
|
$this->markTestSkipped('This test requires either ext/pgsql or pecl/pq');
|
|
}
|
|
}
|
|
|
|
public function testConnect(): \Generator
|
|
{
|
|
$connection = yield connect(ConnectionConfig::fromString('host=localhost user=postgres'));
|
|
$this->assertInstanceOf(Connection::class, $connection);
|
|
}
|
|
|
|
public function testConnectInvalidUser(): Promise
|
|
{
|
|
$this->expectException(FailureException::class);
|
|
|
|
return connect(ConnectionConfig::fromString('host=localhost user=invalid'));
|
|
}
|
|
}
|