1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-02 09:27:54 +01:00
postgres/test/FunctionsTest.php
2020-10-11 11:49:15 -05:00

35 lines
882 B
PHP

<?php
namespace Amp\Postgres\Test;
use Amp\PHPUnit\AsyncTestCase;
use Amp\Postgres\Connection;
use Amp\Postgres\ConnectionConfig;
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()
{
$connection = connect(ConnectionConfig::fromString('host=localhost user=postgres'));
$this->assertInstanceOf(Connection::class, $connection);
}
public function testConnectInvalidUser()
{
$this->expectException(FailureException::class);
connect(ConnectionConfig::fromString('host=localhost user=invalid'));
}
}