1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-02 17:37:57 +01:00
postgres/test/FunctionsTest.php

35 lines
882 B
PHP
Raw Normal View History

2016-12-30 06:21:17 +01:00
<?php
2016-09-14 16:27:39 +02:00
namespace Amp\Postgres\Test;
2019-09-27 05:41:47 +02:00
use Amp\PHPUnit\AsyncTestCase;
use Amp\Postgres\Connection;
2018-07-01 19:33:12 +02:00
use Amp\Postgres\ConnectionConfig;
2019-09-27 05:41:47 +02:00
use Amp\Sql\FailureException;
use function Amp\Postgres\connect;
2016-09-14 16:27:39 +02:00
2019-09-27 05:41:47 +02:00
class FunctionsTest extends AsyncTestCase
2018-07-01 19:33:12 +02:00
{
2020-02-06 23:34:49 +01:00
public function setUp(): void
2018-07-01 19:33:12 +02:00
{
2019-09-27 05:41:47 +02:00
parent::setUp();
2016-09-20 07:47:16 +02:00
if (!\extension_loaded('pgsql') && !\extension_loaded('pq')) {
$this->markTestSkipped('This test requires either ext/pgsql or pecl/pq');
}
}
2020-10-11 18:49:15 +02:00
public function testConnect()
2018-07-01 19:33:12 +02:00
{
2020-10-11 18:49:15 +02:00
$connection = connect(ConnectionConfig::fromString('host=localhost user=postgres'));
2019-09-27 05:41:47 +02:00
$this->assertInstanceOf(Connection::class, $connection);
2016-09-14 16:27:39 +02:00
}
2020-10-11 18:49:15 +02:00
public function testConnectInvalidUser()
2018-07-01 19:33:12 +02:00
{
2019-09-27 05:41:47 +02:00
$this->expectException(FailureException::class);
2020-10-11 18:49:15 +02:00
connect(ConnectionConfig::fromString('host=localhost user=invalid'));
2016-09-14 16:27:39 +02:00
}
}