forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added working integration tests for Zend\Db Oci8 driver
- Loading branch information
1 parent
1adee24
commit 173c73f
Showing
13 changed files
with
853 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/ZendTest/Db/Adapter/Driver/Oci8/AbstractIntegrationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.'); | ||
} | ||
} | ||
} |
151 changes: 151 additions & 0 deletions
151
tests/ZendTest/Db/Adapter/Driver/Oci8/ConnectionIntegrationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
tests/ZendTest/Db/Adapter/Driver/Oci8/Oci8IntegrationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
|
||
} |
Oops, something went wrong.