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