TestSetup.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 ZendX
  16. * @package ZendX_Db
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: TestSetup.php 4791 2007-05-12 23:54:20Z bkarwin $
  21. */
  22. /**
  23. * @see ZendX_Db_TestSetup
  24. */
  25. require_once 'ZendX/Db/TestSetup.php';
  26. PHPUnit_Util_Filter::addFileToFilter(__FILE__);
  27. /**
  28. * @category ZendX
  29. * @package ZendX_Db
  30. * @subpackage UnitTests
  31. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. abstract class ZendX_Db_Table_TestSetup extends Zend_Db_TestSetup
  35. {
  36. /**
  37. * @var array of Zend_Db_Table_Abstract
  38. */
  39. protected $_table = array();
  40. public function setUp()
  41. {
  42. parent::setUp();
  43. $this->_table['accounts'] = $this->_getTable('Zend_Db_Table_TableAccounts');
  44. $this->_table['bugs'] = $this->_getTable('Zend_Db_Table_TableBugs');
  45. $this->_table['bugs_products'] = $this->_getTable('Zend_Db_Table_TableBugsProducts');
  46. $this->_table['products'] = $this->_getTable('Zend_Db_Table_TableProducts');
  47. }
  48. protected function _getTable($tableClass, $options = array())
  49. {
  50. if (is_array($options) && !isset($options['db'])) {
  51. $options['db'] = $this->_db;
  52. }
  53. Zend_Loader::loadClass($tableClass);
  54. $table = new $tableClass($options);
  55. return $table;
  56. }
  57. }