ZF-1868: Add a unit test to fetch a LOB column

Description

As a first step to creating more test coverage for the Zend_Db component, I have created a simple unit test that fetches LOBs. It retrieves both a BLOB and a CLOB column, then does a string comparison.

The test is called testAdapterFetchLob() and is placed in the file:

tests/Zend/Db/Adapter/TestCommon.php

This requires some DDL that creates a table with LOB columns and also populates the table with 1 row. This is provided in:

tests/Zend/Db/TestUtil/Common.php

This may have to be changed because different databases may define LOBs differently. For example, MySQL uses TEXT, not CLOB.

Also, I made a DB2-specific modification to allow a string to be inserted as a BLOB in the file:

tests/Zend/Db/TestUtil/Db2.php

Please review the unit test and change as appropriate. If you also have some suggestions on what other type of LOB tests could be useful, I can add them as time permits.

Comments

testAdapterFetchLob() is defined here

DDL and population of LOB table

DB2-specific change to convert a string to a BLOB.

Assign to Bill Karwin.

I expanded the original test to now include 4 asserts:

  1. Number of rows returned (should now be 3)
  2. Select LOB column that contains data
  3. Select LOB column that contains null (NEW)
  4. Select LOB column that contains a zero-length string ('') (NEW)

Updated files now include:

tests/Zend/Db/TestUtil/Common.php -- contains DDL and data for table tests/Zend/Db/TestUtil/Db2.php -- DB2 specific data for a BLOB column tests/Zend/Db/Adapter/TestCommon.php -- testAdapterFetchLob() with 2 new asserts

Assigning to [~ledezma]

Hy Salvador,

if you are not able to commit this patch, you should un-assign this issue so anyone with commit-rights will do this.

Otherwise please commit your changes and close this issue. ;-)

I had submitted these patches for review by someone with commit authority.

Please use as you see fit.

Resetting 'fix version priority' and 'fix version' to be re-evaluated for next release.

Tests added with correction of ZF-5146 (r13071)