<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.test.phpunit.db" xmlns:xi="http://www.w3.org/2001/XInclude">
    <title>Zend_Test_PHPUnit_Db</title>

    <para>
        Coupling of data-access and the domain model often requires the use of a database for
        testing purposes. But the database is persistent across different tests which leads to
        test results that can affect each other. Furthermore setting up the database to be able to
        run a test is quite some work. PHPUnit's Database extension simplifies testing with a
        database by offering a very simple mechanism to set up and teardown the database between
        different tests. This component extends the PHPUnit Database extension with Zend Framework
        specific code, such that writing database tests against a Zend Framework application is
        simplified.
    </para>

    <para>
        Database Testing can be explained with two conceptual entities, DataSets and DataTables.
        Internally the PHPUnit Database extension can build up an object structure of a database,
        its tables and containing rows from configuration files or the real database content. This
        abstract object graph can then be compared using assertions. A common use-case in database
        testing is setting up some tables with seed data, then performing some operations, and
        finally asserting that the operated on database-state is equal to some predefined expected
        state. <classname>Zend_Test_PHPUnit_Db</classname> simplifies this task by allowing to
        generate DataSets and DataTables from existing <classname>Zend_Db_Table_Abstract</classname>
        or <classname>Zend_Db_Table_Rowset_Abstract</classname> instances.
    </para>

    <para>
        Furthermore this component allows to integrate any
        <classname>Zend_Db_Adapter_Abstract</classname> for testing whereas the original extension
        only works with <acronym>PDO</acronym>. A Test Adapter implementation for
        <classname>Zend_Db_Adapter_Abstract</classname> is also included in this component. It
        allows to instantiate a Db Adapter that requires no database at all and acts as an
        <acronym>SQL</acronym> and result stack which is used by the <acronym>API</acronym> methods.
    </para>

    <xi:include href="Zend_Test-PHPUnit-Db-Quickstart.xml" />
    <xi:include href="Zend_Test-PHPUnit-Db-Testing.xml" />
    <xi:include href="Zend_Test-PHPUnit-Db-Adapter.xml" />
</sect1>
