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 Ibm Db2 unit & integration tests
- Loading branch information
1 parent
823e727
commit 8c5e765
Showing
12 changed files
with
876 additions
and
4 deletions.
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
30 changes: 30 additions & 0 deletions
30
tests/ZendTest/Db/Adapter/Driver/IbmDb2/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\IbmDb2; | ||
|
||
abstract class AbstractIntegrationTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected $variables = array( | ||
'database' => 'ZEND_DB_ADAPTER_DRIVER_IBMDB2_DATABASE', | ||
'username' => 'ZEND_DB_ADAPTER_DRIVER_IBMDB2_USERNAME', | ||
'password' => 'ZEND_DB_ADAPTER_DRIVER_IBMDB2_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('ibm_db2')) { | ||
$this->fail('The phpunit group integration-ibm_db2 was enabled, but the extension is not loaded.'); | ||
} | ||
} | ||
} |
149 changes: 149 additions & 0 deletions
149
tests/ZendTest/Db/Adapter/Driver/IbmDb2/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,149 @@ | ||
<?php | ||
namespace ZendTest\Db\Adapter\Driver\IbmDb2; | ||
|
||
use Zend\Db\Adapter\Driver\IbmDb2\IbmDb2; | ||
use Zend\Db\Adapter\Driver\IbmDb2\Connection; | ||
|
||
/** | ||
* @group integration | ||
* @group integration-sqlserver | ||
*/ | ||
class ConnectionIntegrationTest extends AbstractIntegrationTest | ||
{ | ||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\Connection::getCurrentSchema | ||
*/ | ||
public function testGetCurrentSchema() | ||
{ | ||
$connection = new Connection($this->variables); | ||
$this->assertInternalType('string', $connection->getCurrentSchema()); | ||
} | ||
|
||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\Connection::setResource | ||
*/ | ||
public function testSetResource() | ||
{ | ||
$resource = db2_connect( | ||
$this->variables['database'], | ||
$this->variables['username'], | ||
$this->variables['password'] | ||
); | ||
$connection = new Connection(array()); | ||
$this->assertSame($connection, $connection->setResource($resource)); | ||
|
||
$connection->disconnect(); | ||
unset($connection); | ||
unset($resource); | ||
} | ||
|
||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\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\IbmDb2\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\IbmDb2\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\IbmDb2\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\IbmDb2\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\IbmDb2\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\IbmDb2\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\IbmDb2\Connection::execute | ||
*/ | ||
public function testExecute() | ||
{ | ||
$sqlsrv = new IbmDb2($this->variables); | ||
$connection = $sqlsrv->getConnection(); | ||
|
||
$result = $connection->execute('SELECT \'foo\' FROM SYSIBM.SYSDUMMY1'); | ||
$this->assertInstanceOf('Zend\Db\Adapter\Driver\IbmDb2\Result', $result); | ||
} | ||
|
||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\Connection::getLastGeneratedValue | ||
*/ | ||
public function testGetLastGeneratedValue() | ||
{ | ||
$this->markTestIncomplete('Need to create a temporary sequence.'); | ||
$connection = new Connection($this->variables); | ||
$connection->getLastGeneratedValue(); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
tests/ZendTest/Db/Adapter/Driver/IbmDb2/ConnectionTest.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,56 @@ | ||
<?php | ||
namespace ZendTest\Db\Adapter\Driver\IbmDb2; | ||
|
||
use Zend\Db\Adapter\Driver\IbmDb2\IbmDb2; | ||
use Zend\Db\Adapter\Driver\IbmDb2\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\IbmDb2\Connection::setDriver | ||
*/ | ||
public function testSetDriver() | ||
{ | ||
$this->assertEquals($this->connection, $this->connection->setDriver(new IbmDb2(array()))); | ||
} | ||
|
||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\Connection::setConnectionParameters | ||
*/ | ||
public function testSetConnectionParameters() | ||
{ | ||
$this->assertEquals($this->connection, $this->connection->setConnectionParameters(array())); | ||
} | ||
|
||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\Connection::getConnectionParameters | ||
*/ | ||
public function testGetConnectionParameters() | ||
{ | ||
$this->connection->setConnectionParameters(array('foo' => 'bar')); | ||
$this->assertEquals(array('foo' => 'bar'), $this->connection->getConnectionParameters()); | ||
} | ||
|
||
} |
Oops, something went wrong.