Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed references to Mysqli in Zend\Db\Adapter\Driver\Pgsql

  • Loading branch information...
commit 5c2230c4c9be3ceb8e05832dfc24a9a884b5c3a8 1 parent bc6a795
@adamlundrigan adamlundrigan authored
View
7 library/Zend/Db/Adapter/Driver/Pgsql/Connection.php
@@ -10,7 +10,6 @@
namespace Zend\Db\Adapter\Driver\Pgsql;
-use mysqli;
use Zend\Db\Adapter\Driver\ConnectionInterface;
use Zend\Db\Adapter\Exception;
@@ -48,13 +47,13 @@ class Connection implements ConnectionInterface
/**
* Constructor
*
- * @param mysqli|array|null $connectionInfo
+ * @param resource|array|null $connectionInfo
*/
public function __construct($connectionInfo = null)
{
if (is_array($connectionInfo)) {
$this->setConnectionParameters($connectionInfo);
- } elseif ($connectionInfo instanceof mysqli) {
+ } elseif (is_resource($connectionInfo)) {
$this->setResource($connectionInfo);
}
}
@@ -224,7 +223,7 @@ public function execute($sql)
//var_dump(pg_result_status($resultResource));
- // if the returnValue is something other than a mysqli_result, bypass wrapping it
+ // if the returnValue is something other than a pg result resource, bypass wrapping it
if ($resultResource === false) {
throw new Exception\InvalidQueryException(pg_errormessage());
}
View
4 library/Zend/Db/Adapter/Driver/Pgsql/Pgsql.php
@@ -122,8 +122,8 @@ public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCAS
*/
public function checkEnvironment()
{
- if (!extension_loaded('mysqli')) {
- throw new Exception\RuntimeException('The Mysqli extension is required for this adapter but the extension is not loaded');
+ if (!extension_loaded('pgsql')) {
+ throw new Exception\RuntimeException('The PostgreSQL (pgsql) extension is required for this adapter but the extension is not loaded');
}
}
View
12 tests/ZendTest/Db/Adapter/AdapterTest.php
@@ -64,6 +64,12 @@ public function testCreateDriverFromParameters()
unset($adapter);
}
+ if (extension_loaded('pgsql')) {
+ $adapter = new Adapter(array('driver' => 'pgsql'), $this->mockPlatform);
+ $this->assertInstanceOf('Zend\Db\Adapter\Driver\Pgsql\Pgsql', $adapter->driver);
+ unset($adapter);
+ }
+
if (extension_loaded('sqlsrv')) {
$adapter = new Adapter(array('driver' => 'sqlsrv'), $this->mockPlatform);
$this->assertInstanceOf('Zend\Db\Adapter\Driver\Sqlsrv\Sqlsrv', $adapter->driver);
@@ -96,6 +102,12 @@ public function testCreatePlatformFromDriver()
unset($adapter, $driver);
$driver = clone $this->mockDriver;
+ $driver->expects($this->any())->method('getDatabasePlatformName')->will($this->returnValue('Postgresql'));
+ $adapter = new Adapter($driver);
+ $this->assertInstanceOf('Zend\Db\Adapter\Platform\Postgresql', $adapter->platform);
+ unset($adapter, $driver);
+
+ $driver = clone $this->mockDriver;
$driver->expects($this->any())->method('getDatabasePlatformName')->will($this->returnValue('Sqlite'));
$adapter = new Adapter($driver);
$this->assertInstanceOf('Zend\Db\Adapter\Platform\Sqlite', $adapter->platform);
View
147 tests/ZendTest/Db/Adapter/Driver/Pgsql/PgsqlTest.php
@@ -0,0 +1,147 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Pgsql;
+
+use Zend\Db\Adapter\Driver\Pgsql\Pgsql;
+
+class PgsqlTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @var Pgsql
+ */
+ protected $pgsql = null;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->pgsql = new Pgsql(array());
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::checkEnvironment
+ */
+ public function testCheckEnvironment()
+ {
+ if (extension_loaded('pgsql')) {
+ $this->markTestSkipped('PostgreSQL extension (pgsql) is already loaded');
+ }
+ $this->setExpectedException('Zend\Db\Adapter\Exception\RuntimeException');
+ $this->pgsql->checkEnvironment();
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::registerConnection
+ */
+ public function testRegisterConnection()
+ {
+ $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Connection', array(array()), '', true, true, true, array('setDriver'));
+ $mockConnection->expects($this->once())->method('setDriver')->with($this->equalTo($this->pgsql));
+ $this->assertSame($this->pgsql, $this->pgsql->registerConnection($mockConnection));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::registerStatementPrototype
+ */
+ public function testRegisterStatementPrototype()
+ {
+ $this->pgsql = new Pgsql(array());
+ $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Statement', array(), '', true, true, true, array('setDriver'));
+ $mockStatement->expects($this->once())->method('setDriver')->with($this->equalTo($this->pgsql));
+ $this->assertSame($this->pgsql, $this->pgsql->registerStatementPrototype($mockStatement));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::registerResultPrototype
+ */
+ public function testRegisterResultPrototype()
+ {
+ $this->pgsql = new Pgsql(array());
+ $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Pgsql\Result', array(), '', true, true, true, array('setDriver'));
+ $this->assertSame($this->pgsql, $this->pgsql->registerResultPrototype($mockStatement));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::getDatabasePlatformName
+ */
+ public function testGetDatabasePlatformName()
+ {
+ $this->pgsql = new Pgsql(array());
+ $this->assertEquals('Postgresql', $this->pgsql->getDatabasePlatformName());
+ $this->assertEquals('PostgreSQL', $this->pgsql->getDatabasePlatformName(Pgsql::NAME_FORMAT_NATURAL));
+ }
+
+ /**
+ * @depends testRegisterConnection
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::getConnection
+ */
+ public function testGetConnection($mockConnection)
+ {
+ $conn = new \Zend\Db\Adapter\Driver\Pgsql\Connection(array());
+ $this->pgsql->registerConnection($conn);
+ $this->assertSame($conn, $this->pgsql->getConnection());
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::createStatement
+ * @todo Implement testGetPrepareType().
+ */
+ public function testCreateStatement()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::createResult
+ * @todo Implement testGetPrepareType().
+ */
+ public function testCreateResult()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::getPrepareType
+ * @todo Implement testGetPrepareType().
+ */
+ public function testGetPrepareType()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::formatParameterName
+ * @todo Implement testFormatParameterName().
+ */
+ public function testFormatParameterName()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Pgsql\Pgsql::getLastGeneratedValue
+ * @todo Implement testGetLastGeneratedValue().
+ */
+ public function testGetLastGeneratedValue()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.