Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Zend\Db Oracle Driver #3485

Merged
merged 3 commits into from

3 participants

@ralphschindler
Collaborator

This PR introduces oracle support for Zend\Db through the ext/oci8 extension.

library/Zend/Db/Adapter/Driver/Oci8/Connection.php
((42 lines not shown))
+ *
+ * @var boolean
+ */
+ protected $inTransaction = false;
+
+ /**
+ * Constructor
+ *
+ * @param array|resource|null $connectionInfo
+ * @throws \Zend\Db\Adapter\Exception\InvalidArgumentException
+ */
+ public function __construct($connectionInfo = null)
+ {
+ if (is_array($connectionInfo)) {
+ $this->setConnectionParameters($connectionInfo);
+ } elseif ($connectionInfo instanceof \mysqli) {

instanceof oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
library/Zend/Db/Adapter/Driver/Oci8/Connection.php
((114 lines not shown))
+ * @return Connection
+ */
+ public function setResource($resource)
+ {
+ if (!is_resource($resource) || get_resource_type($resource) !== 'oci8 connection') {
+ throw new Exception\InvalidArgumentException('A resource of type "oci8 connection" was expected');
+ }
+ $this->resource = $resource;
+ return $this;
+ }
+
+ /**
+ * Get resource
+ *
+ * @return \mysqli
+ */

oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
library/Zend/Db/Adapter/Driver/Oci8/Oci8.php
((33 lines not shown))
+
+ /**
+ * @var Result
+ */
+ protected $resultPrototype = null;
+
+ /**
+ * @var array
+ */
+ protected $options = array(
+
+ );
+
+ /**
+ * @param array|Connection|\mysqli $connection
+ * @param null|Statement $statementPrototype

oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
library/Zend/Db/Adapter/Driver/Oci8/Result.php
((126 lines not shown))
+ * @return mixed
+ */
+ public function current()
+ {
+ if ($this->currentComplete == false) {
+ if ($this->loadData() === false) {
+ return false;
+ }
+ }
+
+ return $this->currentData;
+ }
+
+ /**
+ * Load from mysqli result
+ *

oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
library/Zend/Db/Adapter/Driver/Oci8/Statement.php
((108 lines not shown))
+ }
+
+ /**
+ * Get resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param \mysqli_stmt $mysqliStatement

oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
library/Zend/Db/Adapter/Driver/Oci8/Statement.php
((111 lines not shown))
+ * Get resource
+ *
+ * @return mixed
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
+ /**
+ * Set resource
+ *
+ * @param \mysqli_stmt $mysqliStatement
+ * @return Statement
+ */
+ public function setResource(\mysqli_stmt $mysqliStatement)

oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
library/Zend/Db/Adapter/Driver/Oci8/Oci8.php
((54 lines not shown))
+ if (!$connection instanceof Connection) {
+ $connection = new Connection($connection);
+ }
+
+ $options = array_intersect_key(array_merge($this->options, $options), $this->options);
+
+ $this->registerConnection($connection);
+ $this->registerStatementPrototype(($statementPrototype) ?: new Statement());
+ $this->registerResultPrototype(($resultPrototype) ?: new Result());
+ }
+
+ /**
+ * Register connection
+ *
+ * @param Connection $connection
+ * @return Mysqli

Oci8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#3485] Strip @category, @package, and @subpackage annotations
- Pre-emptive measure, in light of #3508
- Only on new files
7a1305b
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#3485] Update copyright year
- end at 2013
addbafd
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#3485] CS fixes
- Trailing whitespace
0cbe9ed
@weierophinney weierophinney merged commit 6a62913 into zendframework:develop
@weierophinney weierophinney referenced this pull request from a commit in weierophinney/zf2
@weierophinney weierophinney Merge branch 'feature/3485' into develop
Close #3485
7952179
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3485] Strip @category, @package, and @subpackage annotations
- Pre-emptive measure, in light of #3508
- Only on new files
19199cc
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3485] Update copyright year
- end at 2013
cbf481b
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3485] CS fixes
- Trailing whitespace
16746c7
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'feature/3485' into develop
Close #3485
4447383
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
9 library/Zend/Db/Adapter/Driver/Oci8/Connection.php
@@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Db
*/
@@ -104,7 +104,11 @@ public function getCurrentSchema()
$this->connect();
}
- // @todo
+ $query = "SELECT sys_context('USERENV', 'DB_NAME') as \"database_name\" FROM DUAL";
+ $stmt = oci_parse($this->resource, $query);
+ oci_execute($stmt);
+ $dbNameArray = oci_fetch_array($stmt, OCI_ASSOC);
+ return $dbNameArray['database_name'];
}
/**
@@ -177,6 +181,7 @@ public function connect()
new Exception\ErrorException($e['message'], $e['code'])
);
}
+ return $this;
}
/**
View
8 library/Zend/Db/Adapter/Driver/Oci8/Oci8.php
@@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Db
*/
@@ -84,6 +84,7 @@ public function registerStatementPrototype(Statement $statementPrototype)
{
$this->statementPrototype = $statementPrototype;
$this->statementPrototype->setDriver($this); // needs access to driver to createResult()
+ return $this;
}
/**
@@ -102,6 +103,7 @@ public function getStatementPrototype()
public function registerResultPrototype(Result $resultPrototype)
{
$this->resultPrototype = $resultPrototype;
+ return $this;
}
/**
@@ -157,6 +159,10 @@ public function createStatement($sqlOrResource = null)
} else {
if (is_string($sqlOrResource)) {
$statement->setSql($sqlOrResource);
+ } elseif ($sqlOrResource !== null) {
+ throw new Exception\InvalidArgumentException(
+ 'Oci8 only accepts an SQL string or a oci8 resource in ' . __FUNCTION__
+ );
}
if (!$this->connection->isConnected()) {
$this->connection->connect();
View
12 library/Zend/Db/Adapter/Driver/Oci8/Result.php
@@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Db
*/
@@ -94,6 +94,16 @@ public function buffer()
}
/**
+ * Is the result buffered?
+ *
+ * @return bool
+ */
+ public function isBuffered()
+ {
+ return false;
+ }
+
+ /**
* Return the resource
* @return mixed
*/
View
4 library/Zend/Db/Adapter/Driver/Oci8/Statement.php
@@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
- * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Db
*/
@@ -105,6 +105,7 @@ public function setSql($sql)
public function setParameterContainer(ParameterContainer $parameterContainer)
{
$this->parameterContainer = $parameterContainer;
+ return $this;
}
/**
@@ -187,6 +188,7 @@ public function prepare($sql = null)
}
$this->isPrepared = true;
+ return $this;
}
/**
View
30 tests/ZendTest/Db/Adapter/Driver/Oci8/AbstractIntegrationTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+abstract class AbstractIntegrationTest extends \PHPUnit_Framework_TestCase
+{
+ protected $variables = array(
+ 'hostname' => 'ZEND_DB_ADAPTER_DRIVER_OCI8_HOSTNAME',
+ 'username' => 'ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME',
+ 'password' => 'ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD',
+ );
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ foreach ($this->variables as $name => $value) {
+ if (!isset($GLOBALS[$value])) {
+ $this->fail('Missing required variable ' . $value . ' from phpunit.xml for this integration test');
+ }
+ $this->variables[$name] = $GLOBALS[$value];
+ }
+
+ if (!extension_loaded('oci8')) {
+ $this->fail('The phpunit group integration-oci8 was enabled, but the extension is not loaded.');
+ }
+ }
+}
View
151 tests/ZendTest/Db/Adapter/Driver/Oci8/ConnectionIntegrationTest.php
@@ -0,0 +1,151 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+use Zend\Db\Adapter\Driver\Oci8\Oci8;
+use Zend\Db\Adapter\Driver\Oci8\Connection;
+
+/**
+ * @group integration
+ * @group integration-sqlserver
+ */
+class ConnectionIntegrationTest extends AbstractIntegrationTest
+{
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::getCurrentSchema
+ */
+ public function testGetCurrentSchema()
+ {
+ $connection = new Connection($this->variables);
+ $this->assertInternalType('string', $connection->getCurrentSchema());
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::setResource
+ */
+ public function testSetResource()
+ {
+ $this->markTestIncomplete('edit this');
+ $resource = sqlsrv_connect(
+ $this->variables['hostname'], array(
+ 'UID' => $this->variables['username'],
+ 'PWD' => $this->variables['password']
+ )
+ );
+ $connection = new Connection(array());
+ $this->assertSame($connection, $connection->setResource($resource));
+
+ $connection->disconnect();
+ unset($connection);
+ unset($resource);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::getResource
+ */
+ public function testGetResource()
+ {
+ $connection = new Connection($this->variables);
+ $connection->connect();
+ $this->assertInternalType('resource', $connection->getResource());
+
+ $connection->disconnect();
+ unset($connection);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::connect
+ */
+ public function testConnect()
+ {
+ $connection = new Connection($this->variables);
+ $this->assertSame($connection, $connection->connect());
+ $this->assertTrue($connection->isConnected());
+
+ $connection->disconnect();
+ unset($connection);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::isConnected
+ */
+ public function testIsConnected()
+ {
+ $connection = new Connection($this->variables);
+ $this->assertFalse($connection->isConnected());
+ $this->assertSame($connection, $connection->connect());
+ $this->assertTrue($connection->isConnected());
+
+ $connection->disconnect();
+ unset($connection);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::disconnect
+ */
+ public function testDisconnect()
+ {
+ $connection = new Connection($this->variables);
+ $connection->connect();
+ $this->assertTrue($connection->isConnected());
+ $connection->disconnect();
+ $this->assertFalse($connection->isConnected());
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::beginTransaction
+ * @todo Implement testBeginTransaction().
+ */
+ public function testBeginTransaction()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::commit
+ * @todo Implement testCommit().
+ */
+ public function testCommit()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::rollback
+ * @todo Implement testRollback().
+ */
+ public function testRollback()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::execute
+ */
+ public function testExecute()
+ {
+ $oci8 = new Oci8($this->variables);
+ $connection = $oci8->getConnection();
+
+ $result = $connection->execute('SELECT \'foo\' FROM DUAL');
+ $this->assertInstanceOf('Zend\Db\Adapter\Driver\Oci8\Result', $result);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::getLastGeneratedValue
+ */
+ public function testGetLastGeneratedValue()
+ {
+ $this->markTestIncomplete('Need to create a temporary sequence.');
+ $connection = new Connection($this->variables);
+ $connection->getLastGeneratedValue();
+ }
+}
View
56 tests/ZendTest/Db/Adapter/Driver/Oci8/ConnectionTest.php
@@ -0,0 +1,56 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+use Zend\Db\Adapter\Driver\Oci8\Oci8;
+use Zend\Db\Adapter\Driver\Oci8\Connection;
+
+class ConnectionTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var Connection
+ */
+ protected $connection;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->connection = new Connection(array());
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::setDriver
+ */
+ public function testSetDriver()
+ {
+ $this->assertEquals($this->connection, $this->connection->setDriver(new Oci8(array())));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::setConnectionParameters
+ */
+ public function testSetConnectionParameters()
+ {
+ $this->assertEquals($this->connection, $this->connection->setConnectionParameters(array()));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Connection::getConnectionParameters
+ */
+ public function testGetConnectionParameters()
+ {
+ $this->connection->setConnectionParameters(array('foo' => 'bar'));
+ $this->assertEquals(array('foo' => 'bar'), $this->connection->getConnectionParameters());
+ }
+
+}
View
38 tests/ZendTest/Db/Adapter/Driver/Oci8/Oci8IntegrationTest.php
@@ -0,0 +1,38 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+use Zend\Db\Adapter\Driver\Oci8\Oci8;
+
+/**
+ * @group integration
+ * @group integration-oci8
+ */
+class Oci8IntegrationTest extends AbstractIntegrationTest
+{
+ /**
+ * @group integration-oci8
+ * @covers Zend\Db\Adapter\Driver\Oci8\Oci8::checkEnvironment
+ */
+ public function testCheckEnvironment()
+ {
+ $sqlserver = new Oci8(array());
+ $this->assertNull($sqlserver->checkEnvironment());
+ }
+
+ public function testCreateStatement()
+ {
+ $driver = new Oci8(array());
+ $resource = oci_connect($this->variables['username'], $this->variables['password']);
+
+ $driver->getConnection()->setResource($resource);
+
+ $stmt = $driver->createStatement('SELECT * FROM DUAL');
+ $this->assertInstanceOf('Zend\Db\Adapter\Driver\Oci8\Statement', $stmt);
+ $stmt = $driver->createStatement();
+ $this->assertInstanceOf('Zend\Db\Adapter\Driver\Oci8\Statement', $stmt);
+
+ $this->setExpectedException('Zend\Db\Adapter\Exception\InvalidArgumentException', 'only accepts an SQL string or a oci8 resource');
+ $driver->createStatement(new \stdClass);
+ }
+
+}
View
135 tests/ZendTest/Db/Adapter/Driver/Oci8/Oci8Test.php
@@ -0,0 +1,135 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+use Zend\Db\Adapter\Driver\Oci8\Oci8;
+
+class Oci8Test extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @var Oci8
+ */
+ protected $oci8 = null;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->oci8 = new Oci8(array());
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Oci8::registerConnection
+ */
+ public function testRegisterConnection()
+ {
+ $mockConnection = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Connection', array(array()), '', true, true, true, array('setDriver'));
+ $mockConnection->expects($this->once())->method('setDriver')->with($this->equalTo($this->oci8));
+ $this->assertSame($this->oci8, $this->oci8->registerConnection($mockConnection));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Oci8::registerStatementPrototype
+ */
+ public function testRegisterStatementPrototype()
+ {
+ $this->oci8 = new Oci8(array());
+ $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Statement', array(), '', true, true, true, array('setDriver'));
+ $mockStatement->expects($this->once())->method('setDriver')->with($this->equalTo($this->oci8));
+ $this->assertSame($this->oci8, $this->oci8->registerStatementPrototype($mockStatement));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Oci8::registerResultPrototype
+ */
+ public function testRegisterResultPrototype()
+ {
+ $this->oci8 = new Oci8(array());
+ $mockStatement = $this->getMockForAbstractClass('Zend\Db\Adapter\Driver\Oci8\Result', array(), '', true, true, true, array('setDriver'));
+ $this->assertSame($this->oci8, $this->oci8->registerResultPrototype($mockStatement));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Oci8::getDatabasePlatformName
+ */
+ public function testGetDatabasePlatformName()
+ {
+ $this->oci8 = new Oci8(array());
+ $this->assertEquals('Oracle', $this->oci8->getDatabasePlatformName());
+ $this->assertEquals('Oracle', $this->oci8->getDatabasePlatformName(Oci8::NAME_FORMAT_NATURAL));
+ }
+
+ /**
+ * @depends testRegisterConnection
+ * @covers Zend\Db\Adapter\Driver\Oci8\Oci8::getConnection
+ */
+ public function testGetConnection($mockConnection)
+ {
+ $conn = new \Zend\Db\Adapter\Driver\Oci8\Connection(array());
+ $this->oci8->registerConnection($conn);
+ $this->assertSame($conn, $this->oci8->getConnection());
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Oci8::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\Oci8\Oci8::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\Oci8\Oci8::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\Oci8\Oci8::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\Oci8\Oci8::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.'
+ );
+ }
+
+}
View
189 tests/ZendTest/Db/Adapter/Driver/Oci8/ResultIntegrationTest.php
@@ -0,0 +1,189 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+use Zend\Db\Adapter\Driver\Oci8\Result;
+
+/**
+ * @group integration
+ * @group integration-oci8
+ */
+class ResultIntegrationTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var Result
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->object = new Result;
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::initialize
+ * @todo Implement testInitialize().
+ */
+ public function testInitialize()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::buffer
+ * @todo Implement testBuffer().
+ */
+ public function testBuffer()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::getResource
+ * @todo Implement testGetResource().
+ */
+ public function testGetResource()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::current
+ * @todo Implement testCurrent().
+ */
+ public function testCurrent()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::next
+ * @todo Implement testNext().
+ */
+ public function testNext()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::key
+ * @todo Implement testKey().
+ */
+ public function testKey()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::rewind
+ * @todo Implement testRewind().
+ */
+ public function testRewind()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::valid
+ * @todo Implement testValid().
+ */
+ public function testValid()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::count
+ * @todo Implement testCount().
+ */
+ public function testCount()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::getFieldCount
+ * @todo Implement testGetFieldCount().
+ */
+ public function testGetFieldCount()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::isQueryResult
+ * @todo Implement testIsQueryResult().
+ */
+ public function testIsQueryResult()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::getAffectedRows
+ * @todo Implement testGetAffectedRows().
+ */
+ public function testGetAffectedRows()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Result::getGeneratedValue
+ * @todo Implement testGetGeneratedValue().
+ */
+ public function testGetGeneratedValue()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+}
View
95 tests/ZendTest/Db/Adapter/Driver/Oci8/StatementIntegrationTest.php
@@ -0,0 +1,95 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+use Zend\Db\Adapter\Driver\Oci8\Oci8;
+use Zend\Db\Adapter\Driver\Oci8\Statement;
+
+/**
+ * @group integration
+ * @group integration-sqlsrv
+ */
+class StatementIntegrationTest extends \PHPUnit_Framework_TestCase
+{
+
+ protected $variables = array(
+ 'hostname' => 'ZEND_DB_ADAPTER_DRIVER_OCI8_HOSTNAME',
+ 'username' => 'ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME',
+ 'password' => 'ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD',
+ );
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ foreach ($this->variables as $name => $value) {
+ if (!isset($GLOBALS[$value])) {
+ $this->fail('Missing required variable ' . $value . ' from phpunit.xml for this integration test');
+ }
+ $this->variables[$name] = $GLOBALS[$value];
+ }
+
+ if (!extension_loaded('oci8')) {
+ $this->fail('The phpunit group integration-sqlsrv was enabled, but the extension is not loaded.');
+ }
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::initialize
+ */
+ public function testInitialize()
+ {
+ $ociResource = oci_connect($this->variables['username'], $this->variables['password']);
+
+ $statement = new Statement;
+ $this->assertSame($statement, $statement->initialize($ociResource));
+ unset($stmtResource, $ociResource);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::getResource
+ */
+ public function testGetResource()
+ {
+ $ociResource = oci_connect($this->variables['username'], $this->variables['password']);
+
+ $statement = new Statement;
+ $statement->initialize($ociResource);
+ $statement->prepare('SELECT * FROM DUAL');
+ $resource = $statement->getResource();
+ $this->assertEquals('oci8 statement', get_resource_type($resource));
+ unset($resource, $ociResource);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::prepare
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::isPrepared
+ */
+ public function testPrepare()
+ {
+ $ociResource = oci_connect($this->variables['username'], $this->variables['password']);
+
+ $statement = new Statement;
+ $statement->initialize($ociResource);
+ $this->assertFalse($statement->isPrepared());
+ $this->assertSame($statement, $statement->prepare('SELECT * FROM DUAL'));
+ $this->assertTrue($statement->isPrepared());
+ unset($resource, $ociResource);
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::execute
+ */
+ public function testExecute()
+ {
+ $oci8 = new Oci8($this->variables);
+ $statement = $oci8->createStatement('SELECT * FROM DUAL');
+ $this->assertSame($statement, $statement->prepare());
+
+ $result = $statement->execute();
+ $this->assertInstanceOf('Zend\Db\Adapter\Driver\Oci8\Result', $result);
+
+ unset($resource, $sqlsrvResource);
+ }
+}
View
130 tests/ZendTest/Db/Adapter/Driver/Oci8/StatementTest.php
@@ -0,0 +1,130 @@
+<?php
+namespace ZendTest\Db\Adapter\Driver\Oci8;
+
+use Zend\Db\Adapter\Driver\Oci8\Statement;
+use Zend\Db\Adapter\Driver\Oci8\Oci8;
+use Zend\Db\Adapter\ParameterContainer;
+
+class StatementTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var Statement
+ */
+ protected $statement;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp()
+ {
+ $this->statement = new Statement;
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::setDriver
+ */
+ public function testSetDriver()
+ {
+ $this->assertEquals($this->statement, $this->statement->setDriver(new Oci8(array())));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::setParameterContainer
+ */
+ public function testSetParameterContainer()
+ {
+ $this->assertSame($this->statement, $this->statement->setParameterContainer(new ParameterContainer));
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::getParameterContainer
+ * @todo Implement testGetParameterContainer().
+ */
+ public function testGetParameterContainer()
+ {
+ $container = new ParameterContainer;
+ $this->statement->setParameterContainer($container);
+ $this->assertSame($container, $this->statement->getParameterContainer());
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::getResource
+ * @todo Implement testGetResource().
+ */
+ public function testGetResource()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::setSql
+ * @todo Implement testSetSql().
+ */
+ public function testSetSql()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::getSql
+ * @todo Implement testGetSql().
+ */
+ public function testGetSql()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::prepare
+ * @todo Implement testPrepare().
+ */
+ public function testPrepare()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::isPrepared
+ * @todo Implement testIsPrepared().
+ */
+ public function testIsPrepared()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Zend\Db\Adapter\Driver\Oci8\Statement::execute
+ * @todo Implement testExecute().
+ */
+ public function testExecute()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+}
View
5 tests/phpunit.xml.dist 100644 → 100755
@@ -23,6 +23,11 @@
<!--<var name="ZEND_DB_ADAPTER_DRIVER_SQLSRV_PASSWORD" value="" />-->
<!--<var name="ZEND_DB_ADAPTER_DRIVER_SQLSRV_DATABASE" value="" />-->
+ <!--<var name="ZEND_DB_ADAPTER_DRIVER_OCI8_HOSTNAME" value="" />-->
+ <!--<var name="ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME" value="" />-->
+ <!--<var name="ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD" value="" />-->
+ <!--<var name="ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE" value="" />-->
+
</php>
Something went wrong with that request. Please try again.