Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'hotfix/3691'

Close #3691
Fixes #3469
  • Loading branch information...
commit dfb00052bbf668d144ca14538db6c1abafa99a9a 2 parents 0560b18 + 8f4e436
@weierophinney weierophinney authored
View
2  library/Zend/Db/Adapter/Driver/IbmDb2/Connection.php
@@ -146,7 +146,7 @@ public function getResource()
public function connect()
{
if (is_resource($this->resource)) {
- return;
+ return $this;
}
// localize
View
5 library/Zend/Db/Adapter/Driver/Mysqli/Connection.php
@@ -156,12 +156,12 @@ public function getResource()
* Connect
*
* @throws Exception\RuntimeException
- * @return void
+ * @return Connection
*/
public function connect()
{
if ($this->resource instanceof \mysqli) {
- return;
+ return $this;
}
// localize
@@ -214,6 +214,7 @@ public function connect()
$this->resource->set_charset($p['charset']);
}
+ return $this;
}
/**
View
6 library/Zend/Db/Adapter/Driver/Pgsql/Connection.php
@@ -143,13 +143,13 @@ public function getResource()
/**
* Connect to the database
*
- * @return void
+ * @return Connection
* @throws Exception\RuntimeException on failure
*/
public function connect()
{
if (is_resource($this->resource)) {
- return;
+ return $this;
}
// localize
@@ -184,6 +184,8 @@ public function connect()
__METHOD__
));
}
+
+ return $this;
}
/**
View
4 library/Zend/Db/Adapter/Driver/Sqlsrv/Connection.php
@@ -154,12 +154,12 @@ public function getResource()
* Connect
*
* @throws Exception\RuntimeException
- * @return null
+ * @return Connection
*/
public function connect()
{
if ($this->resource) {
- return;
+ return $this;
}
$serverName = '.';
View
19 tests/ZendTest/Db/Adapter/Driver/IbmDb2/ConnectionIntegrationTest.php
@@ -154,4 +154,23 @@ public function testGetLastGeneratedValue()
$connection = new Connection($this->variables);
$connection->getLastGeneratedValue();
}
+
+ /**
+ * @group zf3469
+ */
+ public function testConnectReturnsConnectionWhenResourceSet()
+ {
+ $resource = db2_connect(
+ $this->variables['database'],
+ $this->variables['username'],
+ $this->variables['password']
+ );
+ $connection = new Connection(array());
+ $connection->setResource($resource);
+ $this->assertSame($connection, $connection->connect());
+
+ $connection->disconnect();
+ unset($connection);
+ unset($resource);
+ }
}
View
17 tests/ZendTest/Db/Adapter/Driver/Oci8/ConnectionIntegrationTest.php
@@ -144,4 +144,21 @@ public function testGetLastGeneratedValue()
$connection = new Connection($this->variables);
$connection->getLastGeneratedValue();
}
+
+ /**
+ * @group zf3469
+ */
+ public function testConnectReturnsConnectionWhenResourceSet()
+ {
+ $this->markTestIncomplete('edit this');
+ $resource = oci_connect($this->variables['username'], $this->variables['password']);
+
+ $connection = new Connection(array());
+ $connection->setResource($resource);
+ $this->assertSame($connection, $connection->connect());
+
+ $connection->disconnect();
+ unset($connection);
+ unset($resource);
+ }
}
View
20 tests/ZendTest/Db/Adapter/Driver/Sqlsrv/ConnectionIntegrationTest.php
@@ -159,4 +159,24 @@ public function testGetLastGeneratedValue()
$connection = new Connection($this->variables);
$connection->getLastGeneratedValue();
}
+
+ /**
+ * @group zf3469
+ */
+ public function testConnectReturnsConnectionWhenResourceSet()
+ {
+ $resource = sqlsrv_connect(
+ $this->variables['hostname'], array(
+ 'UID' => $this->variables['username'],
+ 'PWD' => $this->variables['password']
+ )
+ );
+ $connection = new Connection(array());
+ $connection->setResource($resource);
+ $this->assertSame($connection, $connection->connect());
+
+ $connection->disconnect();
+ unset($connection);
+ unset($resource);
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.