Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="note"><ac:parameter ac:name="title">Archived</ac:parameter><ac:rich-text-body>
<p>This proposal has been archived and is no longer under consideration. Most key issues it aimed to solve have solutions in current PHPUnit releases at this time.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_UnitTest Component Proposal

Proposed Component Name Zend_UnitTest
Developer Notes
Proposers Ralph Schindler, author
Matthew Weier O'Phinney, Zend liaison
Revision 1.0 - October 12, 2006: Initial Draft. (wiki revision: 13)

Table of Contents

1. Overview

Issues noted during test running and test development:

  • Cannot run isolated tests - This is important for finding dependancy issues.. also speeds up development time when trying to develop tests.
  • New test writers are overwhelmed, when there are a lack of standard practices specific to the Zend Framework. Existing tests for components have a higher learning curve than necessary, since some writers add tests to suites and some add suites to suites inconsistently. Also, the current structure and organization increases the risk of changes (e.g. adding a test suite) made to the AllTests file causing adverse effects, like unintentionally undoing others' changes. Tests are getting lost in the shuffle. Currently, 2 test files exists that never get run.

Reasons for ZFTestManager

  • Ability to isolate unit test suites and unit test tests.
  • Ability to auto-generate Module's Directory and a stock AllTests.php file with default functionality for autolocating and loading tests.
  • Simplify unit test writing by reducing the learning curve and by adding Zend Framework conventions to configuraiton and organization.
  • Standardized suite/test configuration - uses native parse_ini_file().
  • Improve extensibility, including the ability to improve test failure reporting

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

Zend_UnitTest will not make increase the complexity or difficulty of writing or using unit tests for ZF components.
Zend_UnitTest will require some very minor changes to the names of existing unit tests and changes to directory organization of the unit tests to adhere to a consistent convention.
Zend_UnitTest will load all tests, and then perform the ones that have been selected.
Zend_UnitTest will support printing a hierarchical list of suites for testing.
Zend_UnitTest will support creating a new suite at specified location.
Zend_UnitTest will allow performing only selected tests, including a specific test, a test suite, and a suite along with its children.

4. Dependencies on Other Framework Components

  • Zend_Exception

5. Theory of Operation

Using Zend_UnitTest

Writing Tests

  • @todo
  • see notes inside generated AllTests.php file inside your Suite directory.

ZFTestManager Configuration / TestConfiguration.ini

Global Options

6. Milestones / Tasks

  • Milestone 1: [DONE] API
  • Milestone 2: [98% DONE] Working code, not yet committed to incubator.
  • Milestone 3: [DONE] Existing ZF tests for core components work with new ZF_UnitTest.
  • Milestone 4: Existing ZF tests for incubator components work with new ZF_UnitTest.
  • Milestone 5: Unit tests (verifying proper operation of Zend_UnitTest) exist, work, and are checked into SVN.
  • Milestone 6: Initial documentation exists.

7. Class Index

  • Zend_UnitTest

8. Use Cases

  • Adding a new Suite
  • Listing Suites
  • Running All Suites
  • * Running Isolated Suite All Branches.
  • Running Isolated Suite, Single Suite Node, No Branches
  • Running Isolated Suite, Single Suite Node, Single TestCase
  • Running Isolated Suite, Single Suite Node, Single TestCase, Single Test

9. Class Skeletons



Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jan 27, 2008

    <p>I personally think the biggest problem with writing unit tests for the ZF involve classes with dependencies on database classes (the Zend_Db branch). The setup process in the Zend_Db tests is long and involved, and unnecessary for most scenarios - a much better solutions is to use mocks obviously.<br />
    It is still not a straightforward process, and for those new to unit testing might be a deterant to writing tests..</p>

    <p>I would very much like if such a unit testing master class has utility functions with such mocks (and partial mocks) prepared beforehand.</p>

  2. Mar 05, 2008

    <p>Do you really want to add your own component just for filtering by test suite? I think this would be an easy patch for the PHPUnit test suite and you are done, as PHPUnit does support filtering by test case today. I think there is already a ticket open for that in the PHPUnit trac but I can't find it anymore.<br />
    Also this is not true isolation. Isolation in the unit testing world means that every test (or even better: every test case) runs with its own scope (so in PHP in it's own process). This feature will be integrated in PHPUnit 4.0.</p>

  3. Apr 09, 2008

    <p><a class="external-link" href=""></a></p>