SimpleTester.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Test
  17. * @subpackage PHPUnit
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Test_PHPUnit_Db_Operation_Truncate
  24. */
  25. require_once "Zend/Test/PHPUnit/Db/Operation/Truncate.php";
  26. /**
  27. * @see Zend_Test_PHPUnit_Db_Operation_Insert
  28. */
  29. require_once "Zend/Test/PHPUnit/Db/Operation/Insert.php";
  30. /**
  31. * Simple Tester for Database Tests when the Abstract Test Case cannot be used.
  32. *
  33. * @uses PHPUnit_Extensions_Database_DefaultTester
  34. * @category Zend
  35. * @package Zend_Test
  36. * @subpackage PHPUnit
  37. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  38. * @license http://framework.zend.com/license/new-bsd New BSD License
  39. */
  40. class Zend_Test_PHPUnit_Db_SimpleTester extends PHPUnit_Extensions_Database_DefaultTester
  41. {
  42. /**
  43. * Creates a new default database tester using the given connection.
  44. *
  45. * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
  46. */
  47. public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
  48. {
  49. if(!($connection instanceof Zend_Test_PHPUnit_Db_Connection)) {
  50. require_once "Zend/Test/PHPUnit/Db/Exception.php";
  51. throw new Zend_Test_PHPUnit_Db_Exception("Not a valid Zend_Test_PHPUnit_Db_Connection instance, ".get_class($connection)." given!");
  52. }
  53. $this->connection = $connection;
  54. $this->setUpOperation = new PHPUnit_Extensions_Database_Operation_Composite(array(
  55. new Zend_Test_PHPUnit_Db_Operation_Truncate(),
  56. new Zend_Test_PHPUnit_Db_Operation_Insert(),
  57. ));
  58. $this->tearDownOperation = PHPUnit_Extensions_Database_Operation_Factory::NONE();
  59. }
  60. /**
  61. * Set Up the database using the given Dataset and the SetUp strategy "Truncate, then Insert"
  62. *
  63. * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
  64. */
  65. public function setUpDatabase(PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
  66. {
  67. $this->setDataSet($dataSet);
  68. $this->onSetUp();
  69. }
  70. }