Index: tests/Zend/Db/Adapter/TestCommon.php =================================================================== --- tests/Zend/Db/Adapter/TestCommon.php (revision 14591) +++ tests/Zend/Db/Adapter/TestCommon.php (working copy) @@ -280,7 +280,7 @@ $ids = $this->_db->fetchCol("SELECT $product_id FROM $products ORDER BY $product_id"); $this->assertEquals(array(2, 3), $ids); } - + /** * @group ZF-1726 */ @@ -916,6 +916,51 @@ } /** + * Ensures that exec() throws an exception when given a bogus query + * + * @return void + */ + public function testAdapterExecBogus() + { + try { + $this->_db->exec('Bogus query'); + $this->fail('Expected exception not thrown'); + } catch (Zend_Exception $e) { + $this->assertType('integer', $e, + 'Expecting integer, got '.get_class($e)); + } + } + + /** + * Ensures that exec() throws an exception when given a bogus table + * + * @return void + */ + public function testAdapterExecBogusTable() + { + try { + $this->_db->exec('DELETE FROM BogusTable'); + $this->fail('Expected exception not thrown'); + } catch (Zend_Exception $e) { + $this->assertType('integer', $e, + 'Expecting integer, got '.get_class($e)); + } + } + + /** + * Ensures that exec() provides expected behavior when modifying no rows + * + * @return void + */ + public function testAdapterExecModifiedNone() + { + $affected = $this->_db->exec('DELETE FROM ' . $this->_db->quoteIdentifier('zfbugs') . ' WHERE 1 = -1'); + + $this->assertEquals(0, $affected, + "Expected exec() to return zero affected rows; got $count"); + } + + /** * Ensures that query() throws an exception when given a bogus query * * @return void @@ -1729,7 +1774,7 @@ $value = $this->_db->fetchOne("SELECT $bug_status FROM $bugs WHERE $bug_id = 1"); $this->assertEquals('ARRAY', $value); } - + /** * @group ZF-1726 */ @@ -1962,7 +2007,7 @@ $db = unserialize(serialize($db)); $this->assertTrue($db->isConnected()); } - + /** * @group ZF-1541 */ @@ -1975,7 +2020,7 @@ $params['options'] = array( 'charset' => 'utf8' ); - + $db = Zend_Db::factory($this->getDriver(), $params); /** @@ -1985,7 +2030,7 @@ * * $db->query('SET NAMES utf8'); */ - + // create a new util object, with the new db adapter $driver = $this->getDriver(); $utilClass = "Zend_Db_TestUtil_{$driver}";