File indexing completed on 2025-02-23 05:32:49
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Test 0017 * @subpackage PHPUnit 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Db_Table_Abstract 0025 */ 0026 // require_once "Zend/Db/Table/Abstract.php"; 0027 0028 /** 0029 * Use a Zend_Db_Table for assertions with other PHPUnit Database Extension table types. 0030 * 0031 * @uses PHPUnit_Extensions_Database_DataSet_QueryTable 0032 * @category Zend 0033 * @package Zend_Test 0034 * @subpackage PHPUnit 0035 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0036 * @license http://framework.zend.com/license/new-bsd New BSD License 0037 */ 0038 class Zend_Test_PHPUnit_Db_DataSet_DbTable extends PHPUnit_Extensions_Database_DataSet_QueryTable 0039 { 0040 /** 0041 * Zend_Db_Table object 0042 * 0043 * @var Zend_Db_Table_Abstract 0044 */ 0045 protected $_table = null; 0046 0047 /** 0048 * @var array 0049 */ 0050 protected $_columns = array(); 0051 0052 /** 0053 * @var string 0054 */ 0055 protected $_where = null; 0056 0057 /** 0058 * @var string 0059 */ 0060 protected $_orderBy = null; 0061 0062 /** 0063 * @var string 0064 */ 0065 protected $_count = null; 0066 0067 /** 0068 * @var int 0069 */ 0070 protected $_offset = null; 0071 0072 /** 0073 * Construct Dataset Table from Zend_Db_Table object 0074 * 0075 * @param Zend_Db_Table_Abstract $table 0076 * @param string|Zend_Db_Select|null $where 0077 * @param string|null $order 0078 * @param int $count 0079 * @param int $offset 0080 */ 0081 public function __construct(Zend_Db_Table_Abstract $table, $where=null, $order=null, $count=null, $offset=null) 0082 { 0083 $this->tableName = $table->info('name'); 0084 $this->_columns = $table->info('cols'); 0085 0086 $this->_table = $table; 0087 $this->_where = $where; 0088 $this->_order = $order; 0089 $this->_count = $count; 0090 $this->_offset = $offset; 0091 } 0092 0093 /** 0094 * Lazy load data via table fetchAll() method. 0095 * 0096 * @return void 0097 */ 0098 protected function loadData() 0099 { 0100 if ($this->data === null) { 0101 $this->data = $this->_table->fetchAll( 0102 $this->_where, $this->_order, $this->_count, $this->_offset 0103 ); 0104 if($this->data instanceof Zend_Db_Table_Rowset_Abstract) { 0105 $this->data = $this->data->toArray(); 0106 } 0107 } 0108 } 0109 0110 /** 0111 * Create Table Metadata object 0112 */ 0113 protected function createTableMetaData() 0114 { 0115 if ($this->tableMetaData === NULL) { 0116 $this->loadData(); 0117 $this->tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($this->tableName, $this->_columns); 0118 } 0119 } 0120 }