1
0
mirror of https://github.com/danog/postgres.git synced 2024-12-03 09:57:48 +01:00
postgres/test/FunctionsTest.php
Aaron Piotrowski fac9041cac
Update and fix code styles
Changed to match code styles used in other Amp packages.
2017-06-20 22:59:42 -05:00

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');
});
}
}