1
0
mirror of https://github.com/danog/postgres.git synced 2024-11-30 04:29:12 +01:00
postgres/test/FunctionsTest.php

38 lines
966 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;
use Amp\Loop;
use Amp\Postgres\Connection;
2018-07-01 19:33:12 +02:00
use Amp\Postgres\ConnectionConfig;
2017-05-26 17:47:44 +02:00
use PHPUnit\Framework\TestCase;
use function Amp\Postgres\connect;
2016-09-14 16:27:39 +02:00
2018-07-01 19:33:12 +02:00
class FunctionsTest extends TestCase
{
public function 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');
}
}
2018-07-01 19:33:12 +02:00
public function testConnect()
{
Loop::run(function () {
$connection = yield connect(ConnectionConfig::fromString('host=localhost user=postgres'));
2016-09-14 16:27:39 +02:00
$this->assertInstanceOf(Connection::class, $connection);
});
2016-09-14 16:27:39 +02:00
}
/**
2018-07-01 19:33:12 +02:00
* @expectedException \Amp\Sql\FailureException
2016-09-14 16:27:39 +02:00
*/
2018-07-01 19:33:12 +02:00
public function testConnectInvalidUser()
{
Loop::run(function () {
$connection = yield connect(ConnectionConfig::fromString('host=localhost user=invalid'));
});
2016-09-14 16:27:39 +02:00
}
}