-
Notifications
You must be signed in to change notification settings - Fork 121
Implement our own error handler for db2_prepare #273
Changes from 4 commits
02313d5
ddec03b
50e1286
192d30d
c54f5e2
b4db349
ac5e8e0
e493cda
c7d834d
984e355
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
use Zend\Db\Adapter\Driver\IbmDb2\IbmDb2; | ||
use Zend\Db\Adapter\Driver\IbmDb2\Statement; | ||
use Zend\Db\Adapter\Exception\RuntimeException; | ||
|
||
/** | ||
* @group integration | ||
|
@@ -63,7 +64,7 @@ public function testGetResource() | |
|
||
$statement = new Statement; | ||
$statement->initialize($db2Resource); | ||
$statement->prepare("SELECT 'foo'"); | ||
$statement->prepare("SELECT 'foo' FROM sysibm.sysdummy1"); | ||
$resource = $statement->getResource(); | ||
$this->assertEquals('DB2 Statement', get_resource_type($resource)); | ||
unset($resource, $db2Resource); | ||
|
@@ -85,6 +86,23 @@ public function testPrepare() | |
unset($resource, $db2Resource); | ||
} | ||
|
||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\Statement::prepare | ||
* @expectedException RuntimeException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would move it to function use, because right now it's not clear, which line should thrown that exception. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @webimpress I can't - it doesn't work on the AS/400 when I do that. I have no idea why. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm... so maybe exception is thrown not where you expecting it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a PHP error. I'll have another look when I'm next connected to that computer. |
||
*/ | ||
public function testPrepareThrowsAnExceptionOnFailure() | ||
{ | ||
$db2Resource = db2_connect( | ||
$this->variables['database'], | ||
$this->variables['username'], | ||
$this->variables['password'] | ||
); | ||
$statement = new Statement; | ||
$statement->initialize($db2Resource); | ||
$statement->prepare("SELECT"); | ||
unset($resource, $db2Resource); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this line will be not even hit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will if the test fails :) |
||
} | ||
|
||
/** | ||
* @covers Zend\Db\Adapter\Driver\IbmDb2\Statement::execute | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should catch
Exception
for php 5.5/5.6 fallback as well ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - in 5.6, nothing is thrown.