Zend_Test-PHPUnit-Db.xml 2.5 KB

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