You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2008/06/06 16:56:03 UTC
svn commit: r663970 [2/25] - in /incubator/shindig/trunk/php: ./ test/
test/PHPUnit/ test/PHPUnit/Extensions/ test/PHPUnit/Extensions/Database/
test/PHPUnit/Extensions/Database/Constraint/
test/PHPUnit/Extensions/Database/DB/ test/PHPUnit/Extensions/Da...
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/MySQL.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/MySQL.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/MySQL.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/MySQL.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,69 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id:InformationSchema.php 1254 2008-09-02 04:36:15Z mlively $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+require_once '../PHPUnit/Extensions/Database/DB/MetaData/InformationSchema.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides functionality to retrieve meta data from a database with information_schema support.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DB_MetaData_MySQL extends PHPUnit_Extensions_Database_DB_MetaData_InformationSchema
+{
+ protected $schemaObjectQuoteChar = '`';
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Oci.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Oci.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Oci.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Oci.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,159 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Trond Hansen <tr...@xait.no>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Oci.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.3
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+require_once '../PHPUnit/Extensions/Database/DB/MetaData.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides functionality to retrieve meta data from an Oracle database.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Trond Hansen <tr...@xait.no>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.3
+ */
+class PHPUnit_Extensions_Database_DB_MetaData_Oci extends PHPUnit_Extensions_Database_DB_MetaData
+{
+ protected $columns = array();
+ protected $keys = array();
+
+ /**
+ * Returns an array containing the names of all the tables in the database.
+ *
+ * @return array
+ */
+ public function getTableNames()
+ {
+ $tableNames = array();
+
+ $query = "SELECT table_name
+ FROM cat
+ WHERE table_type='TABLE'
+ ORDER BY table_name";
+
+ $result = $this->pdo->query($query);
+
+ while ($tableName = $result->fetchColumn(0)) {
+ $tableNames[] = $tableName;
+ }
+
+ return $tableNames;
+ }
+
+ /**
+ * Returns an array containing the names of all the columns in the
+ * $tableName table,
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTableColumns($tableName)
+ {
+ if (!isset($this->columns[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->columns[$tableName];
+ }
+
+ /**
+ * Returns an array containing the names of all the primary key columns in
+ * the $tableName table.
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTablePrimaryKeys($tableName)
+ {
+ if (!isset($this->keys[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->keys[$tableName];
+ }
+
+ /**
+ * Loads column info from a oracle database.
+ *
+ * @param string $tableName
+ */
+ protected function loadColumnInfo($tableName)
+ {
+ $this->columns[$tableName] = array();
+ $this->keys[$tableName] = array();
+
+ $query = "SELECT DISTINCT COLUMN_NAME
+ FROM USER_TAB_COLUMNS
+ WHERE TABLE_NAME='".$tableName."'
+ ORDER BY COLUMN_NAME";
+
+ $result = $this->pdo->query($query);
+
+ while ($columnName = $result->fetchColumn(0)) {
+ $this->columns[$tableName][] = $columnName;
+ }
+
+ $keyQuery = "SELECT b.column_name
+ FROM all_constraints a, all_cons_columns b
+ WHERE a.constraint_type='P'
+ AND a.constraint_name=b.constraint_name
+ AND a.table_name = '".$tableName."' ";
+
+ $result = $this->pdo->query($keyQuery);
+
+ while ($columnName = $result->fetchColumn(0)) {
+ $this->keys[$tableName][] = $columnName;
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Sqlite.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Sqlite.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Sqlite.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/MetaData/Sqlite.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,151 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id:Sqlite.php 1254 2008-09-02 04:36:15Z mlively $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+require_once '../PHPUnit/Extensions/Database/DB/MetaData.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides functionality to retrieve meta data from a sqlite database.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DB_MetaData_Sqlite extends PHPUnit_Extensions_Database_DB_MetaData
+{
+
+ protected $columns = array();
+
+ protected $keys = array();
+
+ /**
+ * Returns an array containing the names of all the tables in the database.
+ *
+ * @return array
+ */
+ public function getTableNames()
+ {
+ $query = "
+ SELECT name
+ FROM sqlite_master
+ WHERE
+ type='table' AND
+ name <> 'sqlite_sequence'
+ ORDER BY name
+ ";
+
+ $result = $this->pdo->query($query);
+
+ while ($tableName = $result->fetchColumn(0)) {
+ $tableNames[] = $tableName;
+ }
+
+ return $tableNames;
+ }
+
+ /**
+ * Returns an array containing the names of all the columns in the
+ * $tableName table,
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTableColumns($tableName)
+ {
+ if (!isset($this->columns[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->columns[$tableName];
+ }
+
+ /**
+ * Returns an array containing the names of all the primary key columns in
+ * the $tableName table.
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTablePrimaryKeys($tableName)
+ {
+ if (!isset($this->keys[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->keys[$tableName];
+ }
+
+ /**
+ * Loads column info from a sqlite database.
+ *
+ * @param string $tableName
+ */
+ protected function loadColumnInfo($tableName)
+ {
+ $query = "PRAGMA table_info('{$tableName}')";
+ $statement = $this->pdo->query($query);
+
+ /* @var $statement PDOStatement */
+ $this->columns[$tableName] = array();
+ $this->keys[$tableName] = array();
+ while ($columnData = $statement->fetch(PDO::FETCH_NUM)) {
+ $this->columns[$tableName][] = $columnData[1];
+
+ if ($columnData[5] == 1) {
+ $this->keys[$tableName][] = $columnData[1];
+ }
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/ResultSetTable.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/ResultSetTable.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/ResultSetTable.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/ResultSetTable.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,89 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: ResultSetTable.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractTable.php';
+
+/**
+ * Provides the functionality to represent a database result set as a DBUnit
+ * table.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DB_ResultSetTable extends PHPUnit_Extensions_Database_DataSet_AbstractTable
+{
+
+ /**
+ * Creates a new result set table.
+ *
+ * @param string $tableName
+ * @param PDOStatement $pdoStatement
+ */
+ public function __construct($tableName, PDOStatement $pdoStatement)
+ {
+ $this->data = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
+
+ if (count($this->data)) {
+ $columns = array_keys($this->data[0]);
+ } else {
+ $columns = array();
+ }
+
+ $this->setTableMetaData(new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns));
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/Table.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/Table.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/Table.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/Table.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,84 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Table.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractTable.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides the functionality to represent a database table.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DB_Table extends PHPUnit_Extensions_Database_DataSet_AbstractTable
+{
+
+ /**
+ * Creates a new database table object.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
+ */
+ public function __construct(PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData, PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection)
+ {
+ $this->setTableMetaData($tableMetaData);
+
+ $pdoStatement = $databaseConnection->getConnection()->prepare(PHPUnit_Extensions_Database_DB_DataSet::buildTableSelect($tableMetaData));
+ $pdoStatement->execute();
+ $this->data = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableIterator.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableIterator.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableIterator.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableIterator.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,176 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: TableIterator.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/ITableIterator.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides iterative access to tables from a database instance.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DB_TableIterator implements PHPUnit_Extensions_Database_DataSet_ITableIterator
+{
+
+ /**
+ * An array of tablenames.
+ *
+ * @var Array
+ */
+ protected $tableNames;
+
+ /**
+ * If this property is true then the tables will be iterated in reverse
+ * order.
+ *
+ * @var bool
+ */
+ protected $reverse;
+
+ /**
+ * The database dataset that this iterator iterates over.
+ *
+ * @var PHPUnit_Extensions_Database_DB_DataSet
+ */
+ protected $dataSet;
+
+ public function __construct($tableNames, PHPUnit_Extensions_Database_DB_DataSet $dataSet, $reverse = false)
+ {
+ $this->tableNames = $tableNames;
+ $this->dataSet = $dataSet;
+ $this->reverse = $reverse;
+
+ $this->rewind();
+ }
+
+ /**
+ * Returns the current table.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function getTable()
+ {
+ $this->current();
+ }
+
+ /**
+ * Returns the current table's meta data.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ public function getTableMetaData()
+ {
+ $this->current()->getTableMetaData();
+ }
+
+ /**
+ * Returns the current table.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function current()
+ {
+ $tableName = current($this->tableNames);
+ return $this->dataSet->getTable($tableName);
+ }
+
+ /**
+ * Returns the name of the current table.
+ *
+ * @return string
+ */
+ public function key()
+ {
+ return $this->current()->getTableMetaData()->getTableName();
+ }
+
+ /**
+ * advances to the next element.
+ *
+ */
+ public function next()
+ {
+ if ($this->reverse) {
+ prev($this->tableNames);
+ } else {
+ next($this->tableNames);
+ }
+ }
+
+ /**
+ * Rewinds to the first element
+ */
+ public function rewind()
+ {
+ if ($this->reverse) {
+ end($this->tableNames);
+ } else {
+ reset($this->tableNames);
+ }
+ }
+
+ /**
+ * Returns true if the current index is valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return (current($this->tableNames) !== false);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableMetaData.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableMetaData.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableMetaData.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DB/TableMetaData.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,75 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: TableMetaData.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+require_once '../PHPUnit/Extensions/Database/DataSet/DefaultTableMetaData.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * This class loads a table metadata object with database metadata.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DB_TableMetaData extends PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData
+{
+
+ public function __construct($tableName, PHPUnit_Extensions_Database_DB_IMetaData $databaseMetaData)
+ {
+ $this->tableName = $tableName;
+ $this->columns = $databaseMetaData->getTableColumns($tableName);
+ $this->primaryKeys = $databaseMetaData->getTablePrimaryKeys($tableName);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,178 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: AbstractDataSet.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/IDataSet.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Implements the basic functionality of data sets.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+abstract class PHPUnit_Extensions_Database_DataSet_AbstractDataSet implements PHPUnit_Extensions_Database_DataSet_IDataSet
+{
+
+ /**
+ * Creates an iterator over the tables in the data set. If $reverse is
+ * true a reverse iterator will be returned.
+ *
+ * @param bool $reverse
+ * @return PHPUnit_Extensions_Database_DataSet_ITableIterator
+ */
+ protected abstract function createIterator($reverse = false);
+
+ /**
+ * Returns an array of table names contained in the dataset.
+ *
+ * @return array
+ */
+ public function getTableNames()
+ {
+ $tableNames = array();
+
+ foreach ($this->getIterator() as $table) {
+ /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
+ $tableNames[] = $table->getTableMetaData()->getTableName();
+ }
+
+ return $tableNames;
+ }
+
+ /**
+ * Returns a table meta data object for the given table.
+ *
+ * @param string $tableName
+ * @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ public function getTableMetaData($tableName)
+ {
+ return $this->getTable($tableName)->getTableMetaData();
+ }
+
+ /**
+ * Returns a table object for the given table.
+ *
+ * @param string $tableName
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function getTable($tableName)
+ {
+ foreach ($this->getIterator() as $table) {
+ /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
+ if ($table->getTableMetaData()->getTableName() == $tableName) {
+ return $table;
+ }
+ }
+ }
+
+ /**
+ * Returns an iterator for all table objects in the given dataset.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableIterator
+ */
+ public function getIterator()
+ {
+ return $this->createIterator();
+ }
+
+ /**
+ * Returns a reverse iterator for all table objects in the given dataset.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableIterator
+ */
+ public function getReverseIterator()
+ {
+ return $this->createIterator(true);
+ }
+
+ /**
+ * Asserts that the given data set matches this data set.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $other
+ */
+ public function assertEquals(PHPUnit_Extensions_Database_DataSet_IDataSet $other)
+ {
+ $thisTableNames = $this->getTableNames();
+ $otherTableNames = $other->getTableNames();
+
+ sort($thisTableNames);
+ sort($otherTableNames);
+
+ if ($thisTableNames != $otherTableNames) {
+ throw new Exception("Expected following tables: " . implode(', ', $thisTableNames) . "; has columns: " . implode(', ', $otherTableNames));
+ }
+
+ foreach ($thisTableNames as $tableName) {
+ $this->getTable($tableName)->assertEquals($other->getTable($tableName));
+ }
+
+ return TRUE;
+ }
+
+ public function __toString()
+ {
+ $iterator = $this->getIterator();
+
+ $dataSetString = '';
+ foreach ($iterator as $table) {
+ $dataSetString .= $table->__toString();
+ }
+
+ return $dataSetString;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTable.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTable.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTable.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTable.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,198 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: AbstractTable.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/ITable.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides a basic functionality for dbunit tables
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DataSet_AbstractTable implements PHPUnit_Extensions_Database_DataSet_ITable
+{
+
+ /**
+ * @var PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ protected $tableMetaData;
+
+ /**
+ * A 2-dimensional array containing the data for this table.
+ *
+ * @var array
+ */
+ protected $data;
+
+ /**
+ * Sets the metadata for this table.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData
+ */
+ protected function setTableMetaData(PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData)
+ {
+ $this->tableMetaData = $tableMetaData;
+ }
+
+ /**
+ * Returns the table's meta data.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ public function getTableMetaData()
+ {
+ return $this->tableMetaData;
+ }
+
+ /**
+ * Returns the number of rows in this table.
+ *
+ * @return int
+ */
+ public function getRowCount()
+ {
+ return count($this->data);
+ }
+
+ /**
+ * Returns the value for the given column on the given row.
+ *
+ * @param int $row
+ * @param int $column
+ * @todo reorganize this function to throw the exception first.
+ */
+ public function getValue($row, $column)
+ {
+ if (isset($this->data[$row][$column])) {
+ return (string)$this->data[$row][$column];
+ } else {
+ if (!in_array($column, $this->getTableMetaData()->getColumns()) || $this->getRowCount() <= $row) {
+ throw new InvalidArgumentException("The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}");
+ } else {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Asserts that the given table matches this table.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $other
+ */
+ public function assertEquals(PHPUnit_Extensions_Database_DataSet_ITable $other)
+ {
+ $thisMetaData = $this->getTableMetaData();
+ $otherMetaData = $other->getTableMetaData();
+
+ $thisMetaData->assertEquals($otherMetaData);
+
+ if ($this->getRowCount() != $other->getRowCount()) {
+ throw new Exception("Expected row count of {$this->getRowCount()}, has a row count of {$other->getRowCount()}");
+ }
+
+ $columns = $thisMetaData->getColumns();
+ for ($i = 0; $i < $this->getRowCount(); $i++) {
+ foreach ($columns as $columnName) {
+ if ($this->getValue($i, $columnName) != $other->getValue($i, $columnName)) {
+ throw new Exception("Expected value of {$this->getValue($i, $columnName)} for row {$i} column {$columnName}, has a value of {$other->getValue($i, $columnName)}");
+ }
+ }
+ }
+
+ return TRUE;
+ }
+
+ public function __toString()
+ {
+ $columns = $this->getTableMetaData()->getColumns();
+
+ $lineSeperator = str_repeat('+----------------------', count($columns)) . "+\n";
+ $lineLength = strlen($lineSeperator) - 1;
+
+ $tableString = $lineSeperator;
+ $tableString .= '| ' . str_pad($this->getTableMetaData()->getTableName(), $lineLength - 4, ' ', STR_PAD_RIGHT) . " |\n";
+ $tableString .= $lineSeperator;
+ $tableString .= $this->rowToString($columns);
+ $tableString .= $lineSeperator;
+
+ for ($i = 0; $i < $this->getRowCount(); $i++) {
+ $values = array();
+ foreach ($columns as $columnName) {
+ $values[] = $this->getValue($i, $columnName);
+ }
+
+ $tableString .= $this->rowToString($values);
+ $tableString .= $lineSeperator;
+ }
+
+ return "\n" . $tableString . "\n";
+ }
+
+ protected function rowToString(Array $row)
+ {
+ $rowString = '';
+ foreach ($row as $value) {
+ if (is_null($value)) {
+ $value = 'NULL';
+ }
+ $rowString .= '| ' . str_pad(substr($value, 0, 20), 20, ' ', STR_PAD_BOTH) . ' ';
+ }
+
+ return $rowString . "|\n";
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTableMetaData.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTableMetaData.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTableMetaData.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractTableMetaData.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,136 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: AbstractTableMetaData.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/ITableMetaData.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides basic functionality for table meta data.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+abstract class PHPUnit_Extensions_Database_DataSet_AbstractTableMetaData implements PHPUnit_Extensions_Database_DataSet_ITableMetaData
+{
+
+ /**
+ * The names of all columns in the table.
+ *
+ * @var Array
+ */
+ protected $columns;
+
+ /**
+ * The names of all the primary keys in the table.
+ *
+ * @var Array
+ */
+ protected $primaryKeys;
+
+ /**
+ * @var string
+ */
+ protected $tableName;
+
+ /**
+ * Returns the names of the columns in the table.
+ *
+ * @return array
+ */
+ public function getColumns()
+ {
+ return $this->columns;
+ }
+
+ /**
+ * Returns the names of the primary key columns in the table.
+ *
+ * @return array
+ */
+ public function getPrimaryKeys()
+ {
+ return $this->primaryKeys;
+ }
+
+ /**
+ * Returns the name of the table.
+ *
+ * @return string
+ */
+ public function getTableName()
+ {
+ return $this->tableName;
+ }
+
+ /**
+ * Asserts that the given tableMetaData matches this tableMetaData.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $other
+ */
+ public function assertEquals(PHPUnit_Extensions_Database_DataSet_ITableMetaData $other)
+ {
+ if ($this->getTableName() != $other->getTableName()) {
+ throw new Exception("Expected table name of {$this->getTableName()}, has a name of {$other->getTableName()}");
+ }
+
+ if ($this->getColumns() != $other->getColumns()) {
+ throw new Exception("Expected following columns: " . implode(', ', $this->getColumns()) . "; has columns: " . implode(', ', $other->getColumns()));
+ }
+
+ return TRUE;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractXmlDataSet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractXmlDataSet.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractXmlDataSet.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/AbstractXmlDataSet.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,150 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: AbstractXmlDataSet.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php';
+require_once '../PHPUnit/Extensions/Database/DataSet/DefaultTableIterator.php';
+require_once '../PHPUnit/Extensions/Database/DataSet/DefaultTableMetaData.php';
+require_once '../PHPUnit/Extensions/Database/DataSet/DefaultTable.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * The default implementation of a data set.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+abstract class PHPUnit_Extensions_Database_DataSet_AbstractXmlDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
+{
+
+ /**
+ * @var array
+ */
+ protected $tables;
+
+ /**
+ * @var SimpleXmlElement
+ */
+ protected $xmlFileContents;
+
+ /**
+ * Creates a new dataset using the given tables.
+ *
+ * @param array $tables
+ */
+ public function __construct($xmlFile)
+ {
+ if (!is_file($xmlFile)) {
+ throw new InvalidArgumentException("Could not find xml file: {$xmlFile}");
+ }
+ $this->xmlFileContents = @simplexml_load_file($xmlFile);
+
+ if ($this->xmlFileContents === FALSE) {
+ throw new InvalidArgumentException("File is not valid xml: {$xmlFile}");
+ }
+
+ $tableColumns = array();
+ $tableValues = array();
+
+ $this->getTableInfo($tableColumns, $tableValues);
+ $this->createTables($tableColumns, $tableValues);
+ }
+
+ /**
+ * Reads the simple xml object and creates the appropriate tables and meta
+ * data for this dataset.
+ */
+ protected abstract function getTableInfo(Array &$tableColumns, Array &$tableValues);
+
+ protected function createTables(Array &$tableColumns, Array &$tableValues)
+ {
+ foreach ($tableValues as $tableName => $values) {
+ $table = $this->getOrCreateTable($tableName, $tableColumns[$tableName]);
+ foreach ($values as $value) {
+ $table->addRow($value);
+ }
+ }
+ }
+
+ /**
+ * Returns the table with the matching name. If the table does not exist
+ * an empty one is created.
+ *
+ * @param string $tableName
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ protected function getOrCreateTable($tableName, $tableColumns)
+ {
+ if (empty($this->tables[$tableName])) {
+ $tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $tableColumns);
+ $this->tables[$tableName] = new PHPUnit_Extensions_Database_DataSet_DefaultTable($tableMetaData);
+ }
+
+ return $this->tables[$tableName];
+ }
+
+ /**
+ * Creates an iterator over the tables in the data set. If $reverse is
+ * true a reverse iterator will be returned.
+ *
+ * @param bool $reverse
+ * @return PHPUnit_Extensions_Database_DataSet_ITableIterator
+ */
+ protected function createIterator($reverse = false)
+ {
+ return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DataSetFilter.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DataSetFilter.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DataSetFilter.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DataSetFilter.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,144 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: DataSetFilter.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php';
+require_once '../PHPUnit/Extensions/Database/DataSet/TableFilter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A dataset decorator that allows filtering out tables and table columns from
+ * results.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DataSet_DataSetFilter extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
+{
+
+ /**
+ * The dataset being decorated.
+ * @var PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ protected $originalDataSet;
+
+ /**
+ * The tables to exclude from the data set.
+ * @var Array
+ */
+ protected $excludeTables;
+
+ /**
+ * The columns to exclude from the data set.
+ * @var Array
+ */
+ protected $excludeColumns;
+
+ /**
+ * Creates a new filtered data set.
+ *
+ * The $exclude tables should be an associative array using table names as
+ * the key and an array of column names to exclude for the value. If you
+ * would like to exclude a full table set the value of the table's entry
+ * to the special string '*'.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $originalDataSet
+ * @param Array $excludeTables
+ */
+ public function __construct(PHPUnit_Extensions_Database_DataSet_IDataSet $originalDataSet, Array $excludeTables)
+ {
+ $this->originalDataSet = $originalDataSet;
+ $this->excludeTables = $excludeTables;
+
+ foreach ($this->excludeTables as $tableName => $values) {
+ if (is_array($values)) {
+ $this->excludeColumns[$tableName] = $values;
+ } elseif ($values == '*') {
+ $this->excludeTables[] = $tableName;
+ } else {
+ $this->excludeColumns[$tableName] = (array)$values;
+ }
+ }
+ }
+
+ /**
+ * Creates an iterator over the tables in the data set. If $reverse is
+ * true a reverse iterator will be returned.
+ *
+ * @param bool $reverse
+ * @return PHPUnit_Extensions_Database_DataSet_ITableIterator
+ */
+ protected function createIterator($reverse = false)
+ {
+ $original_tables = $this->originalDataSet->getIterator($reverse);
+ $new_tables = array();
+
+ foreach ($original_tables as $table) {
+ /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
+ $tableName = $table->getTableMetaData()->getTableName();
+
+ if (in_array($tableName, $this->excludeTables)) {
+ continue;
+ } elseif (array_key_exists($tableName, $this->excludeColumns)) {
+ $new_tables[] = new PHPUnit_Extensions_Database_DataSet_TableFilter($table, $this->excludeColumns[$tableName]);
+ } else {
+ $new_tables[] = $table;
+ }
+ }
+
+ return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($new_tables);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultDataSet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultDataSet.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultDataSet.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultDataSet.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,109 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: DefaultDataSet.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractDataSet.php';
+require_once '../PHPUnit/Extensions/Database/DataSet/DefaultTableIterator.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * The default implementation of a data set.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DataSet_DefaultDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
+{
+
+ /**
+ * An array of ITable objects.
+ *
+ * @var array
+ */
+ protected $tables;
+
+ /**
+ * Creates a new dataset using the given tables.
+ *
+ * @param array $tables
+ */
+ public function __construct(Array $tables = array())
+ {
+ $this->tables = $tables;
+ }
+
+ /**
+ * Adds a table to the dataset.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $table
+ */
+ public function addTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
+ {
+ $this->tables[] = $table;
+ }
+
+ /**
+ * Creates an iterator over the tables in the data set. If $reverse is
+ * true a reverse iterator will be returned.
+ *
+ * @param bool $reverse
+ * @return PHPUnit_Extensions_Database_DataSet_ITableIterator
+ */
+ protected function createIterator($reverse = false)
+ {
+ return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTable.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTable.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTable.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTable.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,124 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: DefaultTable.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractTable.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Provides default table functionality.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DataSet_DefaultTable extends PHPUnit_Extensions_Database_DataSet_AbstractTable
+{
+
+ /**
+ * Creates a new table object using the given $tableMetaData
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData
+ */
+ public function __construct(PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData)
+ {
+ $this->setTableMetaData($tableMetaData);
+ $this->data = array();
+ }
+
+ /**
+ * Adds a row to the table with optional values.
+ *
+ * @param array $values
+ */
+ public function addRow($values = array())
+ {
+ $columnNames = $this->getTableMetaData()->getColumns();
+ $this->data[] = array_merge(array_fill_keys($columnNames, null), $values);
+ }
+
+ /**
+ * Adds the rows in the passed table to the current table.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $table
+ */
+ public function addTableRows(PHPUnit_Extensions_Database_DataSet_ITable $table)
+ {
+ $tableColumns = $this->getTableMetaData()->getColumns();
+ for ($i = 0; $i < $table->getRowCount(); $i++) {
+ $newRow = array();
+ foreach ($tableColumns as $columnName) {
+ $newRow[$columnName] = $table->getValue($i, $columnName);
+ }
+ $this->addRow($newRow);
+ }
+ }
+
+ /**
+ * Sets the specified column of the specied row to the specified value.
+ *
+ * @param int $row
+ * @param string $column
+ * @param mixed $value
+ */
+ public function setValue($row, $column, $value)
+ {
+ if (isset($this->data[$row])) {
+ $this->data[$row][$column] = $value;
+ } else {
+ throw new InvalidArgumentException("The row given does not exist.");
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableIterator.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableIterator.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableIterator.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableIterator.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,173 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: DefaultTableIterator.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/ITableIterator.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * The default table iterator
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DataSet_DefaultTableIterator implements PHPUnit_Extensions_Database_DataSet_ITableIterator
+{
+
+ /**
+ * An array of tables in the iterator.
+ *
+ * @var Array
+ */
+ protected $tables;
+
+ /**
+ * If this property is true then the tables will be iterated in reverse
+ * order.
+ *
+ * @var bool
+ */
+ protected $reverse;
+
+ /**
+ * Creates a new default table iterator object.
+ *
+ * @param array $tables
+ * @param bool $reverse
+ */
+ public function __construct(Array $tables, $reverse = false)
+ {
+ $this->tables = $tables;
+ $this->reverse = $reverse;
+
+ $this->rewind();
+ }
+
+ /**
+ * Returns the current table.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function getTable()
+ {
+ $this->current();
+ }
+
+ /**
+ * Returns the current table's meta data.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ public function getTableMetaData()
+ {
+ $this->current()->getTableMetaData();
+ }
+
+ /**
+ * Returns the current table.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function current()
+ {
+ return current($this->tables);
+ }
+
+ /**
+ * Returns the name of the current table.
+ *
+ * @return string
+ */
+ public function key()
+ {
+ return $this->current()->getTableMetaData()->getTableName();
+ }
+
+ /**
+ * advances to the next element.
+ *
+ */
+ public function next()
+ {
+ if ($this->reverse) {
+ prev($this->tables);
+ } else {
+ next($this->tables);
+ }
+ }
+
+ /**
+ * Rewinds to the first element
+ */
+ public function rewind()
+ {
+ if ($this->reverse) {
+ end($this->tables);
+ } else {
+ reset($this->tables);
+ }
+ }
+
+ /**
+ * Returns true if the current index is valid
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return ($this->current() !== false);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableMetaData.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableMetaData.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableMetaData.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/DefaultTableMetaData.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,91 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: DefaultTableMetaData.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractTableMetaData.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * The default implementation of table meta data
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData extends PHPUnit_Extensions_Database_DataSet_AbstractTableMetaData
+{
+
+ /**
+ * Creates a new default table meta data object.
+ *
+ * @param string $tableName
+ * @param array $columns
+ * @param array $primaryKeys
+ */
+ public function __construct($tableName, Array $columns, Array $primaryKeys = array())
+ {
+ $this->tableName = $tableName;
+ $this->columns = $columns;
+ $this->primaryKeys = array();
+
+ foreach ($primaryKeys as $columnName) {
+ if (!in_array($columnName, $this->columns)) {
+ throw new InvalidArgumentException("Primary key column passed that is not in the column list.");
+ } else {
+ $this->primaryKeys[] = $columnName;
+ }
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,94 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2008, Sebastian Bergmann <sb...@sebastian-bergmann.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: FlatXmlDataSet.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.0
+ */
+
+require_once '../PHPUnit/Framework.php';
+require_once '../PHPUnit/Util/Filter.php';
+
+require_once '../PHPUnit/Extensions/Database/DataSet/AbstractXmlDataSet.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * The default implementation of a data set.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Mike Lively <m...@digitalsandwich.com>
+ * @copyright 2008 Mike Lively <m...@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 3.2.9
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.0
+ */
+class PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractXmlDataSet
+{
+
+ protected function getTableInfo(Array &$tableColumns, Array &$tableValues)
+ {
+ if ($this->xmlFileContents->getName() != 'dataset') {
+ throw new Exception("The root element of a flat xml file must be called <dataset>");
+ }
+
+ foreach ($this->xmlFileContents->children() as $row) {
+ $tableName = $row->getName();
+
+ if (!isset($tableColumns[$tableName])) {
+ $tableColumns[$tableName] = array();
+ }
+
+ $values = array();
+ foreach ($row->attributes() as $name => $value) {
+ if (!in_array($name, $tableColumns[$tableName])) {
+ $tableColumns[$tableName][] = $name;
+ }
+
+ $values[$name] = $value;
+ }
+ $tableValues[$tableName][] = $values;
+ }
+ }
+}
+?>