*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Test / PHPUnit / Db / DataSet / DbTableDataSet.php
blobb5b2de0ab658b9e49a3f8573895e444b57c2ea86
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Test
17 * @subpackage PHPUnit
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: DbTableDataSet.php 16607 2009-07-09 21:51:46Z beberlei $
23 require_once "PHPUnit/Extensions/Database/DataSet/QueryDataSet.php";
25 require_once "PHPUnit/Extensions/Database/DB/IDatabaseConnection.php";
27 /**
28 * @see Zend_Test_PHPUnit_Db_DataSet_DbTable
30 require_once "Zend/Test/PHPUnit/Db/DataSet/DbTable.php";
32 /**
33 * Aggregate several Zend_Db_Table instances into a dataset.
35 * @uses Zend_Db_Table
36 * @category Zend
37 * @package Zend_Test
38 * @subpackage PHPUnit
39 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
40 * @license http://framework.zend.com/license/new-bsd New BSD License
42 class Zend_Test_PHPUnit_Db_DataSet_DbTableDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
44 /**
45 * @var array
47 protected $tables = array();
49 /**
50 * Add a Table dataset representation by specifiying an arbitrary select query.
52 * By default a select * will be done on the given tablename.
54 * @param Zend_Db_Table_Abstract $table
55 * @param string|Zend_Db_Select $query
56 * @param string $where
57 * @param string $order
58 * @param string $count
59 * @param string $offset
61 public function addTable(Zend_Db_Table_Abstract $table, $where = null, $order = null, $count = null, $offset = null)
63 $tableName = $table->info('name');
64 $this->tables[$tableName] = new Zend_Test_PHPUnit_Db_DataSet_DbTable($table, $where, $order, $count, $offset);
67 /**
68 * Creates an iterator over the tables in the data set. If $reverse is
69 * true a reverse iterator will be returned.
71 * @param bool $reverse
72 * @return PHPUnit_Extensions_Database_DB_TableIterator
74 protected function createIterator($reverse = FALSE)
76 return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse);
79 /**
80 * Returns a table object for the given table.
82 * @param string $tableName
83 * @return PHPUnit_Extensions_Database_DB_Table
85 public function getTable($tableName)
87 if (!isset($this->tables[$tableName])) {
88 throw new InvalidArgumentException("$tableName is not a table in the current database.");
91 return $this->tables[$tableName];
94 /**
95 * Returns a list of table names for the database
97 * @return Array
99 public function getTableNames()
101 return array_keys($this->tables);