Skip to content
Browse files

@thedae: VisualPHPUnit

  • Loading branch information...
1 parent e66efac commit 0dfaac6afac166adcbdd054ea3e2a1744acd003d @thedae committed Oct 7, 2011
Showing with 19,760 additions and 0 deletions.
  1. +96 −0 libs/PHPUnit-3.5.0/Autoload.php
  2. +90 −0 libs/PHPUnit-3.5.0/Extensions/ControllerTest.php
  3. +195 −0 libs/PHPUnit-3.5.0/Extensions/Database/AbstractTester.php
  4. +122 −0 libs/PHPUnit-3.5.0/Extensions/Database/Constraint/DataSetIsEqual.php
  5. +123 −0 libs/PHPUnit-3.5.0/Extensions/Database/Constraint/TableIsEqual.php
  6. +173 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/DataSet.php
  7. +208 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/DefaultDatabaseConnection.php
  8. +84 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/FilteredDataSet.php
  9. +136 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/IDatabaseConnection.php
  10. +105 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/IMetaData.php
  11. +226 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData.php
  12. +174 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/InformationSchema.php
  13. +123 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/MySQL.php
  14. +180 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/Oci.php
  15. +193 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/PgSQL.php
  16. +143 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/Sqlite.php
  17. +81 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/ResultSetTable.php
  18. +73 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/Table.php
  19. +165 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/TableIterator.php
  20. +65 −0 libs/PHPUnit-3.5.0/Extensions/Database/DB/TableMetaData.php
  21. +167 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/AbstractDataSet.php
  22. +212 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/AbstractTable.php
  23. +125 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/AbstractTableMetaData.php
  24. +136 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/AbstractXmlDataSet.php
  25. +120 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/CompositeDataSet.php
  26. +160 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/CsvDataSet.php
  27. +196 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/DataSetFilter.php
  28. +97 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/DefaultDataSet.php
  29. +117 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/DefaultTable.php
  30. +161 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/DefaultTableIterator.php
  31. +80 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/DefaultTableMetaData.php
  32. +99 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/FlatXmlDataSet.php
  33. +95 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/IDataSet.php
  34. +66 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/IPersistable.php
  35. +65 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/ISpec.php
  36. +95 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/ITable.php
  37. +72 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/ITableIterator.php
  38. +86 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/ITableMetaData.php
  39. +141 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/MysqlXmlDataSet.php
  40. +127 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Persistors/Abstract.php
  41. +87 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Persistors/Factory.php
  42. +147 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Persistors/FlatXml.php
  43. +165 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Persistors/MysqlXml.php
  44. +151 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Persistors/Xml.php
  45. +109 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Persistors/Yaml.php
  46. +128 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/QueryDataSet.php
  47. +160 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/QueryTable.php
  48. +129 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/ReplacementDataSet.php
  49. +246 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/ReplacementTable.php
  50. +185 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/ReplacementTableIterator.php
  51. +125 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/Csv.php
  52. +111 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/DbQuery.php
  53. +109 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/DbTable.php
  54. +89 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/Factory.php
  55. +75 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/FlatXml.php
  56. +65 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/IFactory.php
  57. +75 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/Xml.php
  58. +75 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/Specs/Yaml.php
  59. +136 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/TableFilter.php
  60. +165 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/TableMetaDataFilter.php
  61. +132 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/XmlDataSet.php
  62. +168 −0 libs/PHPUnit-3.5.0/Extensions/Database/DataSet/YamlDataSet.php
  63. +84 −0 libs/PHPUnit-3.5.0/Extensions/Database/DefaultTester.php
  64. +64 −0 libs/PHPUnit-3.5.0/Extensions/Database/IDatabaseListConsumer.php
  65. +119 −0 libs/PHPUnit-3.5.0/Extensions/Database/ITester.php
  66. +94 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Composite.php
  67. +86 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Delete.php
  68. +75 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/DeleteAll.php
  69. +129 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Exception.php
  70. +138 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Factory.php
  71. +69 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/IDatabaseOperation.php
  72. +96 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Insert.php
  73. +63 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Null.php
  74. +142 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Replace.php
  75. +122 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/RowBased.php
  76. +84 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Truncate.php
  77. +90 −0 libs/PHPUnit-3.5.0/Extensions/Database/Operation/Update.php
  78. +250 −0 libs/PHPUnit-3.5.0/Extensions/Database/TestCase.php
  79. +89 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/Command.php
  80. +100 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/Context.php
  81. +72 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/IMedium.php
  82. +72 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/IMediumPrinter.php
  83. +66 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/IMode.php
  84. +73 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/IModeFactory.php
  85. +96 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/InvalidModeException.php
  86. +138 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/Mediums/Text.php
  87. +130 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/ModeFactory.php
  88. +119 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/Modes/ExportDataSet.php
  89. +153 −0 libs/PHPUnit-3.5.0/Extensions/Database/UI/Modes/ExportDataSet/Arguments.php
  90. +100 −0 libs/PHPUnit-3.5.0/Extensions/GroupTestSuite.php
  91. +202 −0 libs/PHPUnit-3.5.0/Extensions/OutputTestCase.php
  92. +277 −0 libs/PHPUnit-3.5.0/Extensions/PhptTestCase.php
  93. +63 −0 libs/PHPUnit-3.5.0/Extensions/PhptTestCase/Logger.php
  94. +86 −0 libs/PHPUnit-3.5.0/Extensions/PhptTestSuite.php
  95. +154 −0 libs/PHPUnit-3.5.0/Extensions/RepeatedTest.php
  96. +1,066 −0 libs/PHPUnit-3.5.0/Extensions/SeleniumTestCase.php
  97. +1,218 −0 libs/PHPUnit-3.5.0/Extensions/SeleniumTestCase/Driver.php
  98. +69 −0 libs/PHPUnit-3.5.0/Extensions/SeleniumTestCase/append.php
  99. +86 −0 libs/PHPUnit-3.5.0/Extensions/SeleniumTestCase/phpunit_coverage.php
  100. +59 −0 libs/PHPUnit-3.5.0/Extensions/SeleniumTestCase/prepend.php
  101. +71 −0 libs/PHPUnit-3.5.0/Extensions/Story/Given.php
  102. +102 −0 libs/PHPUnit-3.5.0/Extensions/Story/ResultPrinter.php
  103. +212 −0 libs/PHPUnit-3.5.0/Extensions/Story/ResultPrinter/HTML.php
  104. +13 −0 libs/PHPUnit-3.5.0/Extensions/Story/ResultPrinter/Template/scenario.html.dist
  105. +6 −0 libs/PHPUnit-3.5.0/Extensions/Story/ResultPrinter/Template/scenario_header.html.dist
  106. +60 −0 libs/PHPUnit-3.5.0/Extensions/Story/ResultPrinter/Template/scenarios.html.dist
  107. +6 −0 libs/PHPUnit-3.5.0/Extensions/Story/ResultPrinter/Template/step.html.dist
  108. +150 −0 libs/PHPUnit-3.5.0/Extensions/Story/ResultPrinter/Text.php
  109. +189 −0 libs/PHPUnit-3.5.0/Extensions/Story/Scenario.php
  110. +204 −0 libs/PHPUnit-3.5.0/Extensions/Story/SeleniumTestCase.php
  111. +128 −0 libs/PHPUnit-3.5.0/Extensions/Story/Step.php
  112. +210 −0 libs/PHPUnit-3.5.0/Extensions/Story/TestCase.php
  113. +71 −0 libs/PHPUnit-3.5.0/Extensions/Story/Then.php
  114. +71 −0 libs/PHPUnit-3.5.0/Extensions/Story/When.php
  115. +151 −0 libs/PHPUnit-3.5.0/Extensions/TestDecorator.php
  116. +225 −0 libs/PHPUnit-3.5.0/Extensions/TicketListener.php
  117. +204 −0 libs/PHPUnit-3.5.0/Extensions/TicketListener/GitHub.php
  118. +275 −0 libs/PHPUnit-3.5.0/Extensions/TicketListener/GoogleCode.php
  119. +189 −0 libs/PHPUnit-3.5.0/Extensions/TicketListener/Trac.php
  120. +197 −0 libs/PHPUnit-3.5.0/File/Iterator.php
  121. +159 −0 libs/PHPUnit-3.5.0/File/Iterator/Factory.php
  122. +50 −0 libs/PHPUnit-3.5.0/Framework.php
  123. +2,620 −0 libs/PHPUnit-3.5.0/Framework/Assert.php
