Zend Framework

Add a unit test to fetch a LOB column

Details

  • Type: Unit Tests: Improvement Unit Tests: Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.10.2
  • Component/s: Zend_Db
  • Labels:
    None
  • Fix Version Priority:
    Should Have

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.

  1. Common.php
    30/Aug/07 3:25 PM
    13 kB
    Salvador Ledezma
  2. Common.php
    20/Aug/07 7:19 PM
    13 kB
    Salvador Ledezma
  3. Db2.php
    30/Aug/07 3:25 PM
    6 kB
    Salvador Ledezma
  4. Db2.php
    20/Aug/07 7:20 PM
    5 kB
    Salvador Ledezma
  5. TestCommon.php
    30/Aug/07 3:25 PM
    58 kB
    Salvador Ledezma
  6. TestCommon.php
    20/Aug/07 7:19 PM
    57 kB
    Salvador Ledezma

Issue Links

Activity

Hide
Salvador Ledezma added a comment -

testAdapterFetchLob() is defined here

Show
Salvador Ledezma added a comment - testAdapterFetchLob() is defined here
Hide
Salvador Ledezma added a comment -

DDL and population of LOB table

Show
Salvador Ledezma added a comment - DDL and population of LOB table
Hide
Salvador Ledezma added a comment -

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

Show
Salvador Ledezma added a comment - DB2-specific change to convert a string to a BLOB.
Hide
Bill Karwin added a comment -

Assign to Bill Karwin.

Show
Bill Karwin added a comment - Assign to Bill Karwin.
Hide
Salvador Ledezma added a comment -

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

Show
Salvador Ledezma added a comment - 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
Hide
Darby Felton added a comment -

Assigning to Salvador Ledezma

Show
Darby Felton added a comment - Assigning to Salvador Ledezma
Hide
Thomas Weidner added a comment -

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.

Show
Thomas Weidner added a comment - 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.
Hide
Salvador Ledezma added a comment -

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

Please use as you see fit.

Show
Salvador Ledezma added a comment - I had submitted these patches for review by someone with commit authority. Please use as you see fit.
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - Resetting 'fix version priority' and 'fix version' to be re-evaluated for next release.
Hide
Mickael Perraud added a comment -

Tests added with correction of ZF-5146 (r13071)

Show
Mickael Perraud added a comment - Tests added with correction of ZF-5146 (r13071)

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
3d
Original Estimate - 3 days
Remaining:
3d
Remaining Estimate - 3 days
Logged:
Not Specified
Time Spent - Not Specified