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/08/02 16:11:44 UTC
svn commit: r681982 [4/27] - in /incubator/shindig/trunk/php: external/
external/PHPUnit/ external/PHPUnit/Extensions/
external/PHPUnit/Extensions/Database/
external/PHPUnit/Extensions/Database/Constraint/
external/PHPUnit/Extensions/Database/DB/ exter...
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Replace.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Replace.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Replace.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Replace.php Sat Aug 2 07:11:35 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());
+ }
+ }
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/RowBased.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/RowBased.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/RowBased.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/RowBased.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,113 @@
+<?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: RowBased.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');
+
+/**
+ * Provides basic functionality for row based operations.
+ *
+ * To create a row based operation you must create two functions. The first
+ * one, buildOperationQuery(), must return a query that will be used to create
+ * a prepared statement. The second one, buildOperationArguments(), should
+ * return an array containing arguments for each row.
+ *
+ * @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_Operation_RowBased implements PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+{
+
+ protected $operationName;
+
+ protected abstract function buildOperationQuery(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection);
+
+ protected abstract function buildOperationArguments(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, $row);
+
+ /**
+ * @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)
+ {
+ $databaseDataSet = $connection->createDataSet();
+ foreach ($dataSet as $table) {
+ /* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
+ $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());
+ $query = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);
+ $statement = $connection->getConnection()->prepare($query);
+ for ($i = 0; $i < $table->getRowCount(); $i++) {
+ $args = $this->buildOperationArguments($databaseTableMetaData, $table, $i);
+ try {
+ $statement->execute($args);
+ } catch (Exception $e) {
+ throw new PHPUnit_Extensions_Database_Operation_Exception($this->operationName, $query, $args, $table, $e->getMessage());
+ }
+ }
+ }
+ }
+
+ protected function buildPreparedColumnArray($columns, PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $columnArray = array();
+ foreach ($columns as $columnName) {
+ $columnArray[] = "{$connection->quoteSchemaObject($columnName)} = ?";
+ }
+ return $columnArray;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Truncate.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Truncate.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Truncate.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Truncate.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,86 @@
+<?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: Truncate.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');
+
+/**
+ * Executes a truncate against 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_Truncate 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('TRUNCATE', $query, array(), $table, $e->getMessage());
+ }
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Update.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Update.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Update.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/Operation/Update.php Sat Aug 2 07:11:35 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: Update.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');
+
+/**
+ * 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_Update extends PHPUnit_Extensions_Database_Operation_RowBased
+{
+
+ protected $operationName = 'UPDATE';
+
+ protected function buildOperationQuery(PHPUnit_Extensions_Database_DataSet_ITableMetaData $databaseTableMetaData, PHPUnit_Extensions_Database_DataSet_ITable $table, PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $keys = $databaseTableMetaData->getPrimaryKeys();
+ $columns = $table->getTableMetaData()->getColumns();
+
+ $whereStatement = 'WHERE ' . implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));
+ $setStatement = 'SET ' . implode(', ', $this->buildPreparedColumnArray($columns, $connection));
+
+ $query = "
+ UPDATE {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
+ {$setStatement}
+ {$whereStatement}
+ ";
+
+ 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);
+ }
+
+ foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {
+ $args[] = $table->getValue($row, $columnName);
+ }
+
+ return $args;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/Database/TestCase.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,248 @@
+<?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: TestCase.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/DefaultTester.php';
+require_once 'PHPUnit/Extensions/Database/DB/DefaultDatabaseConnection.php';
+require_once 'PHPUnit/Extensions/Database/Operation/Factory.php';
+require_once 'PHPUnit/Extensions/Database/Constraint/TableIsEqual.php';
+require_once 'PHPUnit/Extensions/Database/Constraint/DataSetIsEqual.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A TestCase extension that provides functionality for testing and asserting
+ * against a real 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
+ */
+abstract class PHPUnit_Extensions_Database_TestCase extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @var PHPUnit_Extensions_Database_ITester
+ */
+ protected $databaseTester;
+
+ /**
+ * Closes the specified connection.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
+ */
+ protected function closeConnection(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $this->getDatabaseTester()->closeConnection($connection);
+ }
+
+ /**
+ * Returns the test database connection.
+ *
+ * @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
+ */
+ protected abstract function getConnection();
+
+ /**
+ * Gets the IDatabaseTester for this testCase. If the IDatabaseTester is
+ * not set yet, this method calls newDatabaseTester() to obtain a new
+ * instance.
+ *
+ * @return PHPUnit_Extensions_Database_ITester
+ */
+ protected function getDatabaseTester()
+ {
+ if (empty($this->databaseTester)) {
+ $this->databaseTester = $this->newDatabaseTester();
+ }
+
+ return $this->databaseTester;
+ }
+
+ /**
+ * Returns the test dataset.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ protected abstract function getDataSet();
+
+ /**
+ * Returns the database operation executed in test setup.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation
+ */
+ protected function getSetUpOperation()
+ {
+ return PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
+ }
+
+ /**
+ * Returns the database operation executed in test cleanup.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation
+ */
+ protected function getTearDownOperation()
+ {
+ return PHPUnit_Extensions_Database_Operation_Factory::NONE();
+ }
+
+ /**
+ * Creates a IDatabaseTester for this testCase.
+ *
+ * @return PHPUnit_Extensions_Database_ITester
+ */
+ protected function newDatabaseTester()
+ {
+ return new PHPUnit_Extensions_Database_DefaultTester($this->getConnection());
+ }
+
+ /**
+ * Creates a new DefaultDatabaseConnection using the given PDO connection
+ * and database schema name.
+ *
+ * @param PDO $connection
+ * @param string $schema
+ * @return PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection
+ */
+ protected function createDefaultDBConnection(PDO $connection, $schema)
+ {
+ return new PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection($connection, $schema);
+ }
+
+ /**
+ * Creates a new FlatXmlDataSet with the given $xmlFile. (absolute path.)
+ *
+ * @param string $xmlFile
+ * @return PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet
+ */
+ protected function createFlatXMLDataSet($xmlFile)
+ {
+ require_once 'PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php';
+ return new PHPUnit_Extensions_Database_DataSet_FlatXmlDataSet($xmlFile);
+ }
+
+ /**
+ * Creates a new XMLDataSet with the given $xmlFile. (absolute path.)
+ *
+ * @param string $xmlFile
+ * @return PHPUnit_Extensions_Database_DataSet_XmlDataSet
+ */
+ protected function createXMLDataSet($xmlFile)
+ {
+ require_once 'PHPUnit/Extensions/Database/DataSet/XmlDataSet.php';
+ return new PHPUnit_Extensions_Database_DataSet_XmlDataSet($xmlFile);
+ }
+
+ /**
+ * Returns an operation factory instance that can be used to instantiate
+ * new operations.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_Factory
+ */
+ protected function getOperations()
+ {
+ require_once 'PHPUnit/Extensions/Database/Operation/Factory.php';
+ return new PHPUnit_Extensions_Database_Operation_Factory();
+ }
+
+ /**
+ * Performs operation returned by getSetUpOperation().
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->getDatabaseTester()->setSetUpOperation($this->getSetUpOperation());
+ $this->getDatabaseTester()->setDataSet($this->getDataSet());
+ $this->getDatabaseTester()->onSetUp();
+ }
+
+ /**
+ * Performs operation returned by getSetUpOperation().
+ */
+ protected function tearDown()
+ {
+ $this->getDatabaseTester()->setTearDownOperation($this->getTearDownOperation());
+ $this->getDatabaseTester()->setDataSet($this->getDataSet());
+ $this->getDatabaseTester()->onTearDown();
+ }
+
+ /**
+ * Asserts that two given tables are equal.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $expected
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $actual
+ * @param string $message
+ */
+ public static function assertTablesEqual(PHPUnit_Extensions_Database_DataSet_ITable $expected, PHPUnit_Extensions_Database_DataSet_ITable $actual, $message = '')
+ {
+ $constraint = new PHPUnit_Extensions_Database_Constraint_TableIsEqual($expected);
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
+ * Asserts that two given datasets are equal.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $expected
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $actual
+ * @param string $message
+ */
+ public static function assertDataSetsEqual(PHPUnit_Extensions_Database_DataSet_IDataSet $expected, PHPUnit_Extensions_Database_DataSet_IDataSet $actual, $message = '')
+ {
+ $constraint = new PHPUnit_Extensions_Database_Constraint_DataSetIsEqual($expected);
+
+ self::assertThat($actual, $constraint, $message);
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/ExceptionTestCase.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,73 @@
+<?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 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: ExceptionTestCase.php 2152 2008-01-17 11:17:12Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 2.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+trigger_error(
+ "Class PHPUnit_Extensions_ExceptionTestCase is deprecated. ".
+ "It will be removed in PHPUnit 3.3. ".
+ "The functionality has been merged into PHPUnit_Framework_TestCase."
+);
+
+/**
+ * A TestCase that expects a specified Exception to be thrown.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @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 2.0.0
+ */
+abstract class PHPUnit_Extensions_ExceptionTestCase extends PHPUnit_Framework_TestCase
+{
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/OutputTestCase.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,207 @@
+<?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 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: OutputTestCase.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A TestCase that expects a specified output.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @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.0.0
+ */
+abstract class PHPUnit_Extensions_OutputTestCase extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var string
+ * @access protected
+ */
+ protected $expectedRegex = NULL;
+
+ /**
+ * @var string
+ * @access protected
+ */
+ protected $expectedString = NULL;
+
+ /**
+ * @var string
+ * @access protected
+ */
+ protected $output = '';
+
+ /**
+ * @var mixed
+ * @access protected
+ */
+ protected $outputCallback = FALSE;
+
+ /**
+ * @return bool
+ * @access public
+ */
+ public function setOutputCallback($callback)
+ {
+ if (is_callable($callback)) {
+ $this->outputCallback = $callback;
+ $set = TRUE;
+ } else {
+ $set = FALSE;
+ }
+
+ return $set;
+ }
+
+ /**
+ * @return string
+ * @access public
+ */
+ public function normalizeOutput($buffer)
+ {
+ return str_replace("\r", '', $buffer);
+ }
+
+ /**
+ * @return string
+ * @access public
+ */
+ public function getActualOutput()
+ {
+ return $this->output;
+ }
+
+ /**
+ * @return string
+ * @access public
+ */
+ public function expectedRegex()
+ {
+ return $this->expectedRegex;
+ }
+
+ /**
+ * @param string $expectedRegex
+ * @access public
+ */
+ public function expectOutputRegex($expectedRegex)
+ {
+ if ($this->expectedString !== NULL) {
+ throw new RuntimeException;
+ }
+
+ if (is_string($expectedRegex) || is_null($expectedRegex)) {
+ $this->expectedRegex = $expectedRegex;
+ }
+ }
+
+ /**
+ * @return string
+ * @access public
+ */
+ public function expectedString()
+ {
+ return $this->expectedOutput;
+ }
+
+ /**
+ * @param string $expectedString
+ * @access public
+ */
+ public function expectOutputString($expectedString)
+ {
+ if ($this->expectedRegex !== NULL) {
+ throw new RuntimeException;
+ }
+
+ if (is_string($expectedString) || is_null($expectedString)) {
+ $this->expectedString = $expectedString;
+ }
+ }
+
+ /**
+ * @access protected
+ */
+ protected function runTest()
+ {
+ ob_start();
+
+ try {
+ parent::runTest();
+ }
+
+ catch (Exception $e) {
+ ob_end_clean();
+ throw $e;
+ }
+
+ if ($this->outputCallback === FALSE) {
+ $this->output = ob_get_contents();
+ } else {
+ $this->output = call_user_func_array($this->outputCallback, array(ob_get_contents()));
+ }
+
+ ob_end_clean();
+
+ if ($this->expectedRegex !== NULL) {
+ $this->assertRegExp($this->expectedRegex, $this->output);
+ $this->expectedRegex = NULL;
+ }
+
+ else if ($this->expectedString !== NULL) {
+ $this->assertEquals($this->expectedString, $this->output);
+ $this->expectedString = NULL;
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PerformanceTestCase.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,122 @@
+<?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 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: PerformanceTestCase.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 2.1.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/Timer.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A TestCase that expects a TestCase to be executed
+ * meeting a given time limit.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @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 2.1.0
+ */
+abstract class PHPUnit_Extensions_PerformanceTestCase extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var integer
+ * @access protected
+ */
+ protected $maxRunningTime = 0;
+
+ /**
+ * @access protected
+ */
+ protected function runTest()
+ {
+ PHPUnit_Util_Timer::start();
+ parent::runTest();
+ $time = PHPUnit_Util_Timer::stop();
+
+ if ($this->maxRunningTime != 0 &&
+ $time > $this->maxRunningTime) {
+ $this->fail(
+ sprintf(
+ 'expected running time: <= %s but was: %s',
+
+ $this->maxRunningTime,
+ $time
+ )
+ );
+ }
+ }
+
+ /**
+ * @param integer $maxRunningTime
+ * @throws InvalidArgumentException
+ * @access public
+ * @since Method available since Release 2.3.0
+ */
+ public function setMaxRunningTime($maxRunningTime)
+ {
+ if (is_integer($maxRunningTime) &&
+ $maxRunningTime >= 0) {
+ $this->maxRunningTime = $maxRunningTime;
+ } else {
+ throw new InvalidArgumentException;
+ }
+ }
+
+ /**
+ * @return integer
+ * @access public
+ * @since Method available since Release 2.3.0
+ */
+ public function getMaxRunningTime()
+ {
+ return $this->maxRunningTime;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,248 @@
+<?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 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: PhptTestCase.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.1.4
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Extensions/PhptTestCase/Logger.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+@include_once 'PEAR/RunTest.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Wrapper to run .phpt test cases.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @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.1.4
+ */
+class PHPUnit_Extensions_PhptTestCase implements PHPUnit_Framework_Test
+{
+ /**
+ * The filename of the .phpt file.
+ *
+ * @var string
+ * @access protected
+ */
+ protected $filename;
+
+ protected $options = array();
+
+ /**
+ * Constructs a test case with the given filename.
+ *
+ * @param string $filename
+ * @param array $options Array with ini settings for the php instance run,
+ * key being the name if the setting, value the ini value.
+ * @access public
+ */
+ public function __construct($filename, $options = array())
+ {
+ if (!is_string($filename)) {
+ throw new InvalidArgumentException;
+ }
+
+ if (!is_file($filename)) {
+ throw new RuntimeException(
+ sprintf(
+ 'File "%s" does not exist.',
+ $filename
+ )
+ );
+ }
+
+ if (!is_array($options)) {
+ throw new InvalidArgumentException;
+ }
+
+ $this->filename = $filename;
+ $this->options = $options;
+ }
+
+ /**
+ * Counts the number of test cases executed by run(TestResult result).
+ *
+ * @return integer
+ * @access public
+ */
+ public function count()
+ {
+ return 1;
+ }
+
+ /**
+ * Runs a test and collects its result in a TestResult instance.
+ *
+ * @param PHPUnit_Framework_TestResult $result
+ * @param array $options Array with ini settings for the php instance run,
+ * key being the name if the setting, value the ini value.
+ * @return PHPUnit_Framework_TestResult
+ * @access public
+ */
+ public function run(PHPUnit_Framework_TestResult $result = NULL, $options = array())
+ {
+ if (!class_exists('PEAR_RunTest', FALSE)) {
+ throw new RuntimeException('Class PEAR_RunTest not found.');
+ }
+
+ if ($result === NULL) {
+ $result = new PHPUnit_Framework_TestResult;
+ }
+
+ if (!is_array($options)) {
+ throw new InvalidArgumentException;
+ }
+
+ $options = array_merge($options, $this->options);
+
+ $coverage = $result->getCollectCodeCoverageInformation();
+
+ if ($coverage) {
+ $options = array('coverage' => TRUE);
+ } else {
+ $options = array();
+ }
+
+ $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger, $options);
+
+ if ($coverage){
+ $runner->xdebug_loaded = TRUE;
+ } else {
+ $runner->xdebug_loaded = FALSE;
+ }
+
+ $result->startTest($this);
+
+ PHPUnit_Util_Timer::start();
+ $buffer = $runner->run($this->filename, $options);
+ $time = PHPUnit_Util_Timer::stop();
+
+ $base = basename($this->filename);
+ $path = dirname($this->filename);
+ $coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base);
+ $diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base);
+ $expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base);
+ $logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base);
+ $outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base);
+ $phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base);
+
+ if (is_object($buffer) && $buffer instanceof PEAR_Error) {
+ $result->addError(
+ $this,
+ new RuntimeException($buffer->getMessage()),
+ $time
+ );
+ }
+
+ else if ($buffer == 'SKIPPED') {
+ $result->addFailure($this, new PHPUnit_Framework_SkippedTestError, 0);
+ }
+
+ else if ($buffer != 'PASSED') {
+ $result->addFailure(
+ $this,
+ PHPUnit_Framework_ComparisonFailure::diffEqual(
+ file_get_contents($expFile),
+ file_get_contents($outFile),
+ FALSE,
+ $this->getName()
+ ),
+ $time
+ );
+ }
+
+ foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) {
+ if (file_exists($file)) {
+ unlink($file);
+ }
+ }
+
+ if ($coverage) {
+ eval('$coverageData = ' . file_get_contents($coverageFile) . ';');
+ unset($coverageData[$phpFile]);
+
+ $codeCoverageInformation = array(
+ 'test' => $this,
+ 'files' => $coverageData
+ );
+
+ $result->appendCodeCoverageInformation($this, $codeCoverageInformation);
+ unlink($coverageFile);
+ }
+
+ $result->endTest($this, $time);
+
+ return $result;
+ }
+
+ /**
+ * Returns the name of the test case.
+ *
+ * @return string
+ * @access public
+ */
+ public function getName()
+ {
+ return $this->toString();
+ }
+
+ /**
+ * Returns a string representation of the test case.
+ *
+ * @return string
+ * @access public
+ */
+ public function toString()
+ {
+ return $this->filename;
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestCase/Logger.php Sat Aug 2 07:11:35 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 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: Logger.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.1.4
+ */
+
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Dummy logger for PEAR_RunTest.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @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.1.4
+ */
+class PHPUnit_Extensions_PhptTestCase_Logger
+{
+ public function log($level, $msg, $append_crlf = TRUE)
+ {
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/PhptTestSuite.php Sat Aug 2 07:11:35 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 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: PhptTestSuite.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.1.4
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Util/Filter.php';
+require_once 'PHPUnit/Util/FilterIterator.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * Suite for .phpt test cases.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @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.1.4
+ */
+class PHPUnit_Extensions_PhptTestSuite extends PHPUnit_Framework_TestSuite
+{
+ /**
+ * Constructs a new TestSuite for .phpt test cases.
+ *
+ * @param string $directory
+ * @param array $options Array with ini settings for the php instance run,
+ * key being the name if the setting, value the ini value.
+ * @throws InvalidArgumentException
+ * @access public
+ */
+ public function __construct($directory, $options = array())
+ {
+ if (is_dir($directory)) {
+ $this->setName($directory);
+
+ $iterator = new PHPUnit_Util_FilterIterator(
+ new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($directory)
+ ),
+ '.phpt'
+ );
+
+ foreach ($iterator as $testFile) {
+ $this->addTestFile($testFile->getPathname(), TRUE, $options);
+ }
+ } else {
+ throw new InvalidArgumentException;
+ }
+ }
+}
+?>
Added: incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php?rev=681982&view=auto
==============================================================================
--- incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php (added)
+++ incubator/shindig/trunk/php/external/PHPUnit/Extensions/RepeatedTest.php Sat Aug 2 07:11:35 2008
@@ -0,0 +1,160 @@
+<?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 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @copyright 2002-2008 Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version SVN: $Id: RepeatedTest.php 1985 2007-12-26 18:11:55Z sb $
+ * @link http://www.phpunit.de/
+ * @since File available since Release 2.0.0
+ */
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/Extensions/TestDecorator.php';
+require_once 'PHPUnit/Util/Filter.php';
+
+PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
+
+/**
+ * A Decorator that runs a test repeatedly.
+ *
+ * @category Testing
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sb...@sebastian-bergmann.de>
+ * @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 2.0.0
+ */
+class PHPUnit_Extensions_RepeatedTest extends PHPUnit_Extensions_TestDecorator
+{
+ /**
+ * @var mixed
+ * @access protected
+ */
+ protected $filter = FALSE;
+
+ /**
+ * @var array
+ * @access protected
+ */
+ protected $groups = array();
+
+ /**
+ * @var array
+ * @access protected
+ */
+ protected $excludeGroups = array();
+
+ /**
+ * @var integer
+ * @access protected
+ */
+ protected $timesRepeat = 1;
+
+ /**
+ * Constructor.
+ *
+ * @param PHPUnit_Framework_Test $test
+ * @param integer $timesRepeat
+ * @param mixed $filter
+ * @param array $groups
+ * @param array $excludeGroups
+ * @throws InvalidArgumentException
+ * @access public
+ */
+ public function __construct(PHPUnit_Framework_Test $test, $timesRepeat = 1, $filter = FALSE, array $groups = array(), array $excludeGroups = array())
+ {
+ parent::__construct($test);
+
+ if (is_integer($timesRepeat) &&
+ $timesRepeat >= 0) {
+ $this->timesRepeat = $timesRepeat;
+ } else {
+ throw new InvalidArgumentException(
+ 'Argument 2 must be a positive integer.'
+ );
+ }
+
+ $this->filter = $filter;
+ $this->groups = $groups;
+ $this->excludeGroups = $excludeGroups;
+ }
+
+ /**
+ * Counts the number of test cases that
+ * will be run by this test.
+ *
+ * @return integer
+ * @access public
+ */
+ public function count()
+ {
+ return $this->timesRepeat * count($this->test);
+ }
+
+ /**
+ * Runs the decorated test and collects the
+ * result in a TestResult.
+ *
+ * @param PHPUnit_Framework_TestResult $result
+ * @return PHPUnit_Framework_TestResult
+ * @throws InvalidArgumentException
+ * @access public
+ */
+ public function run(PHPUnit_Framework_TestResult $result = NULL)
+ {
+ if ($result === NULL) {
+ $result = $this->createResult();
+ }
+
+ for ($i = 0; $i < $this->timesRepeat && !$result->shouldStop(); $i++) {
+ if ($this->test instanceof PHPUnit_Framework_TestSuite) {
+ $this->test->run(
+ $result, $this->filter, $this->groups, $this->excludeGroups
+ );
+ } else {
+ $this->test->run($result);
+ }
+ }
+
+ return $result;
+ }
+}
+?>