Sorry, we could not display the entire diff because too many files (401) changed.
View
96 libs/PHPUnit-3.5.0/Autoload.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, Sebastian Bergmann <sebastian@phpunit.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.
+ *
+ * @package PHPUnit
+ * @author Sebastian Bergmann <sebastian@phpunit.de>
+ * @copyright 2002-2011 Sebastian Bergmann <sebastian@phpunit.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.5.0
+ */
+
+set_include_path( realpath( dirname( __FILE__ ) ) . PATH_SEPARATOR . '.' . PATH_SEPARATOR . realpath( dirname( __FILE__ ) . '/..' ) );
+
+$path = explode( DIRECTORY_SEPARATOR, dirname( __FILE__ ) );
+define( 'PARENT_FOLDER', $path[count( $path ) - 1] );
+
+require_once 'Util/Filesystem.php';
+require_once 'PHP/CodeCoverage/Filter.php';
+
+if (!function_exists('phpunit_autoload')) {
+ function phpunit_autoload($class)
+ {
+ if (strpos($class, 'PHPUnit_') === 0) {
+ $file = str_replace( 'PHPUnit_', PARENT_FOLDER . '_', $class );
+ $file = str_replace('_', '/', $file) . '.php';
+
+ $file = PHPUnit_Util_Filesystem::fileExistsInIncludePath($file);
+
+ if ($file) {
+ require_once $file;
+ }
+ }
+ }
+
+ spl_autoload_register('phpunit_autoload');
+
+ $dir = dirname(__FILE__);
+ $filter = PHP_CodeCoverage_Filter::getInstance();
+
+ $filter->addDirectoryToBlacklist(
+ $dir . '/Extensions', '.php', '', 'PHPUNIT', FALSE
+ );
+
+ $filter->addDirectoryToBlacklist(
+ $dir . '/Framework', '.php', '', 'PHPUNIT', FALSE
+ );
+
+ $filter->addDirectoryToBlacklist(
+ $dir . '/Runner', '.php', '', 'PHPUNIT', FALSE
+ );
+
+ $filter->addDirectoryToBlacklist(
+ $dir . '/TextUI', '.php', '', 'PHPUNIT', FALSE
+ );
+
+ $filter->addDirectoryToBlacklist(
+ $dir . '/Util', '.php', '', 'PHPUNIT', FALSE
+ );
+
+ $filter->addFileToBlacklist(__FILE__, 'PHPUNIT', FALSE);
+
+ unset($dir, $filter);
+}
View
90 libs/PHPUnit-3.5.0/Extensions/ControllerTest.php
@@ -0,0 +1,90 @@
+<?php
+/**
+ * ControllerTest.
+ *
+ * Create a proxy class for a TestCase.
+ * It modifies the accessibility of protected methods and properties to public.
+ *
+ * Example of usage for methods:
+ *
+ * $output = $this->obj->accessible_<methodName>( $args );
+ *
+ * Where <methodName> is the name of the protected method.
+ *
+ * The properties remains with the same name but public access.
+ */
+class PHPUnit_Extensions_ControllerTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Create the proxy class of the given class name.
+ *
+ * @param object $classname Class name.
+ * @return object
+ */
+ protected function getProxyClass( $classname )
+ {
+ $proxy_classname = $classname . 'ProxyTest';
+
+ $proxy_class = <<<CLASS
+class $proxy_classname extends $classname
+{
+ public function __call( \$name, Array \$arguments )
+ {
+ if ( preg_match( '/^accessible_(.*)/i', \$name, \$matches ) )
+ {
+ if ( isset( \$matches[1] ) )
+ {
+ \$foo = self::getMethod( \$matches[1] );
+ \$obj = new $classname();
+ return \$foo->invokeArgs( \$obj, \$arguments );
+ }
+ }
+
+ trigger_error( 'Method $classname::' . \$name . ' does not exist', E_USER_ERROR );
+ }
+
+ protected static function getMethod( \$name )
+ {
+ \$class = new ReflectionClass( '$classname' );
+ \$method = \$class->getMethod( \$name );
+ \$method->setAccessible( true );
+ return \$method;
+ }
+CLASS;
+
+ $reflected = new ReflectionClass( $classname );
+ $class_vars = $reflected->getProperties( ReflectionProperty::IS_PROTECTED );
+
+ foreach ( $class_vars as $reflected_var )
+ {
+ $reflected_var->setAccessible( true );
+ $var_name = $reflected_var->getName();
+
+ $real_value = $reflected_var->getValue( new $classname );
+
+ $is_static = '';
+ if ( false !== $reflected_var->isStatic() )
+ {
+ $is_static = 'static ';
+ }
+
+ $proxy_class .= <<<CLASS
+ {$is_static}public \${$var_name};
+CLASS;
+ }
+
+ $proxy_class .= <<<CLASS
+}
+CLASS;
+
+
+ if ( !class_exists( $proxy_classname ) )
+ {
+ eval( $proxy_class );
+ }
+
+ return new $proxy_classname;
+ }
+}
+
+?>
View
195 libs/PHPUnit-3.5.0/Extensions/Database/AbstractTester.php
@@ -0,0 +1,195 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Can be used as a foundation for new DatabaseTesters.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+abstract class PHPUnit_Extensions_Database_AbstractTester implements PHPUnit_Extensions_Database_ITester
+{
+
+ /**
+ * @var PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ protected $setUpOperation;
+
+ /**
+ * @var PHPUnit_Extensions_Database_Operation_IDatabaseOperation
+ */
+ protected $tearDownOperation;
+
+ /**
+ * @var PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ protected $dataSet;
+
+ /**
+ * @var string
+ */
+ protected $schema;
+
+ /**
+ * Creates a new database tester.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
+ */
+ public function __construct()
+ {
+ $this->setUpOperation = PHPUnit_Extensions_Database_Operation_Factory::CLEAN_INSERT();
+ $this->tearDownOperation = PHPUnit_Extensions_Database_Operation_Factory::NONE();
+ }
+
+ /**
+ * Closes the specified connection.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
+ */
+ public function closeConnection(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
+ {
+ $connection->close();
+ }
+
+ /**
+ * Returns the test dataset.
+ *
+ * @return PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ public function getDataSet()
+ {
+ return $this->dataSet;
+ }
+
+ /**
+ * TestCases must call this method inside setUp().
+ */
+ public function onSetUp()
+ {
+ $this->getSetUpOperation()->execute($this->getConnection(), $this->getDataSet());
+ }
+
+ /**
+ * TestCases must call this method inside tearDown().
+ */
+ public function onTearDown()
+ {
+ $this->getTearDownOperation()->execute($this->getConnection(), $this->getDataSet());
+ }
+
+ /**
+ * Sets the test dataset to use.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
+ */
+ public function setDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
+ {
+ $this->dataSet = $dataSet;
+ }
+
+ /**
+ * Sets the schema value.
+ *
+ * @param string $schema
+ */
+ public function setSchema($schema)
+ {
+ $this->schema = $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)
+ {
+ $this->setUpOperation = $setUpOperation;
+ }
+
+ /**
+ * Sets the DatabaseOperation to call when ending the test.
+ *
+ * @param PHPUnit_Extensions_Database_Operation_DatabaseOperation $tearDownOperation
+ */
+ public function setTearDownOperation(PHPUnit_Extensions_Database_Operation_IDatabaseOperation $tearDownOperation)
+ {
+ $this->tearDownOperation = $tearDownOperation;
+ }
+
+ /**
+ * Returns the schema value
+ *
+ * @return string
+ */
+ protected function getSchema()
+ {
+ return $this->schema;
+ }
+
+ /**
+ * Returns the database operation that will be called when starting the test.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation
+ */
+ protected function getSetUpOperation()
+ {
+ return $this->setUpOperation;
+ }
+
+ /**
+ * Returns the database operation that will be called when ending the test.
+ *
+ * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation
+ */
+ protected function getTearDownOperation()
+ {
+ return $this->tearDownOperation;
+ }
+}
View
122 libs/PHPUnit-3.5.0/Extensions/Database/Constraint/DataSetIsEqual.php
@@ -0,0 +1,122 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Asserts whether or not two dbunit datasets are equal.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+class PHPUnit_Extensions_Database_Constraint_DataSetIsEqual extends PHPUnit_Framework_Constraint
+{
+
+ /**
+ * @var PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ protected $value;
+
+ /**
+ * @var string
+ */
+ protected $failure_reason;
+
+ /**
+ * Creates a new constraint.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $value
+ */
+ public function __construct(PHPUnit_Extensions_Database_DataSet_IDataSet $value)
+ {
+ $this->value = $value;
+ }
+
+ /**
+ * Determines whether or not the given dataset matches the dataset used to
+ * create this constraint.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_IDataSet $other
+ * @return bool
+ */
+ public function evaluate($other)
+ {
+ if ($other instanceof PHPUnit_Extensions_Database_DataSet_IDataSet) {
+ try {
+ $this->value->assertEquals($other);
+ return TRUE;
+ } catch (Exception $e) {
+ $this->failure_reason = $e->getMessage();
+ return FALSE;
+ }
+ } else {
+ throw new InvalidArgumentException("PHPUnit_Extensions_Database_DataSet_IDataSet expected");
+ }
+ }
+
+ protected function customFailureDescription($other, $description, $not)
+ {
+ return sprintf(
+ 'Failed asserting that actual %s %s Reason: %s',
+
+ $other->__toString(),
+ $this->toString(),
+ $this->failure_reason
+ );
+ }
+
+ /**
+ * Returns a string representation of the constraint.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return sprintf('is equal to expected %s',
+ $this->value->__toString());
+ }
+}
View
123 libs/PHPUnit-3.5.0/Extensions/Database/Constraint/TableIsEqual.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Asserts whether or not two dbunit tables are equal.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+class PHPUnit_Extensions_Database_Constraint_TableIsEqual extends PHPUnit_Framework_Constraint
+{
+
+ /**
+ * @var PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ protected $value;
+
+ /**
+ * @var string
+ */
+ protected $failure_reason;
+
+ /**
+ * Creates a new constraint.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $value
+ */
+ public function __construct(PHPUnit_Extensions_Database_DataSet_ITable $value)
+ {
+ $this->value = $value;
+ }
+
+ /**
+ * Determines whether or not the given table matches the table used to
+ * create this constraint.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITable $other
+ * @return bool
+ */
+ public function evaluate($other)
+ {
+ if ($other instanceof PHPUnit_Extensions_Database_DataSet_ITable) {
+ try {
+ $this->value->assertEquals($other);
+ return TRUE;
+ } catch (Exception $e) {
+ $this->failure_reason = $e->getMessage();
+ return FALSE;
+ }
+ } else {
+ throw new InvalidArgumentException("PHPUnit_Extensions_Database_DataSet_ITable expected");
+ }
+ }
+
+ protected function customFailureDescription($other, $description, $not)
+ {
+ return sprintf(
+ 'Failed asserting that actual %s %s Reason: %s',
+
+ $other->__toString(),
+ $this->toString(),
+ $this->failure_reason
+ );
+ }
+
+ /**
+ * Returns a string representation of the constraint.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return sprintf('is equal to expected %s',
+
+ PHPUnit_Util_Type::toString($this->value));
+ }
+}
View
173 libs/PHPUnit-3.5.0/Extensions/Database/DB/DataSet.php
@@ -0,0 +1,173 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides access to a database instance as a data set.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+class PHPUnit_Extensions_Database_DB_DataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
+{
+
+ /**
+ * An array of ITable objects.
+ *
+ * @var array
+ */
+ protected $tables = array();
+
+ /**
+ * The database connection this dataset is using.
+ *
+ * @var PHPUnit_Extensions_Database_DB_IDatabaseConnection
+ */
+ protected $databaseConnection;
+
+ /**
+ * Creates a new dataset using the given database connection.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
+ */
+ public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection)
+ {
+ $this->databaseConnection = $databaseConnection;
+ }
+
+ /**
+ * Creates the query necessary to pull all of the data from a table.
+ *
+ * @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData
+ * @return unknown
+ */
+ public static function buildTableSelect(PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData, PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection = NULL)
+ {
+ if ($tableMetaData->getTableName() == '') {
+ $e = new Exception("Empty Table Name");
+ echo $e->getTraceAsString();
+ throw $e;
+ }
+
+ $columns = $tableMetaData->getColumns();
+ if ($databaseConnection) {
+ $columns = array_map(array($databaseConnection, 'quoteSchemaObject'), $columns);
+ }
+ $columnList = implode(', ', $columns);
+
+ if ($databaseConnection) {
+ $tableName = $databaseConnection->quoteSchemaObject($tableMetaData->getTableName());
+ } else {
+ $tableName = $tableMetaData->getTableName();
+ }
+
+ $primaryKeys = $tableMetaData->getPrimaryKeys();
+ if ($databaseConnection) {
+ $primaryKeys = array_map(array($databaseConnection, 'quoteSchemaObject'), $primaryKeys);
+ }
+ if (count($primaryKeys)) {
+ $orderBy = 'ORDER BY ' . implode(' ASC, ', $primaryKeys) . ' ASC';
+ } else {
+ $orderBy = '';
+ }
+
+ return "SELECT {$columnList} FROM {$tableName} {$orderBy}";
+ }
+
+ /**
+ * Creates an iterator over the tables in the data set. If $reverse is
+ * true a reverse iterator will be returned.
+ *
+ * @param bool $reverse
+ * @return PHPUnit_Extensions_Database_DB_TableIterator
+ */
+ protected function createIterator($reverse = FALSE)
+ {
+ return new PHPUnit_Extensions_Database_DB_TableIterator($this->getTableNames(), $this, $reverse);
+ }
+
+ /**
+ * Returns a table object for the given table.
+ *
+ * @param string $tableName
+ * @return PHPUnit_Extensions_Database_DB_Table
+ */
+ public function getTable($tableName)
+ {
+ if (!in_array($tableName, $this->getTableNames())) {
+ throw new InvalidArgumentException("$tableName is not a table in the current database.");
+ }
+
+ if (empty($this->tables[$tableName])) {
+ $this->tables[$tableName] = new PHPUnit_Extensions_Database_DB_Table($this->getTableMetaData($tableName), $this->databaseConnection);
+ }
+
+ return $this->tables[$tableName];
+ }
+
+ /**
+ * Returns a table meta data object for the given table.
+ *
+ * @param string $tableName
+ * @return PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData
+ */
+ public function getTableMetaData($tableName)
+ {
+ return new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $this->databaseConnection->getMetaData()->getTableColumns($tableName), $this->databaseConnection->getMetaData()->getTablePrimaryKeys($tableName));
+ }
+
+ /**
+ * Returns a list of table names for the database
+ *
+ * @return Array
+ */
+ public function getTableNames()
+ {
+ return $this->databaseConnection->getMetaData()->getTableNames();
+ }
+}
View
208 libs/PHPUnit-3.5.0/Extensions/Database/DB/DefaultDatabaseConnection.php
@@ -0,0 +1,208 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides a basic interface for communicating with a database.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+class PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection implements PHPUnit_Extensions_Database_DB_IDatabaseConnection
+{
+ /**
+ * @var PDO
+ */
+ protected $connection;
+
+ /**
+ * The metadata object used to retrieve table meta data from the database.
+ *
+ * @var PHPUnit_Extensions_Database_DB_IMetaData
+ */
+ protected $metaData;
+
+ /**
+ * Creates a new database connection
+ *
+ * @param PDO $connection
+ * @param string $schema - The name of the database schema you will be testing against.
+ */
+ public function __construct(PDO $connection, $schema = '')
+ {
+ $this->connection = $connection;
+ $this->metaData = PHPUnit_Extensions_Database_DB_MetaData::createMetaData($connection, $schema);
+ $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ }
+
+ /**
+ * Close this connection.
+ */
+ public function close()
+ {
+ unset($this->connection);
+ }
+
+ /**
+ * Returns a database metadata object that can be used to retrieve table
+ * meta data from the database.
+ *
+ * @return PHPUnit_Extensions_Database_DB_IMetaData
+ */
+ public function getMetaData()
+ {
+ return $this->metaData;
+ }
+
+ /**
+ * Returns the schema for the connection.
+ *
+ * @return string
+ */
+ public function getSchema()
+ {
+ return $this->getMetaData()->getSchema();
+ }
+
+ /**
+ * Creates a dataset containing the specified table names. If no table
+ * names are specified then it will created a dataset over the entire
+ * database.
+ *
+ * @param array $tableNames
+ * @return PHPUnit_Extensions_Database_DataSet_IDataSet
+ * @todo Implement the filtered data set.
+ */
+ public function createDataSet(array $tableNames = NULL)
+ {
+ if (empty($tableNames)) {
+ return new PHPUnit_Extensions_Database_DB_DataSet($this);
+ } else {
+ return new PHPUnit_Extensions_Database_DB_FilteredDataSet($this, $tableNames);
+ }
+ }
+
+ /**
+ * Creates a table with the result of the specified SQL statement.
+ *
+ * @param string $resultName
+ * @param string $sql
+ * @return PHPUnit_Extensions_Database_DB_Table
+ */
+ public function createQueryTable($resultName, $sql)
+ {
+ return new PHPUnit_Extensions_Database_DataSet_QueryTable($resultName, $sql, $this);
+ }
+
+ /**
+ * Returns this connection database configuration
+ *
+ * @return PHPUnit_Extensions_Database_Database_DatabaseConfig
+ */
+ public function getConfig()
+ {
+ }
+
+ /**
+ * Returns a PDO Connection
+ *
+ * @return PDO
+ */
+ public function getConnection()
+ {
+ return $this->connection;
+ }
+
+ /**
+ * Returns the number of rows in the given table. You can specify an
+ * optional where clause to return a subset of the table.
+ *
+ * @param string $tableName
+ * @param string $whereClause
+ * @param int
+ */
+ public function getRowCount($tableName, $whereClause = NULL)
+ {
+ $query = "SELECT COUNT(*) FROM ".$this->quoteSchemaObject($tableName);
+
+ if (isset($whereClause)) {
+ $query .= " WHERE {$whereClause}";
+ }
+ }
+
+ /**
+ * Returns a quoted schema object. (table name, column name, etc)
+ *
+ * @param string $object
+ * @return string
+ */
+ public function quoteSchemaObject($object)
+ {
+ return $this->getMetaData()->quoteSchemaObject($object);
+ }
+
+ /**
+ * Returns the command used to truncate a table.
+ *
+ * @return string
+ */
+ public function getTruncateCommand()
+ {
+ return $this->getMetaData()->getTruncateCommand();
+ }
+
+ /**
+ * Returns true if the connection allows cascading
+ *
+ * @return bool
+ */
+ public function allowsCascading()
+ {
+ return $this->getMetaData()->allowsCascading();
+ }
+}
View
84 libs/PHPUnit-3.5.0/Extensions/Database/DB/FilteredDataSet.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides access to a database instance as a data set.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+class PHPUnit_Extensions_Database_DB_FilteredDataSet extends PHPUnit_Extensions_Database_DB_DataSet
+{
+
+ /**
+ * @var Array
+ */
+ protected $tableNames;
+
+ /**
+ * Creates a new dataset using the given database connection.
+ *
+ * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
+ */
+ public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection, Array $tableNames)
+ {
+ parent::__construct($databaseConnection);
+ $this->tableNames = $tableNames;
+ }
+
+ /**
+ * Returns a list of table names for the database
+ *
+ * @return Array
+ */
+ public function getTableNames()
+ {
+ return $this->tableNames;
+ }
+}
View
136 libs/PHPUnit-3.5.0/Extensions/Database/DB/IDatabaseConnection.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides a basic interface for communicating with a database.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+interface PHPUnit_Extensions_Database_DB_IDatabaseConnection
+{
+
+ /**
+ * Close this connection.
+ */
+ public function close();
+
+ /**
+ * Creates a dataset containing the specified table names. If no table
+ * names are specified then it will created a dataset over the entire
+ * database.
+ *
+ * @param array $tableNames
+ * @return PHPUnit_Extensions_Database_DataSet_IDataSet
+ */
+ public function createDataSet(Array $tableNames = NULL);
+
+ /**
+ * Creates a table with the result of the specified SQL statement.
+ *
+ * @param string $resultName
+ * @param string $sql
+ * @return PHPUnit_Extensions_Database_DataSet_ITable
+ */
+ public function createQueryTable($resultName, $sql);
+
+ /**
+ * Returns a PDO Connection
+ *
+ * @return PDO
+ */
+ public function getConnection();
+
+ /**
+ * Returns a database metadata object that can be used to retrieve table
+ * meta data from the database.
+ *
+ * @return PHPUnit_Extensions_Database_DB_IMetaData
+ */
+ public function getMetaData();
+
+ /**
+ * Returns the number of rows in the given table. You can specify an
+ * optional where clause to return a subset of the table.
+ *
+ * @param string $tableName
+ * @param string $whereClause
+ * @param int
+ */
+ public function getRowCount($tableName, $whereClause = NULL);
+
+ /**
+ * Returns the schema for the connection.
+ *
+ * @return string
+ */
+ public function getSchema();
+
+ /**
+ * Returns a quoted schema object. (table name, column name, etc)
+ *
+ * @param string $object
+ * @return string
+ */
+ public function quoteSchemaObject($object);
+
+ /**
+ * Returns the command used to truncate a table.
+ *
+ * @return string
+ */
+ public function getTruncateCommand();
+
+ /**
+ * Returns true if the connection allows cascading
+ *
+ * @return bool
+ */
+ public function allowsCascading();
+}
View
105 libs/PHPUnit-3.5.0/Extensions/Database/DB/IMetaData.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides a basic interface for retreiving metadata from a database.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+interface PHPUnit_Extensions_Database_DB_IMetaData
+{
+
+ /**
+ * Returns an array containing the names of all the tables in the database.
+ *
+ * @return array
+ */
+ public function getTableNames();
+
+ /**
+ * Returns an array containing the names of all the columns in the
+ * $tableName table,
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTableColumns($tableName);
+
+ /**
+ * Returns an array containing the names of all the primary key columns in
+ * the $tableName table.
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTablePrimaryKeys($tableName);
+
+ /**
+ * Returns the name of the default schema.
+ *
+ * @return string
+ */
+ public function getSchema();
+
+ /**
+ * Returns a quoted schema object. (table name, column name, etc)
+ *
+ * @param string $object
+ * @return string
+ */
+ public function quoteSchemaObject($object);
+
+ /**
+ * Returns true if the rdbms allows cascading
+ *
+ * @return bool
+ */
+ public function allowsCascading();
+}
View
226 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData.php
@@ -0,0 +1,226 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides a basic constructor for all meta data classes and a factory for
+ * generating the appropriate meta data class.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2010 Mike Lively <m@digitalsandwich.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+abstract class PHPUnit_Extensions_Database_DB_MetaData implements PHPUnit_Extensions_Database_DB_IMetaData
+{
+ protected static $metaDataClassMap = array(
+ 'pgsql' => 'PHPUnit_Extensions_Database_DB_MetaData_PgSQL',
+ 'mysql' => 'PHPUnit_Extensions_Database_DB_MetaData_MySQL',
+ 'oci' => 'PHPUnit_Extensions_Database_DB_MetaData_Oci',
+ 'sqlite' => 'PHPUnit_Extensions_Database_DB_MetaData_Sqlite',
+ 'sqlite2'=> 'PHPUnit_Extensions_Database_DB_MetaData_Sqlite'
+ );
+
+ /**
+ * The PDO connection used to retreive database meta data
+ *
+ * @var PDO
+ */
+ protected $pdo;
+
+ /**
+ * The default schema name for the meta data object.
+ *
+ * @var string
+ */
+ protected $schema;
+
+ /**
+ * The character used to quote schema objects.
+ */
+ protected $schemaObjectQuoteChar = '"';
+
+ /**
+ * The command used to perform a TRUNCATE operation.
+ */
+ protected $truncateCommand = 'TRUNCATE';
+
+ /**
+ * Creates a new database meta data object using the given pdo connection
+ * and schema name.
+ *
+ * @param PDO $pdo
+ * @param string $schema
+ */
+ public final function __construct(PDO $pdo, $schema = '')
+ {
+ $this->pdo = $pdo;
+ $this->schema = $schema;
+ }
+
+ /**
+ * Creates a meta data object based on the driver of given $pdo object and
+ * $schema name.
+ *
+ * @param PDO $pdo
+ * @param string $schema
+ * @return PHPUnit_Extensions_Database_DB_MetaData
+ */
+ public static function createMetaData(PDO $pdo, $schema = '')
+ {
+ $driverName = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
+ if (isset(self::$metaDataClassMap[$driverName])) {
+ $className = self::$metaDataClassMap[$driverName];
+
+ if ($className instanceof ReflectionClass) {
+ return $className->newInstance($pdo, $schema);
+ } else {
+ return self::registerClassWithDriver($className, $driverName)->newInstance($pdo, $schema);
+ }
+ } else {
+ throw new Exception("Could not find a meta data driver for {$driverName} pdo driver.");
+ }
+ }
+
+ /**
+ * Validates and registers the given $className with the given $pdoDriver.
+ * It should be noted that this function will not attempt to include /
+ * require the file. The $pdoDriver can be determined by the value of the
+ * PDO::ATTR_DRIVER_NAME attribute for a pdo object.
+ *
+ * A reflection of the $className is returned.
+ *
+ * @param string $className
+ * @param string $pdoDriver
+ * @return ReflectionClass
+ */
+ public static function registerClassWithDriver($className, $pdoDriver)
+ {
+ if (!class_exists($className)) {
+ throw new Exception("Specified class for {$pdoDriver} driver ({$className}) does not exist.");
+ }
+
+ $reflection = new ReflectionClass($className);
+ if ($reflection->isSubclassOf('PHPUnit_Extensions_Database_DB_MetaData')) {
+ return self::$metaDataClassMap[$pdoDriver] = $reflection;
+ } else {
+ throw new Exception("Specified class for {$pdoDriver} driver ({$className}) does not extend PHPUnit_Extensions_Database_DB_MetaData.");
+ }
+ }
+
+ /**
+ * Returns the schema for the connection.
+ *
+ * @return string
+ */
+ public function getSchema()
+ {
+ return $this->schema;
+ }
+
+ /**
+ * Returns a quoted schema object. (table name, column name, etc)
+ *
+ * @param string $object
+ * @return string
+ */
+ public function quoteSchemaObject($object)
+ {
+ $parts = explode('.', $object);
+ $quotedParts = array();
+
+ foreach ($parts as $part) {
+ $quotedParts[] = $this->schemaObjectQuoteChar .
+ str_replace($this->schemaObjectQuoteChar, $this->schemaObjectQuoteChar.$this->schemaObjectQuoteChar, $part).
+ $this->schemaObjectQuoteChar;
+ }
+
+ return implode('.', $quotedParts);
+ }
+
+ /**
+ * Seperates the schema and the table from a fully qualified table name.
+ *
+ * Returns an associative array containing the 'schema' and the 'table'.
+ *
+ * @param string $fullTableName
+ * @return array
+ */
+ public function splitTableName($fullTableName)
+ {
+ if (($dot = strpos($fullTableName, '.')) !== FALSE) {
+ return array(
+ 'schema' => substr($fullTableName, 0, $dot),
+ 'table' => substr($fullTableName, $dot + 1)
+ );
+ } else {
+ return array(
+ 'schema' => NULL,
+ 'table' => $fullTableName
+ );
+ }
+ }
+
+ /**
+ * Returns the command for the database to truncate a table.
+ *
+ * @return string
+ */
+ public function getTruncateCommand()
+ {
+ return $this->truncateCommand;
+ }
+
+ /**
+ * Returns true if the rdbms allows cascading
+ *
+ * @return bool
+ */
+ public function allowsCascading()
+ {
+ return FALSE;
+ }
+}
View
174 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/InformationSchema.php
@@ -0,0 +1,174 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides functionality to retrieve meta data from a database with information_schema support.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+class PHPUnit_Extensions_Database_DB_MetaData_InformationSchema extends PHPUnit_Extensions_Database_DB_MetaData
+{
+
+ protected $columns = array();
+
+ protected $keys = array();
+
+ /**
+ * Returns an array containing the names of all the tables in the database.
+ *
+ * @return array
+ */
+ public function getTableNames()
+ {
+ $query = "
+ SELECT DISTINCT
+ TABLE_NAME
+ FROM INFORMATION_SCHEMA.TABLES
+ WHERE
+ TABLE_TYPE='BASE TABLE' AND
+ TABLE_SCHEMA = ?
+ ORDER BY TABLE_NAME
+ ";
+
+ $statement = $this->pdo->prepare($query);
+ $statement->execute(array($this->getSchema()));
+
+ $tableNames = array();
+ while ($tableName = $statement->fetchColumn(0)) {
+ $tableNames[] = $tableName;
+ }
+
+ return $tableNames;
+ }
+
+ /**
+ * Returns an array containing the names of all the columns in the
+ * $tableName table,
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTableColumns($tableName)
+ {
+ if (!isset($this->columns[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->columns[$tableName];
+ }
+
+ /**
+ * Returns an array containing the names of all the primary key columns in
+ * the $tableName table.
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTablePrimaryKeys($tableName)
+ {
+ if (!isset($this->keys[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->keys[$tableName];
+ }
+
+ /**
+ * Loads column info from a sqlite database.
+ *
+ * @param string $tableName
+ */
+ protected function loadColumnInfo($tableName)
+ {
+ $this->columns[$tableName] = array();
+ $this->keys[$tableName] = array();
+
+ $columnQuery = "
+ SELECT DISTINCT
+ COLUMN_NAME
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE
+ TABLE_NAME = ? AND
+ TABLE_SCHEMA = ?
+ ORDER BY ORDINAL_POSITION
+ ";
+
+ $columnStatement = $this->pdo->prepare($columnQuery);
+ $columnStatement->execute(array($tableName, $this->getSchema()));
+
+ while ($columName = $columnStatement->fetchColumn(0)) {
+ $this->columns[$tableName][] = $columName;
+ }
+
+ $keyQuery = "
+ SELECT
+ KCU.COLUMN_NAME
+ FROM
+ INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC,
+ INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU
+ WHERE
+ TC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND
+ TC.TABLE_NAME = KCU.TABLE_NAME AND
+ TC.TABLE_SCHEMA = KCU.TABLE_SCHEMA AND
+ TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND
+ TC.TABLE_NAME = ? AND
+ TC.TABLE_SCHEMA = ?
+ ORDER BY
+ KCU.ORDINAL_POSITION ASC
+ ";
+
+ $keyStatement = $this->pdo->prepare($keyQuery);
+ $keyStatement->execute(array($tableName, $this->getSchema()));
+
+ while ($columName = $keyStatement->fetchColumn(0)) {
+ $this->keys[$tableName][] = $columName;
+ }
+ }
+}
View
123 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/MySQL.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 1.0.0
+ */
+
+/**
+ * Provides functionality to retrieve meta data from a MySQL database.
+ *
+ * @package DbUnit
+ * @author Mike Lively <m@digitalsandwich.com>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 1.0.0
+ */
+class PHPUnit_Extensions_Database_DB_MetaData_MySQL extends PHPUnit_Extensions_Database_DB_MetaData
+{
+ protected $schemaObjectQuoteChar = '`';
+
+ /**
+ * Returns an array containing the names of all the tables in the database.
+ *
+ * @return array
+ */
+ public function getTableNames()
+ {
+ $query = 'SHOW TABLES';
+ $statement = $this->pdo->prepare($query);
+ $statement->execute();
+
+ $tableNames = array();
+ while (($tableName = $statement->fetchColumn(0))) {
+ $tableNames[] = $tableName;
+ }
+
+ return $tableNames;
+ }
+
+ /**
+ * Returns an array containing the names of all the columns in the
+ * $tableName table,
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTableColumns($tableName)
+ {
+ $query = 'SHOW COLUMNS FROM ' . $this->quoteSchemaObject($tableName);
+ $statement = $this->pdo->prepare($query);
+ $statement->execute();
+
+ $columnNames = array();
+ while (($columnName = $statement->fetchColumn(0))) {
+ $columnNames[] = $columnName;
+ }
+
+ return $columnNames;
+ }
+
+ /**
+ * Returns an array containing the names of all the primary key columns in
+ * the $tableName table.
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTablePrimaryKeys($tableName)
+ {
+ $query = 'SHOW INDEX FROM ' . $this->quoteSchemaObject($tableName);
+ $statement = $this->pdo->prepare($query);
+ $statement->execute();
+ $statement->setFetchMode(PDO::FETCH_ASSOC);
+
+ $columnNames = array();
+ while (($column = $statement->fetch())) {
+ if ($column['Key_name'] == 'PRIMARY') {
+ $columnNames[] = $column['Column_name'];
+ }
+ }
+
+ return $columnNames;
+ }
+}
View
180 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/Oci.php
@@ -0,0 +1,180 @@
+<?php
+/**
+ * PHPUnit
+ *
+ * Copyright (c) 2002-2011, 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.
+ *
+ * @package DbUnit
+ * @author Trond Hansen <trond@xait.no>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @link http://www.phpunit.de/
+ * @since File available since Release 3.2.3
+ */
+
+/**
+ * Provides functionality to retrieve meta data from an Oracle database.
+ *
+ * @package DbUnit
+ * @author Trond Hansen <trond@xait.no>
+ * @copyright 2002-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 1.0.1
+ * @link http://www.phpunit.de/
+ * @since Class available since Release 3.2.3
+ */
+class PHPUnit_Extensions_Database_DB_MetaData_Oci extends PHPUnit_Extensions_Database_DB_MetaData
+{
+ /**
+ * No character used to quote schema objects.
+ * @var string
+ */
+ protected $schemaObjectQuoteChar = '';
+
+ /**
+ * The command used to perform a TRUNCATE operation.
+ * @var string
+ */
+ protected $truncateCommand = 'TRUNCATE TABLE';
+
+ /**
+ * @var array
+ */
+ protected $columns = array();
+
+ /**
+ * @var array
+ */
+ protected $keys = array();
+
+ /**
+ * Returns an array containing the names of all the tables in the database.
+ *
+ * @return array
+ */
+ public function getTableNames()
+ {
+ $tableNames = array();
+
+ $query = "SELECT table_name
+ FROM cat
+ WHERE table_type='TABLE'
+ ORDER BY table_name";
+
+ $result = $this->pdo->query($query);
+
+ while ($tableName = $result->fetchColumn(0)) {
+ $tableNames[] = $tableName;
+ }
+
+ return $tableNames;
+ }
+
+ /**
+ * Returns an array containing the names of all the columns in the
+ * $tableName table,
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTableColumns($tableName)
+ {
+ if (!isset($this->columns[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->columns[$tableName];
+ }
+
+ /**
+ * Returns an array containing the names of all the primary key columns in
+ * the $tableName table.
+ *
+ * @param string $tableName
+ * @return array
+ */
+ public function getTablePrimaryKeys($tableName)
+ {
+ if (!isset($this->keys[$tableName])) {
+ $this->loadColumnInfo($tableName);
+ }
+
+ return $this->keys[$tableName];
+ }
+
+ /**
+ * Loads column info from a oracle database.
+ *
+ * @param string $tableName
+ */
+ protected function loadColumnInfo($tableName)
+ {
+ $ownerQuery = '';
+ $conOwnerQuery = '';
+ $tableParts = $this->splitTableName($tableName);
+
+ $this->columns[$tableName] = array();
+ $this->keys[$tableName] = array();
+
+ if (!empty($tableParts['schema']))
+ {
+ $ownerQuery = " AND OWNER = '{$tableParts['schema']}'";
+ $conOwnerQuery = " AND a.owner = '{$tableParts['schema']}'";
+ }
+
+ $query = "SELECT DISTINCT COLUMN_NAME
+ FROM USER_TAB_COLUMNS
+ WHERE TABLE_NAME='".$tableParts['table']."'
+ $ownerQuery
+ ORDER BY COLUMN_NAME";
+
+ $result = $this->pdo->query($query);
+
+ while ($columnName = $result->fetchColumn(0)) {
+ $this->columns[$tableName][] = $columnName;
+ }
+
+ $keyQuery = "SELECT b.column_name
+ FROM user_constraints a, user_cons_columns b
+ WHERE a.constraint_type='P'
+ AND a.constraint_name=b.constraint_name
+ $conOwnerQuery
+ AND a.table_name = '".$tableParts['table']."' ";
+
+ $result = $this->pdo->query($keyQuery);
+
+ while ($columnName = $result->fetchColumn(0)) {
+ $this->keys[$tableName][] = $columnName;
+ }
+ }
+}
View
193 libs/PHPUnit-3.5.0/Extensions/Database/DB/MetaData/PgSQL.php