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 [3/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/DataSet/IDataSet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/IDataSet.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/IDataSet.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/IDataSet.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,104 @@
+<?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: IDataSet.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');
+
+/**
+ * Provides a basic interface for creating and reading data from 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
+ */
+interface PHPUnit_Extensions_Database_DataSet_IDataSet extends IteratorAggregate
+{
+
+ /**
+ * Returns an array of table names contained in the dataset.
+ *
+ * @return array
+ */
+ public function getTableNames();
+
+ /**
+ * Returns a table meta data object for the given table.
+ *
+ * @param string $tableName
+ * @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ public function getTableMetaData($tableName);
+
+ /**
+ * Returns a table object for the given table.
+ *
+ * @param string $tableName
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function getTable($tableName);
+
+ /**
+ * Returns a reverse iterator for all table objects in the given dataset.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableIterator
+ */
+ public function getReverseIterator();
+
+ /**
+ * 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);
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITable.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITable.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITable.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITable.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,96 @@
+<?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: ITable.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');
+
+/**
+ * Provides a basic interface for creating and reading data from 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
+ */
+interface PHPUnit_Extensions_Database_DataSet_ITable
+{
+
+ /**
+ * Returns the table's meta data.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ public function getTableMetaData();
+
+ /**
+ * Returns the number of rows in this table.
+ *
+ * @return int
+ */
+ public function getRowCount();
+
+ /**
+ * Returns the value for the given column on the given row.
+ *
+ * @param int $row
+ * @param int $column
+ */
+ public function getValue($row, $column);
+
+ /**
+ * Asserts that the given table matches this table.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $other
+ */
+ public function assertEquals(PHPUnit_Extensions_Database_DataSet_ITable $other);
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableIterator.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableIterator.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableIterator.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableIterator.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,81 @@
+<?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: ITableIterator.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');
+
+/**
+ * Provides a basic interface for creating and reading data from 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
+ */
+interface PHPUnit_Extensions_Database_DataSet_ITableIterator extends Iterator
+{
+
+ /**
+ * Returns the current table.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function getTable();
+
+ /**
+ * Returns the current table's meta data.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ public function getTableMetaData();
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableMetaData.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableMetaData.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableMetaData.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/ITableMetaData.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,95 @@
+<?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: ITableMetaData.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');
+
+/**
+ * Provides a basic interface for returning 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
+ */
+interface PHPUnit_Extensions_Database_DataSet_ITableMetaData
+{
+
+ /**
+ * Returns the names of the columns in the table.
+ *
+ * @return array
+ */
+ public function getColumns();
+
+ /**
+ * Returns the names of the primary key columns in the table.
+ *
+ * @return array
+ */
+ public function getPrimaryKeys();
+
+ /**
+ * Returns the name of the table.
+ *
+ * @return string
+ */
+ public function getTableName();
+
+ /**
+ * Asserts that the given tableMetaData matches this tableMetaData.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $other
+ */
+ public function assertEquals(PHPUnit_Extensions_Database_DataSet_ITableMetaData $other);
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableFilter.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableFilter.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableFilter.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableFilter.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,107 @@
+<?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: TableFilter.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';
+require_once '../PHPUnit/Extensions/Database/DataSet/TableMetaDataFilter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A table decorator that allows filtering out 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_TableFilter extends PHPUnit_Extensions_Database_DataSet_AbstractTable
+{
+
+ /**
+ * The table meta data being decorated.
+ * @var PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ protected $originalTable;
+
+ public function __construct(PHPUnit_Extensions_Database_DataSet_ITable $originalTable, Array $excludeColumns)
+ {
+ $this->originalTable = $originalTable;
+ $this->setTableMetaData(new PHPUnit_Extensions_Database_DataSet_TableMetaDataFilter($originalTable->getTableMetaData(), $excludeColumns));
+ }
+
+ /**
+ * Returns the number of rows in this table.
+ *
+ * @return int
+ */
+ public function getRowCount()
+ {
+ return $this->originalTable->getRowCount();
+ }
+
+ /**
+ * Returns the value for the given column on the given row.
+ *
+ * @param int $row
+ * @param int $column
+ */
+ public function getValue($row, $column)
+ {
+ if (in_array($column, $this->getTableMetaData()->getColumns())) {
+ return $this->originalTable->getValue($row, $column);
+ } else {
+ throw new InvalidArgumentException("The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}");
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableMetaDataFilter.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableMetaDataFilter.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableMetaDataFilter.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/TableMetaDataFilter.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,125 @@
+<?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: TableMetaDataFilter.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');
+
+/**
+ * A TableMetaData decorator that allows filtering out columns from another
+ * metaData object.
+ *
+ * @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_TableMetaDataFilter extends PHPUnit_Extensions_Database_DataSet_AbstractTableMetaData
+{
+
+ /**
+ * The table meta data being decorated.
+ * @var PHPUnit_Extensions_Database_DataSet_ITableMetaData
+ */
+ protected $originalMetaData;
+
+ /**
+ * The columns to exclude from the meta data.
+ * @var Array
+ */
+ protected $excludeColumns;
+
+ /**
+ * Creates a new filtered table meta data object filtering out
+ * $excludeColumns.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $originalMetaData
+ * @param array $excludeColumns
+ */
+ public function __construct(PHPUnit_Extensions_Database_DataSet_ITableMetaData $originalMetaData, Array $excludeColumns)
+ {
+ $this->originalMetaData = $originalMetaData;
+ $this->excludeColumns = $excludeColumns;
+ }
+
+ /**
+ * Returns the names of the columns in the table.
+ *
+ * @return array
+ */
+ public function getColumns()
+ {
+ return array_values(array_diff($this->originalMetaData->getColumns(), $this->excludeColumns));
+ }
+
+ /**
+ * Returns the names of the primary key columns in the table.
+ *
+ * @return array
+ */
+ public function getPrimaryKeys()
+ {
+ return $this->originalMetaData->getPrimaryKeys();
+ }
+
+ /**
+ * Returns the name of the table.
+ *
+ * @return string
+ */
+ public function getTableName()
+ {
+ return $this->originalMetaData->getTableName();
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/XmlDataSet.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/XmlDataSet.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/XmlDataSet.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DataSet/XmlDataSet.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,129 @@
+<?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: XmlDataSet.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_XmlDataSet 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->xpath('/dataset/table') as $tableElement) {
+ if (empty($tableElement['name'])) {
+ throw new Exception("Table elements must include a name attribute specifying the table name.");
+ }
+
+ $tableName = (string)$tableElement['name'];
+
+ if (!isset($tableColumns[$tableName])) {
+ $tableColumns[$tableName] = array();
+ }
+
+ if (!isset($tableValues[$tableName])) {
+ $tableValues[$tableName] = array();
+ }
+
+ $tableInstanceColumns = array();
+
+ foreach ($tableElement->xpath('./column') as $columnElement) {
+ $columnName = (string)$columnElement;
+ if (empty($columnName)) {
+ throw new Exception("column elements cannot be empty");
+ }
+
+ if (!in_array($columnName, $tableColumns[$tableName])) {
+ $tableColumns[$tableName][] = $columnName;
+ }
+
+ $tableInstanceColumns[] = $columnName;
+ }
+
+ foreach ($tableElement->xpath('./row') as $rowElement) {
+ $rowValues = array();
+ $index = 0;
+ foreach ($rowElement->children() as $columnValue) {
+ switch ($columnValue->getName()) {
+ case 'value':
+ $rowValues[$tableInstanceColumns[$index]] = (string)$columnValue;
+ $index++;
+ break;
+ case 'null':
+ $rowValues[$tableInstanceColumns[$index]] = null;
+ $index++;
+ break;
+ default:
+ throw new Exception("Unknown child in the a row element.");
+ }
+ }
+
+ $tableValues[$tableName][] = $rowValues;
+ }
+ }
+ }
+
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DefaultTester.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DefaultTester.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DefaultTester.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/DefaultTester.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,95 @@
+<?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:DefaultDatabaseTester.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/AbstractTester.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * This is the default implementation of the database tester. It receives its
+ * connection object from the constructor.
+ *
+ * @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_DefaultTester extends PHPUnit_Extensions_Database_AbstractTester
+{
+
+ /**
+ * @var PHPUnit_Extensions_Database_DB_IDatabaseConnection
+ */
+ protected $connection;
+
+ /**
+ * Creates a new default database tester using the given connection.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
+ */
+ public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $this->connection = $connection;
+ }
+
+ /**
+ * Returns the test database connection.
+ *
+ * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/ITester.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/ITester.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/ITester.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/ITester.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,128 @@
+<?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:IDatabaseTester.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';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * This is the interface for DatabaseTester objects. These objects are used to
+ * add database testing to existing test cases using composition instead of
+ * extension.
+ *
+ * @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
+ */
+interface PHPUnit_Extensions_Database_ITester
+{
+
+ /**
+ * Closes the specified connection.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
+ */
+ public function closeConnection(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection);
+
+ /**
+ * Returns the test database connection.
+ *
+ * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
+ */
+ public function getConnection();
+
+ /**
+ * Returns the test dataset.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ public function getDataSet();
+
+ /**
+ * TestCases must call this method inside setUp().
+ */
+ public function onSetUp();
+
+ /**
+ * TestCases must call this method inside teadDown().
+ */
+ public function onTearDown();
+
+ /**
+ * Sets the test dataset to use.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
+ */
+ public function setDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet);
+
+ /**
+ * Sets the schema value.
+ *
+ * @param string $schema
+ */
+ public function setSchema($schema);
+
+ /**
+ * Sets the DatabaseOperation to call when starting the test.
+ *
+ * @param PHPUnit_Extensions_Database_Operation_DatabaseOperation $setUpOperation
+ */
+ public function setSetUpOperation(PHPUnit_Extensions_Database_Operation_IDatabaseOperation $setUpOperation);
+
+ /**
+ * Sets the DatabaseOperation to call when starting the test.
+ *
+ * @param PHPUnit_Extensions_Database_Operation_DatabaseOperation $tearDownOperation
+ */
+ public function setTearDownOperation(PHPUnit_Extensions_Database_Operation_IDatabaseOperation $tearDownOperation);
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Composite.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Composite.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Composite.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Composite.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,106 @@
+<?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: Composite.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/Operation/IDatabaseOperation.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Exception.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * This class facilitates combining database operations. To create a composite
+ * operation pass an array of classes that implement
+ * PHPUnit_Extensions_Database_Operation_IDatabaseOperation and they will be
+ * executed in that order against all 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
+ */
+class PHPUnit_Extensions_Database_Operation_Composite implements PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+{
+
+ /**
+ * @var array
+ */
+ protected $operations = array();
+
+ /**
+ * Creates a composite operation.
+ *
+ * @param array $operations
+ */
+ public function __construct(Array $operations)
+ {
+ foreach ($operations as $operation) {
+ if ($operation instanceof PHPUnit_Extensions_Database_Operation_IDatabaseOperation) {
+ $this->operations[] = $operation;
+ } else {
+ throw new InvalidArgumentException("Only database operation instances can be passed to a composite database operation.");
+ }
+ }
+ }
+
+ public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
+ {
+ try {
+ foreach ($this->operations as $operation) {
+ /* @var $operation PHPUnit_Extensions_Database_Operation_IDatabaseOperation */
+ $operation->execute($connection, $dataSet);
+ }
+ } catch (PHPUnit_Extensions_Database_Operation_Exception $e) {
+ throw new PHPUnit_Extensions_Database_Operation_Exception("COMPOSITE[{$e->getOperation()}]", $e->getQuery(), $e->getArgs(), $e->getTable(), $e->getError());
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Delete.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Delete.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Delete.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Delete.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,96 @@
+<?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: Delete.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/Operation/IDatabaseOperation.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Exception.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Deletes the rows in a given dataset using primary key columns.
+ *
+ * @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_Operation_Delete extends PHPUnit_Extensions_Database_Operation_RowBased
+{
+
+ protected $operationName = 'DELETE';
+
+ protected function buildOperationQuery(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $keys = $databaseTableMetaData->getPrimaryKeys();
+
+ $whereStatement = 'WHERE ' . implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));
+
+ $query = "
+ DELETE FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
+ {$whereStatement}
+ ";
+
+ return $query;
+ }
+
+ protected function buildOperationArguments(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, $row)
+ {
+ $args = array();
+ foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {
+ $args[] = $table->getValue($row, $columnName);
+ }
+
+ return $args;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/DeleteAll.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/DeleteAll.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/DeleteAll.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/DeleteAll.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,87 @@
+<?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: DeleteAll.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/Operation/IDatabaseOperation.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Exception.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Deletes all rows from all tables in a dataset.
+ *
+ * @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_Operation_DeleteAll implements PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+{
+
+ public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
+ {
+ foreach ($dataSet as $table) {
+ /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
+
+ $query = "
+ DELETE FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
+ ";
+
+ try {
+ $connection->getConnection()->query($query);
+ } catch (PDOException $e) {
+ throw new PHPUnit_Extensions_Database_Operation_Exception('DELETE_ALL', $query, array(), $table, $e->getMessage());
+ }
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Exception.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Exception.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Exception.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Exception.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,137 @@
+<?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: Exception.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');
+
+/**
+ * Thrown for exceptions encountered with database operations. Provides
+ * information regarding which operations failed and the query (if any) it
+ * failed on.
+ *
+ * @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_Operation_Exception extends RuntimeException
+{
+
+ /**
+ * @var string
+ */
+ protected $operation;
+
+ /**
+ * @var string
+ */
+ protected $preparedQuery;
+
+ /**
+ * @var array
+ */
+ protected $preparedArgs;
+
+ /**
+ * @var PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ protected $table;
+
+ /**
+ * @var string
+ */
+ protected $error;
+
+ /**
+ * Creates a new dbunit operation exception
+ *
+ * @param string $operation
+ * @param string $current_query
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $current_table
+ * @param string $error
+ */
+ public function __construct($operation, $current_query, $current_args, $current_table, $error)
+ {
+ parent::__construct("{$operation} operation failed on query: {$current_query} using args: " . print_r($current_args, true) . " [{$error}]");
+ $this->operation = $operation;
+ $this->preparedQuery = $current_query;
+ $this->preparedArgs = $current_args;
+ $this->table = $current_table;
+ $this->error = $error;
+ }
+
+ public function getOperation()
+ {
+ return $this->operation;
+ }
+
+ public function getQuery()
+ {
+ return $this->preparedQuery;
+ }
+
+ public function getTable()
+ {
+ return $this->table;
+ }
+
+ public function getArgs()
+ {
+ return $this->preparedArgs;
+ }
+
+ public function getError()
+ {
+ return $this->error;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Factory.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Factory.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Factory.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Factory.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,148 @@
+<?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: Factory.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/Operation/IDatabaseOperation.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+require_once '../PHPUnit/Extensions/Database/Operation/Null.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Composite.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Insert.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Truncate.php';
+require_once '../PHPUnit/Extensions/Database/Operation/DeleteAll.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Delete.php';
+
+/**
+ * A class factory to easily return database operations.
+ *
+ * @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_Operation_Factory
+{
+
+ /**
+ * Returns a null database operation
+ *
+ * @return PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ public static function NONE()
+ {
+ return new PHPUnit_Extensions_Database_Operation_Null();
+ }
+
+ /**
+ * Returns a clean insert database operation. It will remove all contents
+ * from the table prior to re-inserting rows.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ public static function CLEAN_INSERT()
+ {
+ return new PHPUnit_Extensions_Database_Operation_Composite(array(new PHPUnit_Extensions_Database_Operation_Truncate(), new PHPUnit_Extensions_Database_Operation_Insert()));
+ }
+
+ /**
+ * Returns an insert database operation.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ public static function INSERT()
+ {
+ return new PHPUnit_Extensions_Database_Operation_Insert();
+ }
+
+ /**
+ * Returns a truncate database operation.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ public static function TRUNCATE()
+ {
+ return new PHPUnit_Extensions_Database_Operation_Truncate();
+ }
+
+ /**
+ * Returns a delete database operation.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ public static function DELETE()
+ {
+ return new PHPUnit_Extensions_Database_Operation_Delete();
+ }
+
+ /**
+ * Returns a delete_all database operation.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ public static function DELETE_ALL()
+ {
+ return new PHPUnit_Extensions_Database_Operation_DeleteAll();
+ }
+
+ /**
+ * Returns an update database operation.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ public static function UPDATE()
+ {
+ return new PHPUnit_Extensions_Database_Operation_Update();
+ }
+
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/IDatabaseOperation.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/IDatabaseOperation.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/IDatabaseOperation.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/IDatabaseOperation.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,78 @@
+<?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: IDatabaseOperation.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');
+
+/**
+ * Provides a basic interface and functionality for executing database
+ * operations against a connection using a specific dataSet.
+ *
+ * @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
+ */
+interface PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+{
+
+ /**
+ * Executes the database operation against the given $connection for the
+ * given $dataSet.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
+ * @throws PHPUnit_Extensions_Database_Operation_Exception
+ */
+ public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet);
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Insert.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Insert.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Insert.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Insert.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,103 @@
+<?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: Insert.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/Operation/RowBased.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Exception.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * This class provides functionality for inserting rows from a dataset into a database.
+ *
+ * @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_Operation_Insert extends PHPUnit_Extensions_Database_Operation_RowBased
+{
+
+ protected $operationName = 'INSERT';
+
+ protected function buildOperationQuery(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $placeHolders = implode(', ', array_fill(0, count($table->getTableMetaData()->getColumns()), '?'));
+
+ $columns = '';
+ foreach ($table->getTableMetaData()->getColumns() as $column)
+ {
+ $columns .= $connection->quoteSchemaObject($column).', ';
+ }
+
+ $columns = substr($columns, 0, -2);
+
+ $query = "
+ INSERT INTO {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
+ ({$columns})
+ VALUES
+ ({$placeHolders})
+ ";
+
+ return $query;
+ }
+
+ protected function buildOperationArguments(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, $row)
+ {
+ $args = array();
+ foreach ($table->getTableMetaData()->getColumns() as $columnName) {
+ $args[] = $table->getValue($row, $columnName);
+ }
+ return $args;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Null.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Null.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Null.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Null.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,74 @@
+<?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: Null.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/Operation/IDatabaseOperation.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * This class represents a null database operation.
+ *
+ * @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_Operation_Null implements PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+{
+
+ public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
+ {
+ /* do nothing */
+ }
+}
+?>
Added: incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Replace.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Replace.php?rev=663970&view=auto
==============================================================================
--- incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Replace.php (added)
+++ incubator/shindig/trunk/php/test/PHPUnit/Extensions/Database/Operation/Replace.php Fri Jun 6 07:55:55 2008
@@ -0,0 +1,148 @@
+<?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: Replace.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/Operation/RowBased.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Insert.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Update.php';
+require_once '../PHPUnit/Extensions/Database/Operation/Exception.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Updates the rows in a given dataset using primary key columns.
+ *
+ * @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_Operation_Replace extends PHPUnit_Extensions_Database_Operation_RowBased
+{
+
+ protected $operationName = 'REPLACE';
+
+ protected function buildOperationQuery(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $keys = $databaseTableMetaData->getPrimaryKeys();
+
+ $whereStatement = 'WHERE ' . implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));
+
+ $query = "
+ SELECT COUNT(*)
+ FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
+ {$whereStatement}
+ ";
+
+ return $query;
+ }
+
+ protected function buildOperationArguments(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, $row)
+ {
+ $args = array();
+
+ foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {
+ $args[] = $table->getValue($row, $columnName);
+ }
+
+ return $args;
+ }
+
+ /**
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
+ */
+ public function execute(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
+ {
+ $insertOperation = new PHPUnit_Extensions_Database_Operation_Insert();
+ $updateOperation = new PHPUnit_Extensions_Database_Operation_Update();
+
+ $databaseDataSet = $connection->createDataSet();
+
+ foreach ($dataSet as $table) {
+ /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
+ $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());
+
+ $insertQuery = $insertOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);
+ $updateQuery = $updateOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);
+ $selectQuery = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);
+
+ $insertStatement = $connection->getConnection()->prepare($insertQuery);
+ $updateStatement = $connection->getConnection()->prepare($updateQuery);
+ $selectStatement = $connection->getConnection()->prepare($selectQuery);
+
+ for ($i = 0; $i < $table->getRowCount(); $i++) {
+ $selectArgs = $this->buildOperationArguments($databaseTableMetaData, $table, $i);
+ $query = $selectQuery;
+ $args = $selectArgs;
+ try {
+ $selectStatement->execute($selectArgs);
+
+ if ($selectStatement->fetchColumn(0) > 0) {
+ $updateArgs = $updateOperation->buildOperationArguments($databaseTableMetaData, $table, $i);
+ $query = $updateQuery;
+ $args = $updateArgs;
+ $updateStatement->execute($updateArgs);
+ } else {
+ $insertArgs = $insertOperation->buildOperationArguments($databaseTableMetaData, $table, $i);
+ $query = $insertQuery;
+ $args = $insertArgs;
+ $insertStatement->execute($insertArgs);
+ }
+ } catch (Exception $e) {
+ throw new PHPUnit_Extensions_Database_Operation_Exception($this->operationName, $query, $args, $table, $e->getMessage());
+ }
+ }
+ }
+ }
+}
+?>