Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

added connection type to allow force new connection #7396

Merged
merged 3 commits into from
May 4, 2015
Merged

added connection type to allow force new connection #7396

merged 3 commits into from
May 4, 2015

Conversation

yp28
Copy link
Contributor

@yp28 yp28 commented Apr 1, 2015

#7377

Connection now allows to specify type.

@yp28
Copy link
Contributor Author

yp28 commented Apr 1, 2015

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));
Copy link
Contributor

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

Copy link
Contributor Author

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!

@samsonasik
Copy link
Contributor

I think you can add :

 if (! extension_loaded('pgsql')) {
     $this->markTestSkipped('pgsql extension not loaded');
}

*/
public function testSetConnectionTypeException()
{
$this->connection->setType(3);
Copy link
Member

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.

@weierophinney weierophinney added this to the 2.4.1 milestone May 4, 2015
weierophinney added a commit that referenced this pull request May 4, 2015
added connection type to allow force new connection
weierophinney added a commit that referenced this pull request May 4, 2015
weierophinney added a commit that referenced this pull request May 4, 2015
@weierophinney weierophinney merged commit 97b25fb into zendframework:master May 4, 2015
weierophinney added a commit that referenced this pull request May 4, 2015
@Maks3w
Copy link
Member

Maks3w commented May 4, 2015

PGSQL_CONNECT_ASYNC was added on PHP 5.6

@weierophinney
Copy link
Member

I'll create a PR that fixes this.

@yp28 yp28 deleted the pgsql-specify-connection-type branch May 4, 2015 17:55
weierophinney added a commit to weierophinney/zendframework that referenced this pull request May 4, 2015
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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants