Permalink
Browse files

Merge branch 'hotfix/3691'

Close #3691
Fixes #3469
  • Loading branch information...
2 parents fe56fe7 + 5db378d commit c056d3fbd8d0c4bf3c3513d50f8a63a305d9ce26 @weierophinney weierophinney committed Feb 8, 2013
@@ -146,7 +146,7 @@ public function getResource()
public function connect()
{
if (is_resource($this->resource)) {
- return;
+ return $this;
}
// localize
@@ -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;
}
/**
@@ -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;
}
/**
@@ -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 = '.';
@@ -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);
+ }
}
@@ -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);
+ }
}
@@ -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);
+ }
}

0 comments on commit c056d3f

Please sign in to comment.