Developing software in the Real World

The Zend Framework PDO driver's insert() function is fixed!

This bug is finally fixed in subversion revision 386 of the Zend Framework. The Zend Framework now as a bug tracker and this bug was reported in tickets #21 and #32. I noticed #36 first though, so attached the correct patch there.

A little later I committed it to subversion and that bug is gone!

Next up is unit tests for the Zend_Db tree. I’ve created ticket #36 to track my first attempt at getting some unit tests for Zend_Db_Adapter_Pdo_* working. Note that you need the insert() fix for the tests that are attached to the ticket to work!

Enabling the tests

Once you have patched your tree, you need to copy tests/TestConfiguration.php.dist to tests/TestConfiguration.php and update the defines related to either Zend_Db_Adapter_Pdo_MySQL or Zend_Db_Adapter_Pdo_MSSQL (or both!). The TESTS_ZEND_DB_ADAPTER_PDO_xxx_ENABLED define must be true and the other 4 defines for that adapater must be set up so that the test code can connect to the database and create and drop tables.

Explanation of patch

The main test files are tests/Zend/Db/Adapter/Pdo/MssqlTest.php and MysqlTest.php. The classes are Zend_Db_Adapter_Pdo_MssqlTest and Zend_Db_Adapter_Pdo_MysqlTest respectively.

Both these classes inherit from Zend_Db_Adapter_Pdo_Common which is an empty class that inherits from Zend_Db_Adapter_Common.

Zend_Db_Adapter_Common is an abstract class that inherits from PHPUnit2_Framework_TestCase. It contains common set up code to create and drop a test table (actual SQL required delegated down to the concrete classes). It also contains tests for functionality that should work regardless of the concrete Adapter used, such as testing insert.

At the moment, these classes do not cover even most of the tests required, but do show the direction I’m thinking about.

Comments welcome on the the ticket or on the mailing list.

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *