connect( PostgresConnectionConfig::fromString('host=localhost user=postgres'), new TimeoutCancellationToken(100) ); $this->assertInstanceOf(Connection::class, $connection); } /** * @depends testConnect */ public function testConnectCancellationBeforeConnect(): Promise { $this->expectException(CancelledException::class); $source = new CancellationTokenSource; $token = $source->getToken(); $source->cancel(); return $this->connect(PostgresConnectionConfig::fromString('host=localhost user=postgres'), $token); } /** * @depends testConnectCancellationBeforeConnect */ public function testConnectCancellationAfterConnect(): \Generator { $source = new CancellationTokenSource; $token = $source->getToken(); $connection = yield $this->connect(PostgresConnectionConfig::fromString('host=localhost user=postgres'), $token); $this->assertInstanceOf(Connection::class, $connection); $source->cancel(); } /** * @depends testConnectCancellationBeforeConnect */ public function testConnectInvalidUser(): Promise { $this->expectException(FailureException::class); return $this->connect(PostgresConnectionConfig::fromString('host=localhost user=invalid'), new TimeoutCancellationToken(100)); } }