-
Notifications
You must be signed in to change notification settings - Fork 2.5k
added connection type to allow force new connection #7396
added connection type to allow force new connection #7396
Conversation
Test failed due to use of undefined constant PGSQL_CONNECT_ASYNC. This constant is only available if the PGSQL extension is enabled in PHP. |
$this->connection->setType($type); | ||
$reflectionProperty = new \ReflectionProperty($this->connection, 'type'); | ||
$reflectionProperty->setAccessible(true); | ||
$this->assertEquals($type, $reflectionProperty->getValue($this->connection)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of ReflectionProperty
you can use readAttribute()
for this:
public function testSetConnectionType()
{
$type = PGSQL_CONNECT_FORCE_NEW;
$this->connection->setType($type);
$this->assertEquals($type, self::readAttribute($this->connection, 'type'));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for the feedback!
I think you can add : if (! extension_loaded('pgsql')) {
$this->markTestSkipped('pgsql extension not loaded');
} |
*/ | ||
public function testSetConnectionTypeException() | ||
{ | ||
$this->connection->setType(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test also needs to be skipped if pgsql is not present, as it's exercising code that will check for those constants. I can make that change on merge.
added connection type to allow force new connection
|
I'll create a PR that fixes this. |
Raise a RuntimeException when the method is invoked in versions less than 5.6, and skip unit tests in those situations as well. Also fixes several long lines.
#7377
Connection now allows to specify type.