Zend_Test-PHPUnit-Db.xml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 16914 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.test.phpunit.db" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <title>Zend_Test_PHPUnit_Db</title>
  6. <para>
  7. Coupling of data-access and the domain model often requires the use of a database for
  8. testing purposes. But the database is persistet accross different tests which leads to
  9. test results that can affect each other. Furthermore setting up the database to be able to
  10. run a test is quite some work. PHPUnit's Database extension simplifies testing with a
  11. database by offering a very simple mechanism to setup and teardown the database between
  12. different tests. This component extends the PHPUnit Database extension with Zend Framework
  13. specific code, such that writing database tests against a Zend Framework application is
  14. simplified.
  15. </para>
  16. <para>
  17. Database Testing can be explained with two conceptual entities, DataSets and DataTables.
  18. Internally the PHPUnit Database extension can build up an object structure of a database,
  19. its tables and containing rows from configuration files or the real database content. This
  20. abstract object graph can then be compared using assertions. A common use-case in database
  21. testing is setting up some tables with seed data, then performing some operations, and
  22. finally asserting that the operated on database-state is equal to some predefined expected
  23. state. <classname>Zend_Test_PHPUnit_Db</classname> simplifies this task by allowing to
  24. generate DataSets and DataTables from existing <classname>Zend_Db_Table_Abstract</classname>
  25. or <classname>Zend_Db_Table_Rowset_Abstract</classname> instances.
  26. </para>
  27. <para>
  28. Furthermore this component allows to integrate any
  29. <classname>Zend_Db_Adapter_Abstract</classname> for testing wheras the original extension
  30. only works with <classname>PDO</classname>. A Test Adapter implementation for
  31. <classname>Zend_Db_Adapter_Abstract</classname> is also included in this component. It
  32. allows to instantiate a Db Adapter that requires no database at all and acts as an SQL and
  33. result stack which is used by the API methods.
  34. </para>
  35. <xi:include href="Zend_Test-PHPUnit-Db-Quickstart.xml" />
  36. <xi:include href="Zend_Test-PHPUnit-Db-Testing.xml" />
  37. <xi:include href="Zend_Test-PHPUnit-Db-Adapter.xml" />
  38. </sect1>