[
  {
    "path": ".gitattributes",
    "content": "*.php diff=php\n"
  },
  {
    "path": ".gitignore",
    "content": "/.idea\n/.php_cs.cache\n/composer.lock\n/build\n/vendor\n/tools\n"
  },
  {
    "path": ".php_cs.dist",
    "content": "<?php\n$header = <<<'EOF'\nThis file is part of DbUnit.\n\n(c) Sebastian Bergmann <sebastian@phpunit.de>\n\nFor the full copyright and license information, please view the LICENSE\nfile that was distributed with this source code.\nEOF;\n\nreturn PhpCsFixer\\Config::create()\n    ->setRiskyAllowed(true)\n    ->setRules(\n        [\n            'array_syntax' => ['syntax' => 'short'],\n            'binary_operator_spaces' => [\n                'operators' => [\n                    '=' => 'align',\n                    '=>' => 'align',\n                ],\n            ],\n            'blank_line_after_namespace' => true,\n            'blank_line_before_statement' => [\n                'statements' => [\n                    'break',\n                    'continue',\n                    'declare',\n                    'do',\n                    'for',\n                    'foreach',\n                    'if',\n                    'include',\n                    'include_once',\n                    'require',\n                    'require_once',\n                    'return',\n                    'switch',\n                    'throw',\n                    'try',\n                    'while',\n                    'yield',\n                ],\n            ],\n            'braces' => true,\n            'cast_spaces' => true,\n            'class_attributes_separation' => ['elements' => ['method']],\n            'compact_nullable_typehint' => true,\n            'concat_space' => ['spacing' => 'one'],\n            'declare_equal_normalize' => ['space' => 'none'],\n            'dir_constant' => true,\n            'elseif' => true,\n            'encoding' => true,\n            'full_opening_tag' => true,\n            'function_declaration' => true,\n            'header_comment' => ['header' => $header, 'separate' => 'none'],\n            'indentation_type' => true,\n            'line_ending' => true,\n            'list_syntax' => ['syntax' => 'short'],\n            'lowercase_cast' => true,\n            'lowercase_constants' => true,\n            'lowercase_keywords' => true,\n            'magic_constant_casing' => true,\n            'method_argument_space' => ['ensure_fully_multiline' => true],\n            'modernize_types_casting' => true,\n            'native_function_casing' => true,\n            'native_function_invocation' => true,\n            'no_alias_functions' => true,\n            'no_blank_lines_after_class_opening' => true,\n            'no_blank_lines_after_phpdoc' => true,\n            'no_closing_tag' => true,\n            'no_empty_comment' => true,\n            'no_empty_phpdoc' => true,\n            'no_empty_statement' => true,\n            'no_extra_blank_lines' => true,\n            'no_homoglyph_names' => true,\n            'no_leading_import_slash' => true,\n            'no_leading_namespace_whitespace' => true,\n            'no_mixed_echo_print' => ['use' => 'print'],\n            'no_null_property_initialization' => true,\n            'no_short_bool_cast' => true,\n            'no_short_echo_tag' => true,\n            'no_singleline_whitespace_before_semicolons' => true,\n            'no_spaces_after_function_name' => true,\n            'no_spaces_inside_parenthesis' => true,\n            'no_superfluous_elseif' => true,\n            'no_trailing_comma_in_list_call' => true,\n            'no_trailing_comma_in_singleline_array' => true,\n            'no_trailing_whitespace' => true,\n            'no_trailing_whitespace_in_comment' => true,\n            'no_unneeded_control_parentheses' => true,\n            'no_unneeded_curly_braces' => true,\n            'no_unneeded_final_method' => true,\n            'no_unreachable_default_argument_value' => true,\n            'no_unused_imports' => true,\n            'no_useless_else' => true,\n            'no_whitespace_before_comma_in_array' => true,\n            'no_whitespace_in_blank_line' => true,\n            'non_printable_character' => true,\n            'normalize_index_brace' => true,\n            'object_operator_without_whitespace' => true,\n            'ordered_class_elements' => [\n                'order' => [\n                    'use_trait',\n                    'constant_public',\n                    'constant_protected',\n                    'constant_private',\n                    'property_public_static',\n                    'property_protected_static',\n                    'property_private_static',\n                    'property_public',\n                    'property_protected',\n                    'property_private',\n                    'method_public_static',\n                    'construct',\n                    'destruct',\n                    'magic',\n                    'phpunit',\n                    'method_public',\n                    'method_protected',\n                    'method_private',\n                    'method_protected_static',\n                    'method_private_static',\n                ],\n            ],\n            'ordered_imports' => true,\n            'phpdoc_add_missing_param_annotation' => true,\n            'phpdoc_align' => true,\n            'phpdoc_annotation_without_dot' => true,\n            'phpdoc_indent' => true,\n            'phpdoc_no_access' => true,\n            'phpdoc_no_empty_return' => true,\n            'phpdoc_no_package' => true,\n            'phpdoc_order' => true,\n            'phpdoc_return_self_reference' => true,\n            'phpdoc_scalar' => true,\n            'phpdoc_separation' => true,\n            'phpdoc_single_line_var_spacing' => true,\n            'phpdoc_to_comment' => true,\n            'phpdoc_trim' => true,\n            'phpdoc_types' => true,\n            'phpdoc_types_order' => true,\n            'phpdoc_var_without_name' => true,\n            'pow_to_exponentiation' => true,\n            'protected_to_private' => true,\n            'return_type_declaration' => ['space_before' => 'none'],\n            'self_accessor' => true,\n            'short_scalar_cast' => true,\n            'simplified_null_return' => true,\n            'single_blank_line_at_eof' => true,\n            'single_import_per_statement' => true,\n            'single_line_after_imports' => true,\n            'single_quote' => true,\n            'standardize_not_equals' => true,\n            'ternary_to_null_coalescing' => true,\n            'trim_array_spaces' => true,\n            'unary_operator_spaces' => true,\n            'visibility_required' => true,\n            'void_return' => true,\n            'whitespace_after_comma_in_array' => true,\n        ]\n    )\n    ->setFinder(\n        PhpCsFixer\\Finder::create()\n        ->files()\n        ->in(__DIR__ . '/src')\n        ->in(__DIR__ . '/tests')\n        ->notName('*.phpt')\n    );\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: php\n\nsudo: false\n\nphp:\n  - 7.1\n  - 7.2\n  - master\n\nservices:\n  - mysql\n\nenv:\n  matrix:\n    - DEPENDENCIES=\"high\"\n    - DEPENDENCIES=\"low\"\n  global:\n    - DEFAULT_COMPOSER_FLAGS=\"--no-interaction --no-ansi --no-progress --no-suggest\"\n\nbefore_install:\n  - composer self-update\n  - composer clear-cache\n  - mysql -e 'CREATE DATABASE IF NOT EXISTS dbunit;'\n\ninstall:\n  - if [[ \"$DEPENDENCIES\" = 'high' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS; fi\n  - if [[ \"$DEPENDENCIES\" = 'low' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi\n\nscript:\n  - ./vendor/bin/phpunit --configuration phpunit-travis.xml\n\nnotifications:\n  email: false\n\n"
  },
  {
    "path": "ChangeLog.md",
    "content": "# Changes in DbUnit\n\nAll notable changes to DbUnit are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.\n\n## [4.0.0] - 2018-02-07\n\n### Removed\n\n* This extension now requires PHPUnit 7\n* This extension is no longer supported on PHP 7.0\n\n## [3.0.3] - 2018-01-23\n\n### Fixed\n\n* Fixed [#191](https://github.com/sebastianbergmann/dbunit/pull/191): MySQL's `FOREIGN_KEY_CHECKS` setting gets lost\n* Fixed [#192](https://github.com/sebastianbergmann/dbunit/pull/192): Error message for wrong fixture is not good enough\n* Fixed [#201](https://github.com/sebastianbergmann/dbunit/pull/201): `TestCaseTrait::tearDown()` does not call parent's `tearDown()`\n* Fixed [#204](https://github.com/sebastianbergmann/dbunit/pull/204): `DefaultConnection::close()` does not close database connection\n* Fixed [#205](https://github.com/sebastianbergmann/dbunit/pull/205): Metadata for empty SQLite table is not handled correctly\n\n## [3.0.2] - 2017-11-18\n\n### Changed\n\n* This extension is now compatible with Symfony Console 4\n\n## [3.0.1] - 2017-10-19\n\n### Fixed\n\n* Fixed [#193](https://github.com/sebastianbergmann/dbunit/pull/193): Multibyte values are not displayed correctly\n* Fixed [#195](https://github.com/sebastianbergmann/dbunit/issues/195): Empty tables are not displayed correctly\n\n## [3.0.0] - 2017-02-03\n\n### Changed\n\n* DbUnit's units of code are now namespaced\n* DbUnit is now compatible with, and requires, PHPUnit 6.0\n\n### Removed\n\n* The `dbunit` CLI tool was removed\n\n[4.0.0]: https://github.com/sebastianbergmann/dbunit/compare/3.0.3...4.0.0\n[3.0.3]: https://github.com/sebastianbergmann/dbunit/compare/3.0.2...3.0.3\n[3.0.2]: https://github.com/sebastianbergmann/dbunit/compare/3.0.1...3.0.2\n[3.0.1]: https://github.com/sebastianbergmann/dbunit/compare/3.0.0...3.0.1\n[3.0.0]: https://github.com/sebastianbergmann/dbunit/compare/2.0...3.0.0\n"
  },
  {
    "path": "LICENSE",
    "content": "DbUnit\n\nCopyright (c) 2002-2018, Sebastian Bergmann <sebastian@phpunit.de>.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions\nare met:\n\n * Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in\n   the documentation and/or other materials provided with the\n   distribution.\n\n * Neither the name of Sebastian Bergmann nor the names of his\n   contributors may be used to endorse or promote products derived\n   from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\nFOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\nBUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "README.md",
    "content": "[This extension is no longer maintained](https://github.com/sebastianbergmann/dbunit/issues/217)\n\n# DbUnit\n\n[PHPUnit](https://phpunit.de/) extension for database interaction testing.\n\n## Installation\n\n### Composer\n\nIf you use [Composer](https://getcomposer.org/) to manage the dependencies of your project then you can add DbUnit as a development-time dependency to your project:\n\n```\n$ composer require --dev phpunit/dbunit\n```\n\n### PHP Archive (PHAR)\n\nYou can download a PHAR of DbUnit:\n\n```\n$ wget https://phar.phpunit.de/dbunit.phar\n```\n\nThe example below shows how to configure PHPUnit to load all `*.phar` files found in a given directory (`tools/phpunit.d` in this example):\n\n```xml\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"https://schema.phpunit.de/6.0/phpunit.xsd\"\n         extensionsDirectory=\"tools/phpunit.d\">\n</phpunit>\n```\n"
  },
  {
    "path": "build.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"dbunit\" default=\"setup\">\n    <target name=\"setup\" depends=\"clean,install-dependencies\"/>\n\n    <target name=\"clean\" unless=\"clean.done\" description=\"Cleanup build artifacts\">\n        <delete dir=\"${basedir}/build\"/>\n        <delete dir=\"${basedir}/tools\"/>\n        <delete dir=\"${basedir}/vendor\"/>\n        <delete file=\"${basedir}/composer.lock\"/>\n\n        <property name=\"clean.done\" value=\"true\"/>\n    </target>\n\n    <target name=\"prepare\" unless=\"prepare.done\" depends=\"clean,install-dependencies,install-tools\" description=\"Prepare for build\">\n        <mkdir dir=\"${basedir}/build\"/>\n\n        <property name=\"prepare.done\" value=\"true\"/>\n    </target>\n\n    <target name=\"install-dependencies\" depends=\"clean\" description=\"Install dependencies with Composer\">\n        <exec executable=\"composer\" taskname=\"composer\">\n            <arg value=\"update\"/>\n            <arg value=\"--no-interaction\"/>\n            <arg value=\"--no-progress\"/>\n            <arg value=\"--no-ansi\"/>\n            <arg value=\"--no-suggest\"/>\n            <arg value=\"--optimize-autoloader\"/>\n            <arg value=\"--prefer-stable\"/>\n        </exec>\n    </target>\n\n    <target name=\"install-tools\" unless=\"tools-installed\" depends=\"-tools-installed\" description=\"Install tools using phive\">\n        <exec executable=\"phive\" taskname=\"phive\">\n            <arg value=\"install\"/>\n        </exec>\n    </target>\n\n    <target name=\"package\" depends=\"prepare,-get-version-number-from-git\" description=\"Package as PHAR\">\n        <copy todir=\"${basedir}/build/phar\" file=\"${basedir}/LICENSE\" />\n        <copy todir=\"${basedir}/build/phar\" file=\"${basedir}/manifest.xml\" />\n        <copy todir=\"${basedir}/build/phar/dbunit\">\n            <fileset dir=\"${basedir}/src\">\n                <include name=\"**/*\" />\n            </fileset>\n        </copy>\n\n        <copy file=\"${basedir}/vendor/symfony/yaml/LICENSE\" tofile=\"${basedir}/build/phar/symfony/LICENSE\"/>\n        <copy todir=\"${basedir}/build/phar/symfony\">\n            <fileset dir=\"${basedir}/vendor/symfony\">\n                <include name=\"**/*.php\" />\n                <exclude name=\"**/Tests/**\" />\n            </fileset>\n        </copy>\n\n        <exec executable=\"${basedir}/tools/phpab\" taskname=\"phpab\">\n            <arg value=\"--all\" />\n            <arg value=\"--phar\" />\n            <arg value=\"--output\" />\n            <arg path=\"${basedir}/build/dbunit-${version}.phar\" />\n            <arg path=\"${basedir}/build/phar\" />\n        </exec>\n\n        <delete dir=\"${basedir}/build/phar\"/>\n\n        <exec executable=\"gpg\" failonerror=\"true\">\n            <arg value=\"--local-user\"/>\n            <arg value=\"sb@sebastian-bergmann.de\"/>\n            <arg value=\"--armor\"/>\n            <arg value=\"--detach-sign\"/>\n            <arg path=\"${basedir}/build/dbunit-${version}.phar\"/>\n        </exec>\n    </target>\n\n    <target name=\"-get-version-number-from-git\">\n        <exec executable=\"bash\" outputproperty=\"version\" failonerror=\"true\" dir=\"${basedir}\">\n            <arg value=\"-c\" />\n            <arg value=\"/usr/bin/git describe --abbrev=0\" />\n        </exec>\n    </target>\n\n    <target name=\"-tools-installed\">\n        <available file=\"${basedir}/tools\" property=\"tools-installed\" type=\"dir\"/>\n    </target>\n</project>\n"
  },
  {
    "path": "composer.json",
    "content": "{\n    \"name\": \"phpunit/dbunit\",\n    \"description\": \"PHPUnit extension for database interaction testing\",\n    \"type\": \"library\",\n    \"keywords\": [\n        \"database\",\n        \"testing\",\n        \"xunit\"\n    ],\n    \"homepage\": \"https://github.com/sebastianbergmann/dbunit/\",\n    \"license\": \"BSD-3-Clause\",\n    \"authors\": [\n        {\n            \"name\": \"Sebastian Bergmann\",\n            \"email\": \"sebastian@phpunit.de\",\n            \"role\": \"lead\"\n        }\n    ],\n    \"support\": {\n        \"issues\": \"https://github.com/sebastianbergmann/dbunit/issues\"\n    },\n    \"require\": {\n        \"php\": \"^7.1\",\n        \"phpunit/phpunit\": \"^7.0\",\n        \"symfony/yaml\": \"^3.0 || ^4.0\",\n        \"ext-pdo\": \"*\",\n        \"ext-simplexml\": \"*\"\n    },\n    \"autoload\": {\n        \"classmap\": [\n            \"src/\"\n        ]\n    },\n    \"extra\": {\n        \"branch-alias\": {\n            \"dev-master\": \"4.0-dev\"\n        }\n    }\n}\n"
  },
  {
    "path": "manifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n    <contains name=\"phpunit/dbunit\" version=\"4.0.0\" type=\"extension\">\n        <extension for=\"phpunit/phpunit\" compatible=\"^7.0\"/>\n    </contains>\n\n    <copyright>\n        <author name=\"Sebastian Bergmann\" email=\"sebastian@phpunit.de\"/>\n        <license type=\"BSD-3-Clause\" url=\"https://github.com/sebastianbergmann/dbunit/blob/master/LICENSE\"/>\n    </copyright>\n\n    <requires>\n        <php version=\"^7.1\"/>\n    </requires>\n</phar>\n"
  },
  {
    "path": "phive.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phive xmlns=\"https://phar.io/phive\">\n  <phar name=\"phpab\" version=\"^1.24.1\" installed=\"1.24.1\" location=\"./tools/phpab\"/>\n</phive>\n"
  },
  {
    "path": "phpunit-travis.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"https://schema.phpunit.de/6.0/phpunit.xsd\"\n         bootstrap=\"vendor/autoload.php\"\n         beStrictAboutCoversAnnotation=\"true\"\n         beStrictAboutOutputDuringTests=\"true\"\n         beStrictAboutTodoAnnotatedTests=\"true\"\n         verbose=\"true\">\n    <testsuite>\n        <directory suffix=\"Test.php\">tests/Constraint</directory>\n        <directory suffix=\"Test.php\">tests/DataSet</directory>\n        <directory suffix=\"Test.php\">tests/Operation</directory>\n        <directory suffix=\"Test.php\">tests/DB</directory>\n    </testsuite>\n\n    <php>\n        <const name=\"PHPUNIT_TESTSUITE\" value=\"true\"/>\n        <const name=\"PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN\" value=\"mysql:host=127.0.0.1;dbname=dbunit;port=3306\"/>\n        <const name=\"PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_USERNAME\" value=\"root\"/>\n        <const name=\"PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_PASSWORD\" value=\"\"/>\n    </php>\n\n    <filter>\n        <whitelist processUncoveredFilesFromWhitelist=\"true\">\n            <directory suffix=\".php\">src</directory>\n        </whitelist>\n    </filter>\n</phpunit>\n"
  },
  {
    "path": "phpunit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"https://schema.phpunit.de/6.0/phpunit.xsd\"\n         bootstrap=\"vendor/autoload.php\"\n         beStrictAboutCoversAnnotation=\"true\"\n         beStrictAboutOutputDuringTests=\"true\"\n         beStrictAboutTodoAnnotatedTests=\"true\"\n         verbose=\"true\">\n    <testsuite>\n        <directory suffix=\"Test.php\">tests/Constraint</directory>\n        <directory suffix=\"Test.php\">tests/DataSet</directory>\n        <directory suffix=\"Test.php\">tests/Operation</directory>\n        <directory suffix=\"Test.php\">tests/DB</directory>\n    </testsuite>\n\n    <php>\n        <const name=\"PHPUNIT_TESTSUITE\" value=\"true\"/>\n        <!--<const name=\"PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN\" value=\"mysql:host=127.0.0.1;dbname=phpunit_tests;port=3306\"/>-->\n        <!--<const name=\"PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_USERNAME\" value=\"root\"/>-->\n        <!--<const name=\"PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_PASSWORD\" value=\"\"/>-->\n    </php>\n\n    <filter>\n        <whitelist processUncoveredFilesFromWhitelist=\"true\">\n            <directory suffix=\".php\">src</directory>\n        </whitelist>\n    </filter>\n</phpunit>\n"
  },
  {
    "path": "src/AbstractTester.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\Operation\\Factory;\nuse PHPUnit\\DbUnit\\Operation\\Operation;\n\n/**\n * Can be used as a foundation for new DatabaseTesters.\n */\nabstract class AbstractTester implements Tester\n{\n    /**\n     * @var Operation\n     */\n    protected $setUpOperation;\n\n    /**\n     * @var Operation\n     */\n    protected $tearDownOperation;\n\n    /**\n     * @var IDataSet\n     */\n    protected $dataSet;\n\n    /**\n     * @var string\n     */\n    protected $schema;\n\n    /**\n     * Creates a new database tester.\n     */\n    public function __construct()\n    {\n        $this->setUpOperation    = Factory::CLEAN_INSERT();\n        $this->tearDownOperation = Factory::NONE();\n    }\n\n    /**\n     * Closes the specified connection.\n     *\n     * @param Connection $connection\n     */\n    public function closeConnection(Connection $connection): void\n    {\n        $connection->close();\n    }\n\n    /**\n     * Returns the test dataset.\n     *\n     * @return IDataSet\n     */\n    public function getDataSet()\n    {\n        return $this->dataSet;\n    }\n\n    /**\n     * TestCases must call this method inside setUp().\n     */\n    public function onSetUp(): void\n    {\n        $this->getSetUpOperation()->execute($this->getConnection(), $this->getDataSet());\n    }\n\n    /**\n     * TestCases must call this method inside tearDown().\n     */\n    public function onTearDown(): void\n    {\n        $this->getTearDownOperation()->execute($this->getConnection(), $this->getDataSet());\n    }\n\n    /**\n     * Sets the test dataset to use.\n     *\n     * @param IDataSet $dataSet\n     */\n    public function setDataSet(IDataSet $dataSet): void\n    {\n        $this->dataSet = $dataSet;\n    }\n\n    /**\n     * Sets the schema value.\n     *\n     * @param string $schema\n     */\n    public function setSchema($schema): void\n    {\n        $this->schema = $schema;\n    }\n\n    /**\n     * Sets the DatabaseOperation to call when starting the test.\n     *\n     * @param Operation $setUpOperation\n     */\n    public function setSetUpOperation(Operation $setUpOperation): void\n    {\n        $this->setUpOperation = $setUpOperation;\n    }\n\n    /**\n     * Sets the DatabaseOperation to call when ending the test.\n     *\n     * @param Operation $tearDownOperation\n     */\n    public function setTearDownOperation(Operation $tearDownOperation): void\n    {\n        $this->tearDownOperation = $tearDownOperation;\n    }\n\n    /**\n     * Returns the schema value\n     *\n     * @return string\n     */\n    protected function getSchema()\n    {\n        return $this->schema;\n    }\n\n    /**\n     * Returns the database operation that will be called when starting the test.\n     *\n     * @return Operation\n     */\n    protected function getSetUpOperation()\n    {\n        return $this->setUpOperation;\n    }\n\n    /**\n     * Returns the database operation that will be called when ending the test.\n     *\n     * @return Operation\n     */\n    protected function getTearDownOperation()\n    {\n        return $this->tearDownOperation;\n    }\n}\n"
  },
  {
    "path": "src/Constraint/DataSetIsEqual.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Constraint;\n\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\nuse PHPUnit\\Framework\\Constraint\\Constraint;\n\n/**\n * Asserts whether or not two dbunit datasets are equal.\n */\nclass DataSetIsEqual extends Constraint\n{\n    /**\n     * @var IDataSet\n     */\n    protected $value;\n\n    /**\n     * @var string\n     */\n    protected $failure_reason;\n\n    /**\n     * Creates a new constraint.\n     *\n     * @param IDataSet $value\n     */\n    public function __construct(IDataSet $value)\n    {\n        parent::__construct();\n        $this->value = $value;\n    }\n\n    /**\n     * Returns a string representation of the constraint.\n     *\n     * @return string\n     */\n    public function toString(): string\n    {\n        return \\sprintf(\n            'is equal to expected %s',\n            $this->value->__toString()\n        );\n    }\n\n    /**\n     * Evaluates the constraint for parameter $other. Returns TRUE if the\n     * constraint is met, FALSE otherwise.\n     *\n     * This method can be overridden to implement the evaluation algorithm.\n     *\n     * @param mixed $other value or object to evaluate\n     *\n     * @return bool\n     */\n    protected function matches($other): bool\n    {\n        if (!$other instanceof IDataSet) {\n            throw new InvalidArgumentException(\n                'PHPUnit_Extensions_Database_DataSet_IDataSet expected'\n            );\n        }\n\n        return $this->value->matches($other);\n    }\n\n    /**\n     * Returns the description of the failure\n     *\n     * The beginning of failure messages is \"Failed asserting that\" in most\n     * cases. This method should return the second part of that sentence.\n     *\n     * @param mixed $other evaluated value or object\n     *\n     * @return string\n     */\n    protected function failureDescription($other): string\n    {\n        return $other->__toString() . ' ' . $this->toString();\n    }\n}\n"
  },
  {
    "path": "src/Constraint/TableIsEqual.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Constraint;\n\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\nuse PHPUnit\\Framework\\Constraint\\Constraint;\n\n/**\n * Asserts whether or not two dbunit tables are equal.\n */\nclass TableIsEqual extends Constraint\n{\n    /**\n     * @var ITable\n     */\n    protected $value;\n\n    /**\n     * @var string\n     */\n    protected $failure_reason;\n\n    /**\n     * Creates a new constraint.\n     *\n     * @param ITable $value\n     */\n    public function __construct(ITable $value)\n    {\n        parent::__construct();\n        $this->value = $value;\n    }\n\n    /**\n     * Returns a string representation of the constraint.\n     *\n     * @return string\n     */\n    public function toString(): string\n    {\n        return \\sprintf(\n            'is equal to expected %s',\n            $this->value->__toString()\n        );\n    }\n\n    /**\n     * Evaluates the constraint for parameter $other. Returns TRUE if the\n     * constraint is met, FALSE otherwise.\n     *\n     * This method can be overridden to implement the evaluation algorithm.\n     *\n     * @param mixed $other value or object to evaluate\n     *\n     * @return bool\n     */\n    protected function matches($other): bool\n    {\n        if (!$other instanceof ITable) {\n            throw new InvalidArgumentException(\n                'PHPUnit_Extensions_Database_DataSet_ITable expected'\n            );\n        }\n\n        return $this->value->matches($other);\n    }\n\n    /**\n     * Returns the description of the failure\n     *\n     * The beginning of failure messages is \"Failed asserting that\" in most\n     * cases. This method should return the second part of that sentence.\n     *\n     * @param mixed $other evaluated value or object\n     *\n     * @return string\n     */\n    protected function failureDescription($other): string\n    {\n        return $other->__toString() . ' ' . $this->toString();\n    }\n}\n"
  },
  {
    "path": "src/Constraint/TableRowCount.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Constraint;\n\nuse PHPUnit\\Framework\\Constraint\\Constraint;\n\n/**\n * Asserts the row count in a table\n */\nclass TableRowCount extends Constraint\n{\n    /**\n     * @var int\n     */\n    protected $value;\n\n    /**\n     * @var string\n     */\n    protected $tableName;\n\n    /**\n     * Creates a new constraint.\n     *\n     * @param $tableName\n     * @param $value\n     */\n    public function __construct($tableName, $value)\n    {\n        parent::__construct();\n        $this->tableName = $tableName;\n        $this->value     = $value;\n    }\n\n    /**\n     * Returns a string representation of the constraint.\n     *\n     * @return string\n     */\n    public function toString(): string\n    {\n        return \\sprintf('is equal to expected row count %d', $this->value);\n    }\n\n    /**\n     * Evaluates the constraint for parameter $other. Returns TRUE if the\n     * constraint is met, FALSE otherwise.\n     *\n     * This method can be overridden to implement the evaluation algorithm.\n     *\n     * @param mixed $other value or object to evaluate\n     *\n     * @return bool\n     */\n    protected function matches($other): bool\n    {\n        return $other == $this->value;\n    }\n}\n"
  },
  {
    "path": "src/DataSet/AbstractDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * Implements the basic functionality of data sets.\n */\nabstract class AbstractDataSet implements IDataSet\n{\n    public function __toString()\n    {\n        $iterator = $this->getIterator();\n\n        $dataSetString = '';\n\n        foreach ($iterator as $table) {\n            $dataSetString .= $table->__toString();\n        }\n\n        return $dataSetString;\n    }\n\n    /**\n     * Returns an array of table names contained in the dataset.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $tableNames = [];\n\n        foreach ($this->getIterator() as $table) {\n            /* @var $table ITable */\n            $tableNames[] = $table->getTableMetaData()->getTableName();\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns a table meta data object for the given table.\n     *\n     * @param string $tableName\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData($tableName)\n    {\n        return $this->getTable($tableName)->getTableMetaData();\n    }\n\n    /**\n     * Returns a table object for the given table.\n     *\n     * @param string $tableName\n     *\n     * @return ITable\n     */\n    public function getTable($tableName)\n    {\n        foreach ($this->getIterator() as $table) {\n            /* @var $table ITable */\n            if ($table->getTableMetaData()->getTableName() == $tableName) {\n                return $table;\n            }\n        }\n    }\n\n    /**\n     * Returns an iterator for all table objects in the given dataset.\n     *\n     * @return ITableIterator\n     */\n    public function getIterator()\n    {\n        return $this->createIterator();\n    }\n\n    /**\n     * Returns a reverse iterator for all table objects in the given dataset.\n     *\n     * @return ITableIterator\n     */\n    public function getReverseIterator()\n    {\n        return $this->createIterator(true);\n    }\n\n    /**\n     * Asserts that the given data set matches this data set.\n     *\n     * @param IDataSet $other\n     */\n    public function matches(IDataSet $other)\n    {\n        $thisTableNames  = $this->getTableNames();\n        $otherTableNames = $other->getTableNames();\n\n        \\sort($thisTableNames);\n        \\sort($otherTableNames);\n\n        if ($thisTableNames != $otherTableNames) {\n            return false;\n        }\n\n        foreach ($thisTableNames as $tableName) {\n            $table = $this->getTable($tableName);\n\n            if (!$table->matches($other->getTable($tableName))) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    abstract protected function createIterator($reverse = false);\n}\n"
  },
  {
    "path": "src/DataSet/AbstractTable.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\nuse SimpleXMLElement;\n\n/**\n * Provides a basic functionality for dbunit tables\n */\nclass AbstractTable implements ITable\n{\n    /**\n     * @var ITableMetadata\n     */\n    protected $tableMetaData;\n\n    /**\n     * A 2-dimensional array containing the data for this table.\n     *\n     * @var array\n     */\n    protected $data;\n\n    /**\n     * @var null|ITable\n     */\n    private $other;\n\n    public function __toString()\n    {\n        $columns = $this->getTableMetaData()->getColumns();\n        $count   = \\count($columns);\n\n        // if count less than 0 (when table is empty), then set count to 1\n        $count         = $count >= 1 ? $count : 1;\n        $lineSeparator = \\str_repeat('+----------------------', $count) . \"+\\n\";\n        $lineLength    = \\strlen($lineSeparator) - 1;\n\n        $tableString = $lineSeparator;\n        $tblName     = $this->getTableMetaData()->getTableName();\n        $tableString .= '| ' . \\str_pad(\n            $tblName,\n            $lineLength - 4,\n            ' ',\n                STR_PAD_RIGHT\n        ) . \" |\\n\";\n        $tableString .= $lineSeparator;\n        $rows = $this->rowToString($columns);\n        $tableString .= !empty($rows) ? $rows . $lineSeparator : '';\n\n        $rowCount = $this->getRowCount();\n\n        for ($i = 0; $i < $rowCount; $i++) {\n            $values = [];\n\n            foreach ($columns as $columnName) {\n                if ($this->other) {\n                    try {\n                        if ($this->getValue($i, $columnName) != $this->other->getValue($i, $columnName)) {\n                            $values[] = \\sprintf(\n                                '%s != actual %s',\n                                \\var_export($this->getValue($i, $columnName), true),\n                                \\var_export($this->other->getValue($i, $columnName), true)\n                            );\n                        } else {\n                            $values[] = $this->getValue($i, $columnName);\n                        }\n                    } catch (\\InvalidArgumentException $ex) {\n                        $values[] = $this->getValue($i, $columnName) . ': no row';\n                    }\n                } else {\n                    $values[] = $this->getValue($i, $columnName);\n                }\n            }\n\n            $tableString .= $this->rowToString($values) . $lineSeparator;\n        }\n\n        return ($this->other ? '(table diff enabled)' : '') . \"\\n\" . $tableString . \"\\n\";\n    }\n\n    /**\n     * Returns the table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData()\n    {\n        return $this->tableMetaData;\n    }\n\n    /**\n     * Returns the number of rows in this table.\n     *\n     * @return int\n     */\n    public function getRowCount()\n    {\n        return \\count($this->data);\n    }\n\n    /**\n     * Returns the value for the given column on the given row.\n     *\n     * @param int $row\n     * @param int $column\n     *\n     * @todo reorganize this function to throw the exception first.\n     */\n    public function getValue($row, $column)\n    {\n        if (isset($this->data[$row][$column])) {\n            $value = $this->data[$row][$column];\n\n            return ($value instanceof SimpleXMLElement) ? (string) $value : $value;\n        }\n\n        if (!\\in_array($column, $this->getTableMetaData()->getColumns()) || $this->getRowCount() <= $row) {\n            throw new InvalidArgumentException(\"The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}\");\n        }\n\n        return;\n    }\n\n    /**\n     * Returns the an associative array keyed by columns for the given row.\n     *\n     * @param int $row\n     *\n     * @return array\n     */\n    public function getRow($row)\n    {\n        if (isset($this->data[$row])) {\n            return $this->data[$row];\n        }\n\n        if ($this->getRowCount() <= $row) {\n            throw new InvalidArgumentException(\"The given row ({$row}) does not exist in table {$this->getTableMetaData()->getTableName()}\");\n        }\n\n        return;\n    }\n\n    /**\n     * Asserts that the given table matches this table.\n     *\n     * @param ITable $other\n     */\n    public function matches(ITable $other)\n    {\n        $thisMetaData  = $this->getTableMetaData();\n        $otherMetaData = $other->getTableMetaData();\n\n        if (!$thisMetaData->matches($otherMetaData) ||\n            $this->getRowCount() != $other->getRowCount()\n        ) {\n            return false;\n        }\n\n        $columns  = $thisMetaData->getColumns();\n        $rowCount = $this->getRowCount();\n\n        for ($i = 0; $i < $rowCount; $i++) {\n            foreach ($columns as $columnName) {\n                $thisValue  = $this->getValue($i, $columnName);\n                $otherValue = $other->getValue($i, $columnName);\n\n                if (\\is_numeric($thisValue) && \\is_numeric($otherValue)) {\n                    if ($thisValue != $otherValue) {\n                        $this->other = $other;\n\n                        return false;\n                    }\n                } elseif ($thisValue !== $otherValue) {\n                    $this->other = $other;\n\n                    return false;\n                }\n            }\n        }\n\n        return true;\n    }\n\n    /**\n     * Checks if a given row is in the table\n     *\n     * @param array $row\n     *\n     * @return bool\n     */\n    public function assertContainsRow(array $row)\n    {\n        return \\in_array($row, $this->data);\n    }\n\n    /**\n     * Sets the metadata for this table.\n     *\n     * @param ITableMetadata $tableMetaData\n     *\n     * @deprecated\n     */\n    protected function setTableMetaData(ITableMetadata $tableMetaData): void\n    {\n        $this->tableMetaData = $tableMetaData;\n    }\n\n    protected function rowToString(array $row)\n    {\n        $rowString = '';\n\n        foreach ($row as $value) {\n            if (null === $value) {\n                $value = 'NULL';\n            }\n\n            $value_str = \\mb_substr($value, 0, 20);\n\n            // make str_pad act in multibyte manner\n            $correction = \\strlen($value_str) - \\mb_strlen($value_str);\n            $rowString .= '| ' . \\str_pad($value_str, 20 + $correction, ' ', STR_PAD_BOTH) . ' ';\n        }\n\n        /** @see https://github.com/sebastianbergmann/dbunit/issues/195 */\n        $rowString = !empty($row) ? $rowString . \"|\\n\" : '';\n\n        return $rowString;\n    }\n}\n"
  },
  {
    "path": "src/DataSet/AbstractTableMetadata.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * Provides basic functionality for table meta data.\n */\nabstract class AbstractTableMetadata implements ITableMetadata\n{\n    /**\n     * The names of all columns in the table.\n     *\n     * @var array\n     */\n    protected $columns;\n\n    /**\n     * The names of all the primary keys in the table.\n     *\n     * @var array\n     */\n    protected $primaryKeys;\n\n    /**\n     * @var string\n     */\n    protected $tableName;\n\n    /**\n     * Returns the names of the columns in the table.\n     *\n     * @return array\n     */\n    public function getColumns()\n    {\n        return $this->columns;\n    }\n\n    /**\n     * Returns the names of the primary key columns in the table.\n     *\n     * @return array\n     */\n    public function getPrimaryKeys()\n    {\n        return $this->primaryKeys;\n    }\n\n    /**\n     * Returns the name of the table.\n     *\n     * @return string\n     */\n    public function getTableName()\n    {\n        return $this->tableName;\n    }\n\n    /**\n     * Asserts that the given tableMetaData matches this tableMetaData.\n     *\n     * @param ITableMetadata $other\n     */\n    public function matches(ITableMetadata $other)\n    {\n        if ($this->getTableName() != $other->getTableName() ||\n            $this->getColumns() != $other->getColumns()\n        ) {\n            return false;\n        }\n\n        return true;\n    }\n}\n"
  },
  {
    "path": "src/DataSet/AbstractXmlDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\nuse RuntimeException;\nuse SimpleXmlElement;\n\n/**\n * The default implementation of a data set.\n */\nabstract class AbstractXmlDataSet extends AbstractDataSet\n{\n    /**\n     * @var array\n     */\n    protected $tables;\n\n    /**\n     * @var SimpleXmlElement\n     */\n    protected $xmlFileContents;\n\n    /**\n     * Creates a new dataset using the given tables.\n     *\n     * @param array $tables\n     * @param mixed $xmlFile\n     */\n    public function __construct($xmlFile)\n    {\n        if (!\\is_file($xmlFile)) {\n            throw new InvalidArgumentException(\n                \"Could not find xml file: {$xmlFile}\"\n            );\n        }\n\n        $libxmlEntityLoader    = \\libxml_disable_entity_loader(false);\n        $libxmlErrorReporting  = \\libxml_use_internal_errors(true);\n        $this->xmlFileContents = \\simplexml_load_file($xmlFile, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);\n\n        if (!$this->xmlFileContents) {\n            $message = '';\n\n            foreach (\\libxml_get_errors() as $error) {\n                $message .= \\print_r($error, true);\n            }\n\n            throw new RuntimeException($message);\n        }\n\n        \\libxml_clear_errors();\n        \\libxml_use_internal_errors($libxmlErrorReporting);\n        \\libxml_disable_entity_loader($libxmlEntityLoader);\n\n        $tableColumns = [];\n        $tableValues  = [];\n\n        $this->getTableInfo($tableColumns, $tableValues);\n        $this->createTables($tableColumns, $tableValues);\n    }\n\n    /**\n     * Reads the simple xml object and creates the appropriate tables and meta\n     * data for this dataset.\n     */\n    abstract protected function getTableInfo(array &$tableColumns, array &$tableValues);\n\n    protected function createTables(array &$tableColumns, array &$tableValues): void\n    {\n        foreach ($tableValues as $tableName => $values) {\n            $table = $this->getOrCreateTable($tableName, $tableColumns[$tableName]);\n\n            foreach ($values as $value) {\n                $table->addRow($value);\n            }\n        }\n    }\n\n    /**\n     * Returns the table with the matching name. If the table does not exist\n     * an empty one is created.\n     *\n     * @param string $tableName\n     * @param mixed  $tableColumns\n     *\n     * @return ITable\n     */\n    protected function getOrCreateTable($tableName, $tableColumns)\n    {\n        if (empty($this->tables[$tableName])) {\n            $tableMetaData            = new DefaultTableMetadata($tableName, $tableColumns);\n            $this->tables[$tableName] = new DefaultTable($tableMetaData);\n        }\n\n        return $this->tables[$tableName];\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        return new DefaultTableIterator($this->tables, $reverse);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/ArrayDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * Implements the basic functionality of data sets using a PHP array.\n */\nclass ArrayDataSet extends AbstractDataSet\n{\n    /**\n     * @var array\n     */\n    protected $tables = [];\n\n    /**\n     * Constructor to build a new ArrayDataSet with the given array.\n     * The array parameter is an associative array of tables where the key is\n     * the table name and the value an array of rows. Each row is an associative\n     * array by itself with keys representing the field names and the values the\n     * actual data.\n     * For example:\n     * array(\n     *     \"addressbook\" => array(\n     *         array(\"id\" => 1, \"name\" => \"...\", \"address\" => \"...\"),\n     *         array(\"id\" => 2, \"name\" => \"...\", \"address\" => \"...\")\n     *     )\n     * )\n     *\n     * @param array $data\n     */\n    public function __construct(array $data)\n    {\n        foreach ($data as $tableName => $rows) {\n            $columns = [];\n\n            if (isset($rows[0])) {\n                $columns = \\array_keys($rows[0]);\n            }\n\n            $metaData = new DefaultTableMetadata($tableName, $columns);\n            $table    = new DefaultTable($metaData);\n\n            foreach ($rows as $row) {\n                $table->addRow($row);\n            }\n            $this->tables[$tableName] = $table;\n        }\n    }\n\n    public function getTable($tableName)\n    {\n        if (!isset($this->tables[$tableName])) {\n            throw new InvalidArgumentException(\"$tableName is not a table in the current database.\");\n        }\n\n        return $this->tables[$tableName];\n    }\n\n    protected function createIterator($reverse = false)\n    {\n        return new DefaultTableIterator($this->tables, $reverse);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/CompositeDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * Creates Composite Datasets\n *\n * Allows for creating datasets from multiple sources (csv, query, xml, etc.)\n */\nclass CompositeDataSet extends AbstractDataSet\n{\n    protected $motherDataSet;\n\n    /**\n     * Creates a new Composite dataset\n     *\n     * You can pass in any data set that implements PHPUnit_Extensions_Database_DataSet_IDataSet\n     *\n     * @param string $delimiter\n     * @param string $enclosure\n     * @param string $escape\n     */\n    public function __construct(array $dataSets = [])\n    {\n        $this->motherDataSet = new DefaultDataSet();\n\n        foreach ($dataSets as $dataSet) {\n            $this->addDataSet($dataSet);\n        }\n    }\n\n    /**\n     * Adds a new data set to the composite.\n     *\n     * The dataset may not define tables that already exist in the composite.\n     *\n     * @param IDataSet $dataSet\n     */\n    public function addDataSet(IDataSet $dataSet): void\n    {\n        foreach ($dataSet->getTableNames() as $tableName) {\n            if (!\\in_array($tableName, $this->getTableNames())) {\n                $this->motherDataSet->addTable($dataSet->getTable($tableName));\n            } else {\n                $other = $dataSet->getTable($tableName);\n                $table = $this->getTable($tableName);\n\n                if (!$table->getTableMetaData()->matches($other->getTableMetaData())) {\n                    throw new InvalidArgumentException(\"There is already a table named $tableName with different table definition\");\n                }\n\n                $table->addTableRows($dataSet->getTable($tableName));\n            }\n        }\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        if ($reverse) {\n            return $this->motherDataSet->getReverseIterator();\n        }\n\n        return $this->motherDataSet->getIterator();\n    }\n}\n"
  },
  {
    "path": "src/DataSet/CsvDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * Creates CsvDataSets.\n *\n * You can incrementally add CSV files as tables to your datasets\n */\nclass CsvDataSet extends AbstractDataSet\n{\n    /**\n     * @var array\n     */\n    protected $tables = [];\n\n    /**\n     * @var string\n     */\n    protected $delimiter = ',';\n\n    /**\n     * @var string\n     */\n    protected $enclosure = '\"';\n\n    /**\n     * @var string\n     */\n    protected $escape = '\"';\n\n    /**\n     * Creates a new CSV dataset\n     *\n     * You can pass in the parameters for how csv files will be read.\n     *\n     * @param string $delimiter\n     * @param string $enclosure\n     * @param string $escape\n     */\n    public function __construct($delimiter = ',', $enclosure = '\"', $escape = '\"')\n    {\n        $this->delimiter = $delimiter;\n        $this->enclosure = $enclosure;\n        $this->escape    = $escape;\n    }\n\n    /**\n     * Adds a table to the dataset\n     *\n     * The table will be given the passed name. $csvFile should be a path to\n     * a valid csv file (based on the arguments passed to the constructor.)\n     *\n     * @param string $tableName\n     * @param string $csvFile\n     */\n    public function addTable($tableName, $csvFile): void\n    {\n        if (!\\is_file($csvFile)) {\n            throw new InvalidArgumentException(\"Could not find csv file: {$csvFile}\");\n        }\n\n        if (!\\is_readable($csvFile)) {\n            throw new InvalidArgumentException(\"Could not read csv file: {$csvFile}\");\n        }\n\n        $fh           = \\fopen($csvFile, 'r');\n        $columns      = $this->getCsvRow($fh);\n        $columnsCount = \\count($columns);\n\n        if ($columns === false) {\n            throw new InvalidArgumentException(\"Could not determine the headers from the given file {$csvFile}\");\n        }\n\n        $metaData = new DefaultTableMetadata($tableName, $columns);\n        $table    = new DefaultTable($metaData);\n\n        $rowNumber = 1;\n\n        while (($row = $this->getCsvRow($fh)) !== false) {\n            if ($columnsCount !== \\count($row)) {\n                throw new InvalidArgumentException(\"Row no. {$rowNumber} in csv file {$csvFile} should have an equal number of elements as table {$tableName}\");\n            }\n            $table->addRow(\\array_combine($columns, $row));\n            $rowNumber++;\n        }\n\n        $this->tables[$tableName] = $table;\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        return new DefaultTableIterator($this->tables, $reverse);\n    }\n\n    /**\n     * Returns a row from the csv file in an indexed array.\n     *\n     * @param resource $fh\n     *\n     * @return array\n     */\n    protected function getCsvRow($fh)\n    {\n        if (\\version_compare(PHP_VERSION, '5.3.0', '>')) {\n            return \\fgetcsv($fh, null, $this->delimiter, $this->enclosure, $this->escape);\n        }\n\n        return \\fgetcsv($fh, null, $this->delimiter, $this->enclosure);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/DefaultDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * The default implementation of a data set.\n */\nclass DefaultDataSet extends AbstractDataSet\n{\n    /**\n     * An array of ITable objects.\n     *\n     * @var array\n     */\n    protected $tables;\n\n    /**\n     * Creates a new dataset using the given tables.\n     *\n     * @param array $tables\n     */\n    public function __construct(array $tables = [])\n    {\n        $this->tables = $tables;\n    }\n\n    /**\n     * Adds a table to the dataset.\n     *\n     * @param ITable $table\n     */\n    public function addTable(ITable $table): void\n    {\n        $this->tables[] = $table;\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        return new DefaultTableIterator($this->tables, $reverse);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/DefaultTable.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * Provides default table functionality.\n */\nclass DefaultTable extends AbstractTable\n{\n    /**\n     * Creates a new table object using the given $tableMetaData\n     *\n     * @param ITableMetadata $tableMetaData\n     */\n    public function __construct(ITableMetadata $tableMetaData)\n    {\n        $this->setTableMetaData($tableMetaData);\n        $this->data = [];\n    }\n\n    /**\n     * Adds a row to the table with optional values.\n     *\n     * @param array $values\n     */\n    public function addRow($values = []): void\n    {\n        $this->data[] = \\array_replace(\n            \\array_fill_keys($this->getTableMetaData()->getColumns(), null),\n            $values\n        );\n    }\n\n    /**\n     * Adds the rows in the passed table to the current table.\n     *\n     * @param ITable $table\n     */\n    public function addTableRows(ITable $table): void\n    {\n        $tableColumns = $this->getTableMetaData()->getColumns();\n        $rowCount     = $table->getRowCount();\n\n        for ($i = 0; $i < $rowCount; $i++) {\n            $newRow = [];\n\n            foreach ($tableColumns as $columnName) {\n                $newRow[$columnName] = $table->getValue($i, $columnName);\n            }\n            $this->addRow($newRow);\n        }\n    }\n\n    /**\n     * Sets the specified column of the specied row to the specified value.\n     *\n     * @param int    $row\n     * @param string $column\n     * @param mixed  $value\n     */\n    public function setValue($row, $column, $value): void\n    {\n        if (isset($this->data[$row])) {\n            $this->data[$row][$column] = $value;\n        } else {\n            throw new InvalidArgumentException('The row given does not exist.');\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/DefaultTableIterator.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * The default table iterator\n */\nclass DefaultTableIterator implements ITableIterator\n{\n    /**\n     * An array of tables in the iterator.\n     *\n     * @var array\n     */\n    protected $tables;\n\n    /**\n     * If this property is true then the tables will be iterated in reverse\n     * order.\n     *\n     * @var bool\n     */\n    protected $reverse;\n\n    /**\n     * Creates a new default table iterator object.\n     *\n     * @param array $tables\n     * @param bool  $reverse\n     */\n    public function __construct(array $tables, $reverse = false)\n    {\n        $this->tables  = $tables;\n        $this->reverse = $reverse;\n\n        $this->rewind();\n    }\n\n    /**\n     * Returns the current table.\n     *\n     * @return ITable\n     */\n    public function getTable()\n    {\n        return $this->current();\n    }\n\n    /**\n     * Returns the current table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData()\n    {\n        return $this->current()->getTableMetaData();\n    }\n\n    /**\n     * Returns the current table.\n     *\n     * @return ITable\n     */\n    public function current()\n    {\n        return \\current($this->tables);\n    }\n\n    /**\n     * Returns the name of the current table.\n     *\n     * @return string\n     */\n    public function key()\n    {\n        return $this->current()->getTableMetaData()->getTableName();\n    }\n\n    /**\n     * advances to the next element.\n     */\n    public function next(): void\n    {\n        if ($this->reverse) {\n            \\prev($this->tables);\n        } else {\n            \\next($this->tables);\n        }\n    }\n\n    /**\n     * Rewinds to the first element\n     */\n    public function rewind(): void\n    {\n        if ($this->reverse) {\n            \\end($this->tables);\n        } else {\n            \\reset($this->tables);\n        }\n    }\n\n    /**\n     * Returns true if the current index is valid\n     *\n     * @return bool\n     */\n    public function valid()\n    {\n        return $this->current() !== false;\n    }\n}\n"
  },
  {
    "path": "src/DataSet/DefaultTableMetadata.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * The default implementation of table meta data\n */\nclass DefaultTableMetadata extends AbstractTableMetadata\n{\n    /**\n     * Creates a new default table meta data object.\n     *\n     * @param string $tableName\n     * @param array  $columns\n     * @param array  $primaryKeys\n     */\n    public function __construct($tableName, array $columns, array $primaryKeys = [])\n    {\n        $this->tableName   = $tableName;\n        $this->columns     = $columns;\n        $this->primaryKeys = [];\n\n        foreach ($primaryKeys as $columnName) {\n            if (!\\in_array($columnName, $this->columns)) {\n                throw new InvalidArgumentException('Primary key column passed that is not in the column list.');\n            }\n            $this->primaryKeys[] = $columnName;\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Filter.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * A dataset decorator that allows filtering out tables and table columns from\n * results.\n */\nclass Filter extends AbstractDataSet\n{\n    /**\n     * The dataset being decorated.\n     *\n     * @var IDataSet\n     */\n    protected $originalDataSet;\n\n    /**\n     * The tables to exclude from the data set.\n     *\n     * @var array\n     */\n    protected $excludeTables = [];\n\n    /**\n     * The tables to exclude from the data set.\n     *\n     * @var array\n     */\n    protected $includeTables = [];\n\n    /**\n     * The columns to exclude from the data set.\n     *\n     * @var array\n     */\n    protected $excludeColumns = [];\n\n    /**\n     * The columns to exclude from the data set.\n     *\n     * @var array\n     */\n    protected $includeColumns = [];\n\n    /**\n     * Creates a new filtered data set.\n     *\n     * The $exclude tables should be an associative array using table names as\n     * the key and an array of column names to exclude for the value. If you\n     * would like to exclude a full table set the value of the table's entry\n     * to the special string '*'.\n     *\n     * @param IDataSet $originalDataSet\n     * @param array    $excludeTables   @deprecated use set* methods instead\n     */\n    public function __construct(IDataSet $originalDataSet, array $excludeTables = [])\n    {\n        $this->originalDataSet = $originalDataSet;\n\n        $tables = [];\n\n        foreach ($excludeTables as $tableName => $values) {\n            if (\\is_array($values)) {\n                $this->setExcludeColumnsForTable($tableName, $values);\n            } elseif ($values == '*') {\n                $tables[] = $tableName;\n            } else {\n                $this->setExcludeColumnsForTable($tableName, (array) $values);\n            }\n        }\n\n        $this->addExcludeTables($tables);\n    }\n\n    /**\n     * Adds tables to be included in the data set.\n     *\n     * @param array $tables\n     */\n    public function addIncludeTables(array $tables): void\n    {\n        $this->includeTables = \\array_unique(\\array_merge($this->includeTables, $tables));\n    }\n\n    /**\n     * Adds tables to be included in the data set.\n     *\n     * @param array $tables\n     */\n    public function addExcludeTables(array $tables): void\n    {\n        $this->excludeTables = \\array_unique(\\array_merge($this->excludeTables, $tables));\n    }\n\n    /**\n     * Adds columns to include in the data set for the given table.\n     *\n     * @param string $table\n     * @param array  $columns\n     */\n    public function setIncludeColumnsForTable($table, array $columns): void\n    {\n        $this->includeColumns[$table] = $columns;\n    }\n\n    /**\n     * Adds columns to include in the data set for the given table.\n     *\n     * @param string $table\n     * @param array  $columns\n     */\n    public function setExcludeColumnsForTable($table, array $columns): void\n    {\n        $this->excludeColumns[$table] = $columns;\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        $original_tables = $this->originalDataSet->getIterator($reverse);\n        $new_tables      = [];\n\n        foreach ($original_tables as $table) {\n            /* @var $table ITable */\n            $tableName = $table->getTableMetaData()->getTableName();\n\n            if ((!\\in_array($tableName, $this->includeTables) && !empty($this->includeTables)) ||\n                \\in_array($tableName, $this->excludeTables)\n            ) {\n                continue;\n            }\n\n            if (!empty($this->excludeColumns[$tableName]) || !empty($this->includeColumns[$tableName])) {\n                $new_table = new TableFilter($table);\n\n                if (!empty($this->includeColumns[$tableName])) {\n                    $new_table->addIncludeColumns($this->includeColumns[$tableName]);\n                }\n\n                if (!empty($this->excludeColumns[$tableName])) {\n                    $new_table->addExcludeColumns($this->excludeColumns[$tableName]);\n                }\n\n                $new_tables[] = $new_table;\n            } else {\n                $new_tables[] = $table;\n            }\n        }\n\n        return new DefaultTableIterator($new_tables);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/FlatXmlDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\RuntimeException;\n\n/**\n * The default implementation of a data set.\n */\nclass FlatXmlDataSet extends AbstractXmlDataSet\n{\n    protected function getTableInfo(array &$tableColumns, array &$tableValues): void\n    {\n        if ($this->xmlFileContents->getName() != 'dataset') {\n            throw new RuntimeException('The root element of a flat xml data set file must be called <dataset>');\n        }\n\n        foreach ($this->xmlFileContents->children() as $row) {\n            $tableName = $row->getName();\n\n            if (!isset($tableColumns[$tableName])) {\n                $tableColumns[$tableName] = [];\n                $tableValues[$tableName]  = [];\n            }\n\n            $values = [];\n\n            foreach ($row->attributes() as $name => $value) {\n                if (!\\in_array($name, $tableColumns[$tableName])) {\n                    $tableColumns[$tableName][] = $name;\n                }\n\n                $values[$name] = $value;\n            }\n\n            if (\\count($values)) {\n                $tableValues[$tableName][] = $values;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/IDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse IteratorAggregate;\n\n/**\n * Provides a basic interface for creating and reading data from data sets.\n */\ninterface IDataSet extends IteratorAggregate\n{\n    /**\n     * Returns an array of table names contained in the dataset.\n     *\n     * @return array\n     */\n    public function getTableNames();\n\n    /**\n     * Returns a table meta data object for the given table.\n     *\n     * @param string $tableName\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData($tableName);\n\n    /**\n     * Returns a table object for the given table.\n     *\n     * @param string $tableName\n     *\n     * @return ITable\n     */\n    public function getTable($tableName);\n\n    /**\n     * Returns a reverse iterator for all table objects in the given dataset.\n     *\n     * @return ITableIterator\n     */\n    public function getReverseIterator();\n\n    /**\n     * Asserts that the given data set matches this data set.\n     *\n     * @param IDataSet $other\n     */\n    public function matches(self $other);\n}\n"
  },
  {
    "path": "src/DataSet/ITable.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * Provides a basic interface for creating and reading data from data sets.\n */\ninterface ITable\n{\n    /**\n     * Returns the table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData();\n\n    /**\n     * Returns the number of rows in this table.\n     *\n     * @return int\n     */\n    public function getRowCount();\n\n    /**\n     * Returns the value for the given column on the given row.\n     *\n     * @param int $row\n     * @param int $column\n     */\n    public function getValue($row, $column);\n\n    /**\n     * Returns the an associative array keyed by columns for the given row.\n     *\n     * @param int $row\n     *\n     * @return array\n     */\n    public function getRow($row);\n\n    /**\n     * Asserts that the given table matches this table.\n     *\n     * @param ITable $other\n     */\n    public function matches(self $other);\n}\n"
  },
  {
    "path": "src/DataSet/ITableIterator.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse Iterator;\n\n/**\n * Provides a basic interface for creating and reading data from data sets.\n */\ninterface ITableIterator extends Iterator\n{\n    /**\n     * Returns the current table.\n     *\n     * @return ITable\n     */\n    public function getTable();\n\n    /**\n     * Returns the current table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData();\n}\n"
  },
  {
    "path": "src/DataSet/ITableMetadata.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * Provides a basic interface for returning table meta data.\n */\ninterface ITableMetadata\n{\n    /**\n     * Returns the names of the columns in the table.\n     *\n     * @return array\n     */\n    public function getColumns();\n\n    /**\n     * Returns the names of the primary key columns in the table.\n     *\n     * @return array\n     */\n    public function getPrimaryKeys();\n\n    /**\n     * Returns the name of the table.\n     *\n     * @return string\n     */\n    public function getTableName();\n\n    /**\n     * Asserts that the given tableMetaData matches this tableMetaData.\n     *\n     * @param ITableMetadata $other\n     */\n    public function matches(self $other);\n}\n"
  },
  {
    "path": "src/DataSet/IYamlParser.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * An interface for parsing YAML files.\n */\ninterface IYamlParser\n{\n    /**\n     * @param string $yamlFile\n     *\n     * @return array parsed YAML\n     */\n    public function parseYaml($yamlFile);\n}\n"
  },
  {
    "path": "src/DataSet/MysqlXmlDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\RuntimeException;\n\n/**\n * Data set implementation for the output of mysqldump --xml.\n */\nclass MysqlXmlDataSet extends AbstractXmlDataSet\n{\n    protected function getTableInfo(array &$tableColumns, array &$tableValues): void\n    {\n        if ($this->xmlFileContents->getName() != 'mysqldump') {\n            throw new RuntimeException('The root element of a MySQL XML data set file must be called <mysqldump>');\n        }\n\n        foreach ($this->xmlFileContents->xpath('./database/table_data') as $tableElement) {\n            if (empty($tableElement['name'])) {\n                throw new RuntimeException('<table_data> elements must include a name attribute');\n            }\n\n            $tableName = (string) $tableElement['name'];\n\n            if (!isset($tableColumns[$tableName])) {\n                $tableColumns[$tableName] = [];\n            }\n\n            if (!isset($tableValues[$tableName])) {\n                $tableValues[$tableName] = [];\n            }\n\n            foreach ($tableElement->xpath('./row') as $rowElement) {\n                $rowValues = [];\n\n                foreach ($rowElement->xpath('./field') as $columnElement) {\n                    if (empty($columnElement['name'])) {\n                        throw new RuntimeException('<field> element name attributes cannot be empty');\n                    }\n\n                    $columnName = (string) $columnElement['name'];\n\n                    if (!\\in_array($columnName, $tableColumns[$tableName])) {\n                        $tableColumns[$tableName][] = $columnName;\n                    }\n                }\n\n                foreach ($tableColumns[$tableName] as $columnName) {\n                    $fields = $rowElement->xpath('./field[@name=\"' . $columnName . '\"]');\n\n                    if (!isset($fields[0])) {\n                        throw new RuntimeException(\n                            \\sprintf(\n                                '%s column doesn\\'t exist in current row for table %s',\n                                $columnName,\n                                $tableName\n                            )\n                        );\n                    }\n\n                    $column = $fields[0];\n                    $attr   = $column->attributes('http://www.w3.org/2001/XMLSchema-instance');\n\n                    if (isset($attr['type']) && (string) $attr['type'] === 'xs:hexBinary') {\n                        $columnValue = \\pack('H*', (string) $column);\n                    } else {\n                        $null        = isset($column['nil']) || isset($attr[0]);\n                        $columnValue = $null ? null : (string) $column;\n                    }\n\n                    $rowValues[$columnName] = $columnValue;\n                }\n\n                $tableValues[$tableName][] = $rowValues;\n            }\n        }\n\n        foreach ($this->xmlFileContents->xpath('./database/table_structure') as $tableElement) {\n            if (empty($tableElement['name'])) {\n                throw new RuntimeException('<table_structure> elements must include a name attribute');\n            }\n\n            $tableName = (string) $tableElement['name'];\n\n            foreach ($tableElement->xpath('./field') as $fieldElement) {\n                if (empty($fieldElement['Field']) && empty($fieldElement['field'])) {\n                    throw new RuntimeException('<field> elements must include a Field attribute');\n                }\n\n                $columnName = (string) (empty($fieldElement['Field']) ? $fieldElement['field'] : $fieldElement['Field']);\n\n                if (!\\in_array($columnName, $tableColumns[$tableName])) {\n                    $tableColumns[$tableName][] = $columnName;\n                }\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/QueryDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\Database\\Table;\nuse PHPUnit\\DbUnit\\Database\\TableIterator;\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * Provides access to a database instance as a data set.\n */\nclass QueryDataSet extends AbstractDataSet\n{\n    /**\n     * An array of ITable objects.\n     *\n     * @var array\n     */\n    protected $tables = [];\n\n    /**\n     * The database connection this dataset is using.\n     *\n     * @var Connection\n     */\n    protected $databaseConnection;\n\n    /**\n     * Creates a new dataset using the given database connection.\n     *\n     * @param Connection $databaseConnection\n     */\n    public function __construct(Connection $databaseConnection)\n    {\n        $this->databaseConnection = $databaseConnection;\n    }\n\n    public function addTable($tableName, $query = null): void\n    {\n        if ($query === null) {\n            $query = 'SELECT * FROM ' . $tableName;\n        }\n\n        $this->tables[$tableName] = new QueryTable($tableName, $query, $this->databaseConnection);\n    }\n\n    /**\n     * Returns a table object for the given table.\n     *\n     * @param string $tableName\n     *\n     * @return Table\n     */\n    public function getTable($tableName)\n    {\n        if (!isset($this->tables[$tableName])) {\n            throw new InvalidArgumentException(\"$tableName is not a table in the current database.\");\n        }\n\n        return $this->tables[$tableName];\n    }\n\n    /**\n     * Returns a list of table names for the database\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        return \\array_keys($this->tables);\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return TableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        return new DefaultTableIterator($this->tables, $reverse);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/QueryTable.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PDO;\nuse PHPUnit\\DbUnit\\Database\\Connection;\n\n/**\n * Provides the functionality to represent a database table.\n */\nclass QueryTable extends AbstractTable\n{\n    /**\n     * @var string\n     */\n    protected $query;\n\n    /**\n     * @var Connection\n     */\n    protected $databaseConnection;\n\n    /**\n     * @var string\n     */\n    protected $tableName;\n\n    /**\n     * Creates a new database query table object.\n     *\n     * @param string     $table_name\n     * @param string     $query\n     * @param Connection $databaseConnection\n     * @param mixed      $tableName\n     */\n    public function __construct($tableName, $query, Connection $databaseConnection)\n    {\n        $this->query              = $query;\n        $this->databaseConnection = $databaseConnection;\n        $this->tableName          = $tableName;\n    }\n\n    /**\n     * Returns the table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData()\n    {\n        $this->createTableMetaData();\n\n        return parent::getTableMetaData();\n    }\n\n    /**\n     * Checks if a given row is in the table\n     *\n     * @param array $row\n     *\n     * @return bool\n     */\n    public function assertContainsRow(array $row)\n    {\n        $this->loadData();\n\n        return parent::assertContainsRow($row);\n    }\n\n    /**\n     * Returns the number of rows in this table.\n     *\n     * @return int\n     */\n    public function getRowCount()\n    {\n        $this->loadData();\n\n        return parent::getRowCount();\n    }\n\n    /**\n     * Returns the value for the given column on the given row.\n     *\n     * @param int $row\n     * @param int $column\n     */\n    public function getValue($row, $column)\n    {\n        $this->loadData();\n\n        return parent::getValue($row, $column);\n    }\n\n    /**\n     * Returns the an associative array keyed by columns for the given row.\n     *\n     * @param int $row\n     *\n     * @return array\n     */\n    public function getRow($row)\n    {\n        $this->loadData();\n\n        return parent::getRow($row);\n    }\n\n    /**\n     * Asserts that the given table matches this table.\n     *\n     * @param ITable $other\n     */\n    public function matches(ITable $other)\n    {\n        $this->loadData();\n\n        return parent::matches($other);\n    }\n\n    protected function loadData(): void\n    {\n        if ($this->data === null) {\n            $pdoStatement = $this->databaseConnection->getConnection()->query($this->query);\n            $this->data   = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);\n        }\n    }\n\n    protected function createTableMetaData(): void\n    {\n        if ($this->tableMetaData === null) {\n            $this->loadData();\n\n            // if some rows are in the table\n            $columns = [];\n\n            if (isset($this->data[0])) {\n                // get column names from data\n                $columns = \\array_keys($this->data[0]);\n            } else {\n                $columns = $this->databaseConnection->getMetaData()->getTableColumns($this->tableName);\n            }\n            // create metadata\n            $this->tableMetaData = new DefaultTableMetadata($this->tableName, $columns);\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/ReplacementDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * Allows for replacing arbitrary values or portions of values with new data.\n *\n * A usage for this is replacing all values == '[NULL'] with a true NULL value\n */\nclass ReplacementDataSet extends AbstractDataSet\n{\n    /**\n     * @var IDataSet\n     */\n    protected $dataSet;\n\n    /**\n     * @var array\n     */\n    protected $fullReplacements;\n\n    /**\n     * @var array\n     */\n    protected $subStrReplacements;\n\n    /**\n     * Creates a new replacement dataset\n     *\n     * You can pass in any data set that implements PHPUnit_Extensions_Database_DataSet_IDataSet\n     *\n     * @param string $delimiter\n     * @param string $enclosure\n     * @param string $escape\n     */\n    public function __construct(IDataSet $dataSet, array $fullReplacements = [], array $subStrReplacements = [])\n    {\n        $this->dataSet            = $dataSet;\n        $this->fullReplacements   = $fullReplacements;\n        $this->subStrReplacements = $subStrReplacements;\n    }\n\n    /**\n     * Adds a new full replacement\n     *\n     * Full replacements will only replace values if the FULL value is a match\n     *\n     * @param string $value\n     * @param string $replacement\n     */\n    public function addFullReplacement($value, $replacement): void\n    {\n        $this->fullReplacements[$value] = $replacement;\n    }\n\n    /**\n     * Adds a new substr replacement\n     *\n     * Substr replacements will replace all occurances of the substr in every column\n     *\n     * @param string $value\n     * @param string $replacement\n     */\n    public function addSubStrReplacement($value, $replacement): void\n    {\n        $this->subStrReplacements[$value] = $replacement;\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        $innerIterator = $reverse ? $this->dataSet->getReverseIterator() : $this->dataSet->getIterator();\n\n        return new ReplacementTableIterator($innerIterator, $this->fullReplacements, $this->subStrReplacements);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/ReplacementTable.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * Allows for replacing arbitrary strings in your data sets with other values.\n *\n * @todo When setTableMetaData() is taken out of the AbstractTable this class should extend AbstractTable.\n */\nclass ReplacementTable implements ITable\n{\n    /**\n     * @var ITable\n     */\n    protected $table;\n\n    /**\n     * @var array\n     */\n    protected $fullReplacements;\n\n    /**\n     * @var array\n     */\n    protected $subStrReplacements;\n\n    /**\n     * Creates a new replacement table\n     *\n     * @param ITable $table\n     * @param array  $fullReplacements\n     * @param array  $subStrReplacements\n     */\n    public function __construct(ITable $table, array $fullReplacements = [], array $subStrReplacements = [])\n    {\n        $this->table              = $table;\n        $this->fullReplacements   = $fullReplacements;\n        $this->subStrReplacements = $subStrReplacements;\n    }\n\n    public function __toString()\n    {\n        $columns = $this->getTableMetaData()->getColumns();\n\n        $lineSeperator = \\str_repeat('+----------------------', \\count($columns)) . \"+\\n\";\n        $lineLength    = \\strlen($lineSeperator) - 1;\n\n        $tableString = $lineSeperator;\n        $tableString .= '| ' . \\str_pad($this->getTableMetaData()->getTableName(), $lineLength - 4, ' ', STR_PAD_RIGHT) . \" |\\n\";\n        $tableString .= $lineSeperator;\n        $tableString .= $this->rowToString($columns);\n        $tableString .= $lineSeperator;\n\n        $rowCount = $this->getRowCount();\n\n        for ($i = 0; $i < $rowCount; $i++) {\n            $values = [];\n\n            foreach ($columns as $columnName) {\n                $values[] = $this->getValue($i, $columnName);\n            }\n\n            $tableString .= $this->rowToString($values);\n            $tableString .= $lineSeperator;\n        }\n\n        return \"\\n\" . $tableString . \"\\n\";\n    }\n\n    /**\n     * Adds a new full replacement\n     *\n     * Full replacements will only replace values if the FULL value is a match\n     *\n     * @param string $value\n     * @param string $replacement\n     */\n    public function addFullReplacement($value, $replacement): void\n    {\n        $this->fullReplacements[$value] = $replacement;\n    }\n\n    /**\n     * Adds a new substr replacement\n     *\n     * Substr replacements will replace all occurances of the substr in every column\n     *\n     * @param string $value\n     * @param string $replacement\n     */\n    public function addSubStrReplacement($value, $replacement): void\n    {\n        $this->subStrReplacements[$value] = $replacement;\n    }\n\n    /**\n     * Returns the table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData()\n    {\n        return $this->table->getTableMetaData();\n    }\n\n    /**\n     * Returns the number of rows in this table.\n     *\n     * @return int\n     */\n    public function getRowCount()\n    {\n        return $this->table->getRowCount();\n    }\n\n    /**\n     * Returns the value for the given column on the given row.\n     *\n     * @param int $row\n     * @param int $column\n     */\n    public function getValue($row, $column)\n    {\n        return $this->getReplacedValue($this->table->getValue($row, $column));\n    }\n\n    /**\n     * Returns the an associative array keyed by columns for the given row.\n     *\n     * @param int $row\n     *\n     * @return array\n     */\n    public function getRow($row)\n    {\n        $row = $this->table->getRow($row);\n\n        return \\array_map([$this, 'getReplacedValue'], $row);\n    }\n\n    /**\n     * Asserts that the given table matches this table.\n     *\n     * @param ITable $other\n     */\n    public function matches(ITable $other)\n    {\n        $thisMetaData  = $this->getTableMetaData();\n        $otherMetaData = $other->getTableMetaData();\n\n        if (!$thisMetaData->matches($otherMetaData) ||\n            $this->getRowCount() != $other->getRowCount()\n        ) {\n            return false;\n        }\n\n        $columns  = $thisMetaData->getColumns();\n        $rowCount = $this->getRowCount();\n\n        for ($i = 0; $i < $rowCount; $i++) {\n            foreach ($columns as $columnName) {\n                $thisValue  = $this->getValue($i, $columnName);\n                $otherValue = $other->getValue($i, $columnName);\n\n                if (\\is_numeric($thisValue) && \\is_numeric($otherValue)) {\n                    if ($thisValue != $otherValue) {\n                        return false;\n                    }\n                } elseif ($thisValue !== $otherValue) {\n                    return false;\n                }\n            }\n        }\n\n        return true;\n    }\n\n    protected function rowToString(array $row)\n    {\n        $rowString = '';\n\n        foreach ($row as $value) {\n            if (\\is_null($value)) {\n                $value = 'NULL';\n            }\n\n            $rowString .= '| ' . \\str_pad(\\substr($value, 0, 20), 20, ' ', STR_PAD_BOTH) . ' ';\n        }\n\n        return $rowString . \"|\\n\";\n    }\n\n    protected function getReplacedValue($value)\n    {\n        if (\\is_scalar($value) && \\array_key_exists((string) $value, $this->fullReplacements)) {\n            return $this->fullReplacements[$value];\n        }\n\n        if (\\count($this->subStrReplacements) && isset($value)) {\n            return \\str_replace(\\array_keys($this->subStrReplacements), \\array_values($this->subStrReplacements), $value);\n        }\n\n        return $value;\n    }\n}\n"
  },
  {
    "path": "src/DataSet/ReplacementTableIterator.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse OuterIterator;\n\n/**\n * The default table iterator\n */\nclass ReplacementTableIterator implements OuterIterator, ITableIterator\n{\n    /**\n     * @var ITableIterator\n     */\n    protected $innerIterator;\n\n    /**\n     * @var array\n     */\n    protected $fullReplacements;\n\n    /**\n     * @var array\n     */\n    protected $subStrReplacements;\n\n    /**\n     * Creates a new replacement table iterator object.\n     *\n     * @param ITableIterator $innerIterator\n     * @param array          $fullReplacements\n     * @param array          $subStrReplacements\n     */\n    public function __construct(ITableIterator $innerIterator, array $fullReplacements = [], array $subStrReplacements = [])\n    {\n        $this->innerIterator      = $innerIterator;\n        $this->fullReplacements   = $fullReplacements;\n        $this->subStrReplacements = $subStrReplacements;\n    }\n\n    /**\n     * Adds a new full replacement\n     *\n     * Full replacements will only replace values if the FULL value is a match\n     *\n     * @param string $value\n     * @param string $replacement\n     */\n    public function addFullReplacement($value, $replacement): void\n    {\n        $this->fullReplacements[$value] = $replacement;\n    }\n\n    /**\n     * Adds a new substr replacement\n     *\n     * Substr replacements will replace all occurances of the substr in every column\n     *\n     * @param string $value\n     * @param string $replacement\n     */\n    public function addSubStrReplacement($value, $replacement): void\n    {\n        $this->subStrReplacements[$value] = $replacement;\n    }\n\n    /**\n     * Returns the current table.\n     *\n     * @return ITable\n     */\n    public function getTable()\n    {\n        return $this->current();\n    }\n\n    /**\n     * Returns the current table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData()\n    {\n        $this->current()->getTableMetaData();\n    }\n\n    /**\n     * Returns the current table.\n     *\n     * @return ITable\n     */\n    public function current()\n    {\n        return new ReplacementTable($this->innerIterator->current(), $this->fullReplacements, $this->subStrReplacements);\n    }\n\n    /**\n     * Returns the name of the current table.\n     *\n     * @return string\n     */\n    public function key()\n    {\n        return $this->current()->getTableMetaData()->getTableName();\n    }\n\n    /**\n     * advances to the next element.\n     */\n    public function next(): void\n    {\n        $this->innerIterator->next();\n    }\n\n    /**\n     * Rewinds to the first element\n     */\n    public function rewind(): void\n    {\n        $this->innerIterator->rewind();\n    }\n\n    /**\n     * Returns true if the current index is valid\n     *\n     * @return bool\n     */\n    public function valid()\n    {\n        return $this->innerIterator->valid();\n    }\n\n    public function getInnerIterator()\n    {\n        return $this->innerIterator;\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Specification/Csv.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\DataSet\\CsvDataSet;\nuse ReflectionClass;\n\n/**\n * Creates CsvDataSets based off of a spec string.\n *\n * The format of the spec string is as follows:\n *\n * <csv options>|table1:filename.csv,table2:filename2.csv\n *\n * The first portion of the spec including the pipe symbol '|' is optional.\n * If the pipe option is included than it may be preceded by up to four\n * characters specifying values for the following arguments in order:\n * delimiter (defaults to ',',) enclosure (defaults to '\"',) escape (defaults to '\"',).\n *\n * Any additional characters in the csv options will be discarded.\n */\nclass Csv implements Specification\n{\n    /**\n     * Creates CSV Data Set from a data set spec.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return CsvDataSet\n     */\n    public function getDataSet($dataSetSpec)\n    {\n        $csvDataSetArgs = $this->getCsvOptions($dataSetSpec);\n        $csvDataSetRfl  = new ReflectionClass(CsvDataSet::class);\n        $csvDataSet     = $csvDataSetRfl->newInstanceArgs($csvDataSetArgs);\n\n        foreach ($this->getTableFileMap($dataSetSpec) as $tableName => $file) {\n            $csvDataSet->addTable($tableName, $file);\n        }\n\n        return $csvDataSet;\n    }\n\n    /**\n     * Returns CSV options.\n     *\n     * Returns an array containing the options that will be passed to the\n     * PHPUnit_Extensions_Database_DataSet_CsvDataSet constructor. The options\n     * are determined by the given $dataSetSpec.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return array\n     */\n    protected function getCsvOptions($dataSetSpec)\n    {\n        [$csvOptStr] = \\explode('|', $dataSetSpec, 2);\n\n        return \\str_split($csvOptStr);\n    }\n\n    /**\n     * Returns map of tables to files.\n     *\n     * Returns an associative array containing a mapping of tables (the key)\n     * to files (the values.) The tables and files are determined by the given\n     * $dataSetSpec\n     *\n     * @param string $dataSetSpec\n     *\n     * @return array\n     */\n    protected function getTableFileMap($dataSetSpec)\n    {\n        $tables = [];\n\n        foreach (\\explode(',', $dataSetSpec) as $csvfile) {\n            [$tableName, $file]     = \\explode(':', $csvfile, 2);\n            $tables[$tableName]     = $file;\n        }\n\n        return $tables;\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Specification/Factory.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\RuntimeException;\n\n/**\n * Creates the appropriate DataSet Spec based on a given type.\n */\nclass Factory implements IFactory\n{\n    /**\n     * Returns the data set\n     *\n     * @param string $type\n     *\n     * @return Specification\n     */\n    public function getDataSetSpecByType($type)\n    {\n        switch ($type) {\n            case 'xml':\n                return new Xml();\n\n            case 'flatxml':\n                return new FlatXml();\n\n            case 'csv':\n                return new Csv();\n\n            case 'yaml':\n                return new Yaml();\n\n            case 'dbtable':\n                return new Table();\n\n            case 'dbquery':\n                return new Query();\n\n            default:\n                throw new RuntimeException(\"I don't know what you want from me.\");\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Specification/FlatXml.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\DataSet\\FlatXmlDataSet;\n\n/**\n * Creates a FlatXML dataset based off of a spec string.\n *\n * The format of the spec string is as follows:\n *\n * <filename>\n *\n * The filename should be the location of a flat xml file relative to the\n * current working directory.\n */\nclass FlatXml implements Specification\n{\n    /**\n     * Creates Flat XML Data Set from a data set spec.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return FlatXmlDataSet\n     */\n    public function getDataSet($dataSetSpec)\n    {\n        return new FlatXmlDataSet($dataSetSpec);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Specification/IFactory.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\n/**\n * An interface for data set spec factories.\n */\ninterface IFactory\n{\n    /**\n     * Returns the data set\n     *\n     * @param string $type\n     *\n     * @return Specification\n     */\n    public function getDataSetSpecByType($type);\n}\n"
  },
  {
    "path": "src/DataSet/Specification/Query.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DatabaseListConsumer;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse ReflectionClass;\n\n/**\n * Creates DefaultDataSets based off of a spec string.\n *\n * This spec class requires a list of databases to be set to the object before\n * it can return a list of databases.\n *\n * The format of the spec string is as follows:\n *\n * <db label>:<schema>:<table name>:<sql>\n *\n * The db label should be equal to one of the keys in the array of databases\n * passed to setDatabases().\n *\n * The schema should be the primary schema you will be running the sql query\n * against.\n *\n * The table name should be set to what you would like the table name in the\n * dataset to be.\n *\n * The sql is the query you want to use to generate the table columns and data.\n * The column names in the table will be identical to the column aliases in the\n * query.\n */\nclass Query implements Specification, DatabaseListConsumer\n{\n    /**\n     * @var array\n     */\n    protected $databases = [];\n\n    /**\n     * Sets the database for the spec\n     *\n     * @param array $databases\n     */\n    public function setDatabases(array $databases): void\n    {\n        $this->databases = $databases;\n    }\n\n    /**\n     * Creates a Default Data Set with a query table from a data set spec.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return DefaultDataSet\n     */\n    public function getDataSet($dataSetSpec)\n    {\n        [$dbLabel, $schema, $table, $sql]     = \\explode(':', $dataSetSpec, 4);\n        $databaseInfo                         = $this->databases[$dbLabel];\n\n        $pdoRflc      = new ReflectionClass('PDO');\n        $pdo          = $pdoRflc->newInstanceArgs(\\explode('|', $databaseInfo));\n        $dbConnection = new DefaultConnection($pdo, $schema);\n        $table        = $dbConnection->createQueryTable($table, $sql);\n\n        return new DefaultDataSet([$table]);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Specification/Specification.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\n\n/**\n * Provides an interface for creating data sets from data set spec strings.\n */\ninterface Specification\n{\n    /**\n     * Creates a data set from a data set spec string.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return IDataSet\n     */\n    public function getDataSet($dataSetSpec);\n}\n"
  },
  {
    "path": "src/DataSet/Specification/Table.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DatabaseListConsumer;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse ReflectionClass;\n\n/**\n * Creates a database dataset based off of a spec string.\n *\n * This spec class requires a list of databases to be set to the object before\n * it can return a list of databases.\n *\n * The format of the spec string is as follows:\n *\n * <db label>:<schema>:<tables>\n *\n * The db label should be equal to one of the keys in the array of databases\n * passed to setDatabases().\n *\n * The schema should be the primary schema you will be choosing tables from.\n *\n * The tables should be a comma delimited list of all tables you would like to\n * pull data from.\n *\n * The sql is the query you want to use to generate the table columns and data.\n * The column names in the table will be identical to the column aliases in the\n * query.\n */\nclass Table implements Specification, DatabaseListConsumer\n{\n    /**\n     * @var array\n     */\n    protected $databases = [];\n\n    /**\n     * Sets the database for the spec\n     *\n     * @param array $databases\n     */\n    public function setDatabases(array $databases): void\n    {\n        $this->databases = $databases;\n    }\n\n    /**\n     * Creates a DB Data Set from a data set spec.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return IDataSet\n     */\n    public function getDataSet($dataSetSpec)\n    {\n        [$dbLabel, $schema, $tables]     = \\explode(':', $dataSetSpec, 3);\n        $databaseInfo                    = $this->databases[$dbLabel];\n\n        $pdoRflc      = new ReflectionClass('PDO');\n        $pdo          = $pdoRflc->newInstanceArgs(\\explode('|', $databaseInfo));\n        $dbConnection = new DefaultConnection($pdo, $schema);\n\n        return !empty($tables) ? $dbConnection->createDataSet(\\explode(',', $tables)) : $dbConnection->createDataSet();\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Specification/Xml.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\DataSet\\XmlDataSet;\n\n/**\n * Creates a XML dataset based off of a spec string.\n *\n * The format of the spec string is as follows:\n *\n * <filename>\n *\n * The filename should be the location of a xml file relative to the\n * current working directory.\n */\nclass Xml implements Specification\n{\n    /**\n     * Creates XML Data Set from a data set spec.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return XmlDataSet\n     */\n    public function getDataSet($dataSetSpec)\n    {\n        return new XmlDataSet($dataSetSpec);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/Specification/Yaml.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet\\Specification;\n\nuse PHPUnit\\DbUnit\\DataSet\\YamlDataSet;\n\n/**\n * Creates a YAML dataset based off of a spec string.\n *\n * The format of the spec string is as follows:\n *\n * <filename>\n *\n * The filename should be the location of a yaml file relative to the\n * current working directory.\n */\nclass Yaml implements Specification\n{\n    /**\n     * Creates YAML Data Set from a data set spec.\n     *\n     * @param string $dataSetSpec\n     *\n     * @return YamlDataSet\n     */\n    public function getDataSet($dataSetSpec)\n    {\n        return new YamlDataSet($dataSetSpec);\n    }\n}\n"
  },
  {
    "path": "src/DataSet/SymfonyYamlParser.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse Symfony;\n\n/**\n * The default YAML parser, using Symfony/Yaml.\n */\nclass SymfonyYamlParser implements IYamlParser\n{\n    public function parseYaml($yamlFile)\n    {\n        return Symfony\\Component\\Yaml\\Yaml::parse(\\file_get_contents($yamlFile));\n    }\n}\n"
  },
  {
    "path": "src/DataSet/TableFilter.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * A table decorator that allows filtering out table columns from results.\n */\nclass TableFilter extends AbstractTable\n{\n    /**\n     * The table meta data being decorated.\n     *\n     * @var ITable\n     */\n    protected $originalTable;\n\n    /**\n     * Creates a new table filter using the original table\n     *\n     * @param $originalTable ITable\n     * @param $excludeColumns array @deprecated, use the set* methods instead\n     */\n    public function __construct(ITable $originalTable, array $excludeColumns = [])\n    {\n        $this->originalTable = $originalTable;\n        $this->setTableMetaData(new TableMetadataFilter($originalTable->getTableMetaData()));\n        $this->addExcludeColumns($excludeColumns);\n    }\n\n    /**\n     * Returns the an associative array keyed by columns for the given row.\n     *\n     * @param int $row\n     *\n     * @return array\n     */\n    public function getRow($row)\n    {\n        $this->loadData();\n\n        return parent::getRow($row);\n    }\n\n    /**\n     * Returns the number of rows in this table.\n     *\n     * @return int\n     */\n    public function getRowCount()\n    {\n        $this->loadData();\n\n        return parent::getRowCount();\n    }\n\n    /**\n     * Returns the value for the given column on the given row.\n     *\n     * @param int $row\n     * @param int $column\n     */\n    public function getValue($row, $column)\n    {\n        if (\\in_array($column, $this->getTableMetaData()->getColumns())) {\n            return $this->originalTable->getValue($row, $column);\n        }\n\n        throw new InvalidArgumentException(\"The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}\");\n    }\n\n    /**\n     * Sets the columns to include in the table.\n     *\n     * @param array $includeColumns\n     */\n    public function addIncludeColumns(array $includeColumns): void\n    {\n        $this->tableMetaData->addIncludeColumns($includeColumns);\n    }\n\n    /**\n     * Clears the included columns.\n     */\n    public function clearIncludeColumns(): void\n    {\n        $this->tableMetaData->clearIncludeColumns();\n    }\n\n    /**\n     * Sets the columns to exclude from the table.\n     *\n     * @param array $excludeColumns\n     */\n    public function addExcludeColumns(array $excludeColumns): void\n    {\n        $this->tableMetaData->addExcludeColumns($excludeColumns);\n    }\n\n    /**\n     * Clears the included columns.\n     */\n    public function clearExcludeColumns(): void\n    {\n        $this->tableMetaData->clearExcludeColumns();\n    }\n\n    /**\n     * Checks if a given row is in the table\n     *\n     * @param array $row\n     *\n     * @return bool\n     */\n    public function assertContainsRow(array $row)\n    {\n        $this->loadData();\n\n        return parent::assertContainsRow($row);\n    }\n\n    /**\n     * Loads data into local data table if it's not already loaded\n     */\n    protected function loadData(): void\n    {\n        if ($this->data === null) {\n            $data = [];\n\n            for ($row = 0; $row < $this->originalTable->getRowCount(); $row++) {\n                $tRow = [];\n\n                foreach ($this->getTableMetaData()->getColumns() as $col) {\n                    $tRow[$col] = $this->getValue($row, $col);\n                }\n                $data[$row] = $tRow;\n            }\n            $this->data = $data;\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/TableMetadataFilter.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * A TableMetaData decorator that allows filtering columns from another\n * metaData object.\n *\n * The if a whitelist (include) filter is specified, then only those columns\n * will be included.\n */\nclass TableMetadataFilter extends AbstractTableMetadata\n{\n    /**\n     * The table meta data being decorated.\n     *\n     * @var ITableMetadata\n     */\n    protected $originalMetaData;\n\n    /**\n     * The columns to exclude from the meta data.\n     *\n     * @var array\n     */\n    protected $excludeColumns = [];\n\n    /**\n     * The columns to include from the meta data.\n     *\n     * @var array\n     */\n    protected $includeColumns = [];\n\n    /**\n     * Creates a new filtered table meta data object filtering out\n     * $excludeColumns.\n     *\n     * @param ITableMetadata $originalMetaData\n     * @param array          $excludeColumns   - Deprecated. Use the set* methods instead.\n     */\n    public function __construct(ITableMetadata $originalMetaData, array $excludeColumns = [])\n    {\n        $this->originalMetaData = $originalMetaData;\n        $this->addExcludeColumns($excludeColumns);\n    }\n\n    /**\n     * Returns the names of the columns in the table.\n     *\n     * @return array\n     */\n    public function getColumns()\n    {\n        if (!empty($this->includeColumns)) {\n            return \\array_values(\\array_intersect($this->originalMetaData->getColumns(), $this->includeColumns));\n        }\n\n        if (!empty($this->excludeColumns)) {\n            return \\array_values(\\array_diff($this->originalMetaData->getColumns(), $this->excludeColumns));\n        }\n\n        return $this->originalMetaData->getColumns();\n    }\n\n    /**\n     * Returns the names of the primary key columns in the table.\n     *\n     * @return array\n     */\n    public function getPrimaryKeys()\n    {\n        return $this->originalMetaData->getPrimaryKeys();\n    }\n\n    /**\n     * Returns the name of the table.\n     *\n     * @return string\n     */\n    public function getTableName()\n    {\n        return $this->originalMetaData->getTableName();\n    }\n\n    /**\n     * Sets the columns to include in the table.\n     *\n     * @param array $includeColumns\n     */\n    public function addIncludeColumns(array $includeColumns): void\n    {\n        $this->includeColumns = \\array_unique(\\array_merge($this->includeColumns, $includeColumns));\n    }\n\n    /**\n     * Clears the included columns.\n     */\n    public function clearIncludeColumns(): void\n    {\n        $this->includeColumns = [];\n    }\n\n    /**\n     * Sets the columns to exclude from the table.\n     *\n     * @param array $excludeColumns\n     */\n    public function addExcludeColumns(array $excludeColumns): void\n    {\n        $this->excludeColumns = \\array_unique(\\array_merge($this->excludeColumns, $excludeColumns));\n    }\n\n    /**\n     * Clears the excluded columns.\n     */\n    public function clearExcludeColumns(): void\n    {\n        $this->excludeColumns = [];\n    }\n}\n"
  },
  {
    "path": "src/DataSet/XmlDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\nuse PHPUnit\\DbUnit\\RuntimeException;\n\n/**\n * The default implementation of a data set.\n */\nclass XmlDataSet extends AbstractXmlDataSet\n{\n    protected function getTableInfo(array &$tableColumns, array &$tableValues): void\n    {\n        if ($this->xmlFileContents->getName() != 'dataset') {\n            throw new RuntimeException('The root element of an xml data set file must be called <dataset>');\n        }\n\n        foreach ($this->xmlFileContents->xpath('/dataset/table') as $tableElement) {\n            if (empty($tableElement['name'])) {\n                throw new RuntimeException('Table elements must include a name attribute specifying the table name.');\n            }\n\n            $tableName = (string) $tableElement['name'];\n\n            if (!isset($tableColumns[$tableName])) {\n                $tableColumns[$tableName] = [];\n            }\n\n            if (!isset($tableValues[$tableName])) {\n                $tableValues[$tableName] = [];\n            }\n\n            $tableInstanceColumns = [];\n\n            foreach ($tableElement->xpath('./column') as $columnElement) {\n                $columnName = (string) $columnElement;\n\n                if (empty($columnName)) {\n                    throw new RuntimeException(\"Missing <column> elements for table $tableName. Add one or more <column> elements to the <table> element.\");\n                }\n\n                if (!\\in_array($columnName, $tableColumns[$tableName])) {\n                    $tableColumns[$tableName][] = $columnName;\n                }\n\n                $tableInstanceColumns[] = $columnName;\n            }\n\n            foreach ($tableElement->xpath('./row') as $rowElement) {\n                $rowValues                 = [];\n                $index                     = 0;\n                $numOfTableInstanceColumns = \\count($tableInstanceColumns);\n\n                foreach ($rowElement->children() as $columnValue) {\n                    if ($index >= $numOfTableInstanceColumns) {\n                        throw new RuntimeException(\"Row contains more values than the number of columns defined for table $tableName.\");\n                    }\n\n                    switch ($columnValue->getName()) {\n                        case 'value':\n                            $rowValues[$tableInstanceColumns[$index]] = (string) $columnValue;\n                            $index++;\n\n                            break;\n                        case 'null':\n                            $rowValues[$tableInstanceColumns[$index]] = null;\n                            $index++;\n\n                            break;\n                        default:\n                            throw new RuntimeException('Unknown element ' . $columnValue->getName() . ' in a row element.');\n                    }\n                }\n\n                $tableValues[$tableName][] = $rowValues;\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/DataSet/YamlDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\DataSet;\n\n/**\n * Creates YamlDataSets.\n *\n * You can incrementally add YAML files as tables to your datasets\n */\nclass YamlDataSet extends AbstractDataSet\n{\n    /**\n     * @var array\n     */\n    protected $tables = [];\n\n    /**\n     * @var IYamlParser\n     */\n    protected $parser;\n\n    /**\n     * Creates a new YAML dataset\n     *\n     * @param string      $yamlFile\n     * @param IYamlParser $parser\n     */\n    public function __construct($yamlFile, $parser = null)\n    {\n        if ($parser == null) {\n            $parser = new SymfonyYamlParser();\n        }\n        $this->parser = $parser;\n        $this->addYamlFile($yamlFile);\n    }\n\n    /**\n     * Adds a new yaml file to the dataset.\n     *\n     * @param string $yamlFile\n     */\n    public function addYamlFile($yamlFile): void\n    {\n        $data = $this->parser->parseYaml($yamlFile);\n\n        foreach ($data as $tableName => $rows) {\n            if (!isset($rows)) {\n                $rows = [];\n            }\n\n            if (!\\is_array($rows)) {\n                continue;\n            }\n\n            if (!\\array_key_exists($tableName, $this->tables)) {\n                $columns = $this->getColumns($rows);\n\n                $tableMetaData = new DefaultTableMetadata(\n                    $tableName,\n                    $columns\n                );\n\n                $this->tables[$tableName] = new DefaultTable(\n                    $tableMetaData\n                );\n            }\n\n            foreach ($rows as $row) {\n                $this->tables[$tableName]->addRow($row);\n            }\n        }\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return ITableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        return new DefaultTableIterator(\n            $this->tables,\n            $reverse\n        );\n    }\n\n    /**\n     * Creates a unique list of columns from all the rows in a table.\n     * If the table is defined another time in the Yaml, and if the Yaml\n     * parser could return the multiple occerrences, then this would be\n     * insufficient unless we grouped all the occurences of the table\n     * into onwe row set.  sfYaml, however, does not provide multiple tables\n     * with the same name, it only supplies the last table.\n     *\n     * @params all the rows in a table.\n     *\n     * @param mixed $rows\n     */\n    private function getColumns($rows)\n    {\n        $columns = [];\n\n        foreach ($rows as $row) {\n            $columns = \\array_merge($columns, \\array_keys($row));\n        }\n\n        return \\array_values(\\array_unique($columns));\n    }\n}\n"
  },
  {
    "path": "src/Database/Connection.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database;\n\nuse PDO;\nuse PHPUnit\\DbUnit\\Database\\Metadata\\Metadata;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\n\n/**\n * Provides a basic interface for communicating with a database.\n */\ninterface Connection\n{\n    /**\n     * Close this connection.\n     */\n    public function close();\n\n    /**\n     * Creates a dataset containing the specified table names. If no table\n     * names are specified then it will created a dataset over the entire\n     * database.\n     *\n     * @param array $tableNames\n     *\n     * @return IDataSet\n     */\n    public function createDataSet(array $tableNames = null);\n\n    /**\n     * Creates a table with the result of the specified SQL statement.\n     *\n     * @param string $resultName\n     * @param string $sql\n     *\n     * @return ITable\n     */\n    public function createQueryTable($resultName, $sql);\n\n    /**\n     * Returns a PDO Connection\n     *\n     * @return PDO\n     */\n    public function getConnection();\n\n    /**\n     * Returns a database metadata object that can be used to retrieve table\n     * meta data from the database.\n     *\n     * @return Metadata\n     */\n    public function getMetaData();\n\n    /**\n     * Returns the number of rows in the given table. You can specify an\n     * optional where clause to return a subset of the table.\n     *\n     * @param string $tableName\n     * @param string $whereClause\n     * @param int\n     */\n    public function getRowCount($tableName, $whereClause = null);\n\n    /**\n     * Returns the schema for the connection.\n     *\n     * @return string\n     */\n    public function getSchema();\n\n    /**\n     * Returns a quoted schema object. (table name, column name, etc)\n     *\n     * @param string $object\n     *\n     * @return string\n     */\n    public function quoteSchemaObject($object);\n\n    /**\n     * Returns the command used to truncate a table.\n     *\n     * @return string\n     */\n    public function getTruncateCommand();\n\n    /**\n     * Returns true if the connection allows cascading\n     *\n     * @return bool\n     */\n    public function allowsCascading();\n\n    /**\n     * Disables primary keys if connection does not allow setting them otherwise\n     *\n     * @param string $tableName\n     */\n    public function disablePrimaryKeys($tableName);\n\n    /**\n     * Reenables primary keys after they have been disabled\n     *\n     * @param string $tableName\n     */\n    public function enablePrimaryKeys($tableName);\n}\n"
  },
  {
    "path": "src/Database/DataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database;\n\nuse PHPUnit\\DbUnit\\DataSet\\AbstractDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\nuse PHPUnit\\DbUnit\\RuntimeException;\n\n/**\n * Provides access to a database instance as a data set.\n */\nclass DataSet extends AbstractDataSet\n{\n    /**\n     * An array of ITable objects.\n     *\n     * @var array\n     */\n    protected $tables = [];\n\n    /**\n     * The database connection this dataset is using.\n     *\n     * @var Connection\n     */\n    protected $databaseConnection;\n\n    /**\n     * Creates the query necessary to pull all of the data from a table.\n     *\n     * @param ITableMetadata $tableMetaData\n     *\n     * @return string\n     */\n    public static function buildTableSelect(ITableMetadata $tableMetaData, Connection $databaseConnection = null)\n    {\n        if ($tableMetaData->getTableName() == '') {\n            $e = new RuntimeException('Empty Table Name');\n            print $e->getTraceAsString();\n\n            throw $e;\n        }\n\n        $columns = $tableMetaData->getColumns();\n\n        if ($databaseConnection) {\n            $columns = \\array_map([$databaseConnection, 'quoteSchemaObject'], $columns);\n        }\n        $columnList = \\implode(', ', $columns);\n\n        if ($databaseConnection) {\n            $tableName = $databaseConnection->quoteSchemaObject($tableMetaData->getTableName());\n        } else {\n            $tableName = $tableMetaData->getTableName();\n        }\n\n        $primaryKeys = $tableMetaData->getPrimaryKeys();\n\n        if ($databaseConnection) {\n            $primaryKeys = \\array_map([$databaseConnection, 'quoteSchemaObject'], $primaryKeys);\n        }\n\n        if (\\count($primaryKeys)) {\n            $orderBy = 'ORDER BY ' . \\implode(' ASC, ', $primaryKeys) . ' ASC';\n        } else {\n            $orderBy = '';\n        }\n\n        return \"SELECT {$columnList} FROM {$tableName} {$orderBy}\";\n    }\n\n    /**\n     * Creates a new dataset using the given database connection.\n     *\n     * @param Connection $databaseConnection\n     */\n    public function __construct(Connection $databaseConnection)\n    {\n        $this->databaseConnection = $databaseConnection;\n    }\n\n    /**\n     * Returns a table object for the given table.\n     *\n     * @param string $tableName\n     *\n     * @return Table\n     */\n    public function getTable($tableName)\n    {\n        if (!\\in_array($tableName, $this->getTableNames())) {\n            throw new InvalidArgumentException(\"$tableName is not a table in the current database.\");\n        }\n\n        if (empty($this->tables[$tableName])) {\n            $this->tables[$tableName] = new Table($this->getTableMetaData($tableName), $this->databaseConnection);\n        }\n\n        return $this->tables[$tableName];\n    }\n\n    /**\n     * Returns a table meta data object for the given table.\n     *\n     * @param string $tableName\n     *\n     * @return DefaultTableMetadata\n     */\n    public function getTableMetaData($tableName)\n    {\n        return new DefaultTableMetadata($tableName, $this->databaseConnection->getMetaData()->getTableColumns($tableName), $this->databaseConnection->getMetaData()->getTablePrimaryKeys($tableName));\n    }\n\n    /**\n     * Returns a list of table names for the database\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        return $this->databaseConnection->getMetaData()->getTableNames();\n    }\n\n    /**\n     * Creates an iterator over the tables in the data set. If $reverse is\n     * true a reverse iterator will be returned.\n     *\n     * @param bool $reverse\n     *\n     * @return TableIterator\n     */\n    protected function createIterator($reverse = false)\n    {\n        return new TableIterator($this->getTableNames(), $this, $reverse);\n    }\n}\n"
  },
  {
    "path": "src/Database/DefaultConnection.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database;\n\nuse PDO;\nuse PHPUnit\\DbUnit\\Database\\Metadata\\AbstractMetadata;\nuse PHPUnit\\DbUnit\\Database\\Metadata\\Metadata;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\QueryTable;\n\n/**\n * Provides a basic interface for communicating with a database.\n */\nclass DefaultConnection implements Connection\n{\n    /**\n     * @var PDO\n     */\n    protected $connection;\n\n    /**\n     * The metadata object used to retrieve table meta data from the database.\n     *\n     * @var Metadata\n     */\n    protected $metaData;\n\n    /**\n     * Creates a new database connection\n     *\n     * @param PDO    $connection\n     * @param string $schema     - The name of the database schema you will be testing against\n     */\n    public function __construct(PDO $connection, $schema = '')\n    {\n        $this->connection = $connection;\n        $this->metaData   = AbstractMetadata::createMetaData($connection, $schema);\n        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n    }\n\n    /**\n     * Close this connection.\n     */\n    public function close(): void\n    {\n        unset($this->connection, $this->metaData);\n    }\n\n    /**\n     * Returns a database metadata object that can be used to retrieve table\n     * meta data from the database.\n     *\n     * @return Metadata\n     */\n    public function getMetaData()\n    {\n        return $this->metaData;\n    }\n\n    /**\n     * Returns the schema for the connection.\n     *\n     * @return string\n     */\n    public function getSchema()\n    {\n        return $this->getMetaData()->getSchema();\n    }\n\n    /**\n     * Creates a dataset containing the specified table names. If no table\n     * names are specified then it will created a dataset over the entire\n     * database.\n     *\n     * @param array $tableNames\n     *\n     * @return IDataSet\n     *\n     * @todo Implement the filtered data set.\n     */\n    public function createDataSet(array $tableNames = null)\n    {\n        if (empty($tableNames)) {\n            return new DataSet($this);\n        }\n\n        return new FilteredDataSet($this, $tableNames);\n    }\n\n    /**\n     * Creates a table with the result of the specified SQL statement.\n     *\n     * @param string $resultName\n     * @param string $sql\n     *\n     * @return Table\n     */\n    public function createQueryTable($resultName, $sql)\n    {\n        return new QueryTable($resultName, $sql, $this);\n    }\n\n    /**\n     * Returns this connection database configuration\n     */\n    public function getConfig(): void\n    {\n    }\n\n    /**\n     * Returns a PDO Connection\n     *\n     * @return PDO\n     */\n    public function getConnection()\n    {\n        return $this->connection;\n    }\n\n    /**\n     * Returns the number of rows in the given table. You can specify an\n     * optional where clause to return a subset of the table.\n     *\n     * @param string $tableName\n     * @param string $whereClause\n     *\n     * @return int\n     */\n    public function getRowCount($tableName, $whereClause = null)\n    {\n        $query = 'SELECT COUNT(*) FROM ' . $this->quoteSchemaObject($tableName);\n\n        if (isset($whereClause)) {\n            $query .= \" WHERE {$whereClause}\";\n        }\n\n        return (int) $this->connection->query($query)->fetchColumn();\n    }\n\n    /**\n     * Returns a quoted schema object. (table name, column name, etc)\n     *\n     * @param string $object\n     *\n     * @return string\n     */\n    public function quoteSchemaObject($object)\n    {\n        return $this->getMetaData()->quoteSchemaObject($object);\n    }\n\n    /**\n     * Returns the command used to truncate a table.\n     *\n     * @return string\n     */\n    public function getTruncateCommand()\n    {\n        return $this->getMetaData()->getTruncateCommand();\n    }\n\n    /**\n     * Returns true if the connection allows cascading\n     *\n     * @return bool\n     */\n    public function allowsCascading()\n    {\n        return $this->getMetaData()->allowsCascading();\n    }\n\n    /**\n     * Disables primary keys if connection does not allow setting them otherwise\n     *\n     * @param string $tableName\n     */\n    public function disablePrimaryKeys($tableName): void\n    {\n        $this->getMetaData()->disablePrimaryKeys($tableName);\n    }\n\n    /**\n     * Reenables primary keys after they have been disabled\n     *\n     * @param string $tableName\n     */\n    public function enablePrimaryKeys($tableName): void\n    {\n        $this->getMetaData()->enablePrimaryKeys($tableName);\n    }\n}\n"
  },
  {
    "path": "src/Database/FilteredDataSet.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database;\n\n/**\n * Provides access to a database instance as a data set.\n */\nclass FilteredDataSet extends DataSet\n{\n    /**\n     * @var array\n     */\n    protected $tableNames;\n\n    /**\n     * Creates a new dataset using the given database connection.\n     *\n     * @param Connection $databaseConnection\n     */\n    public function __construct(Connection $databaseConnection, array $tableNames)\n    {\n        parent::__construct($databaseConnection);\n        $this->tableNames = $tableNames;\n    }\n\n    /**\n     * Returns a list of table names for the database\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        return $this->tableNames;\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/AbstractMetadata.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\nuse PDO;\nuse PHPUnit\\DbUnit\\RuntimeException;\nuse ReflectionClass;\n\n/**\n * Provides a basic constructor for all meta data classes and a factory for\n * generating the appropriate meta data class.\n */\nabstract class AbstractMetadata implements Metadata\n{\n    protected static $metaDataClassMap = [\n        'pgsql'    => PgSQL::class,\n        'mysql'    => MySQL::class,\n        'oci'      => Oci::class,\n        'sqlite'   => Sqlite::class,\n        'sqlite2'  => Sqlite::class,\n        'sqlsrv'   => SqlSrv::class,\n        'firebird' => Firebird::class,\n        'dblib'    => Dblib::class\n    ];\n\n    /**\n     * The PDO connection used to retreive database meta data\n     *\n     * @var PDO\n     */\n    protected $pdo;\n\n    /**\n     * The default schema name for the meta data object.\n     *\n     * @var string\n     */\n    protected $schema;\n\n    /**\n     * The character used to quote schema objects.\n     */\n    protected $schemaObjectQuoteChar = '\"';\n\n    /**\n     * The command used to perform a TRUNCATE operation.\n     */\n    protected $truncateCommand = 'TRUNCATE';\n\n    /**\n     * Creates a meta data object based on the driver of given $pdo object and\n     * $schema name.\n     *\n     * @param PDO    $pdo\n     * @param string $schema\n     *\n     * @return AbstractMetadata\n     */\n    public static function createMetaData(PDO $pdo, $schema = '')\n    {\n        $driverName = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);\n\n        if (isset(self::$metaDataClassMap[$driverName])) {\n            $className = self::$metaDataClassMap[$driverName];\n\n            if ($className instanceof ReflectionClass) {\n                return $className->newInstance($pdo, $schema);\n            }\n\n            return self::registerClassWithDriver($className, $driverName)->newInstance($pdo, $schema);\n        }\n\n        throw new RuntimeException(\"Could not find a meta data driver for {$driverName} pdo driver.\");\n    }\n\n    /**\n     * Validates and registers the given $className with the given $pdoDriver.\n     * It should be noted that this function will not attempt to include /\n     * require the file. The $pdoDriver can be determined by the value of the\n     * PDO::ATTR_DRIVER_NAME attribute for a pdo object.\n     *\n     * A reflection of the $className is returned.\n     *\n     * @param string $className\n     * @param string $pdoDriver\n     *\n     * @return ReflectionClass\n     */\n    public static function registerClassWithDriver($className, $pdoDriver)\n    {\n        if (!\\class_exists($className)) {\n            throw new RuntimeException(\"Specified class for {$pdoDriver} driver ({$className}) does not exist.\");\n        }\n\n        $reflection = new ReflectionClass($className);\n\n        if ($reflection->isSubclassOf(self::class)) {\n            return self::$metaDataClassMap[$pdoDriver] = $reflection;\n        }\n\n        throw new RuntimeException(\"Specified class for {$pdoDriver} driver ({$className}) does not extend PHPUnit_Extensions_Database_DB_MetaData.\");\n    }\n\n    /**\n     * Creates a new database meta data object using the given pdo connection\n     * and schema name.\n     *\n     * @param PDO    $pdo\n     * @param string $schema\n     */\n    final public function __construct(PDO $pdo, $schema = '')\n    {\n        $this->pdo    = $pdo;\n        $this->schema = $schema;\n    }\n\n    /**\n     * Returns the schema for the connection.\n     *\n     * @return string\n     */\n    public function getSchema()\n    {\n        return $this->schema;\n    }\n\n    /**\n     * Returns a quoted schema object. (table name, column name, etc)\n     *\n     * @param string $object\n     *\n     * @return string\n     */\n    public function quoteSchemaObject($object)\n    {\n        $parts       = \\explode('.', $object);\n        $quotedParts = [];\n\n        foreach ($parts as $part) {\n            $quotedParts[] = $this->schemaObjectQuoteChar .\n                \\str_replace($this->schemaObjectQuoteChar, $this->schemaObjectQuoteChar . $this->schemaObjectQuoteChar, $part) .\n                $this->schemaObjectQuoteChar;\n        }\n\n        return \\implode('.', $quotedParts);\n    }\n\n    /**\n     * Seperates the schema and the table from a fully qualified table name.\n     *\n     * Returns an associative array containing the 'schema' and the 'table'.\n     *\n     * @param string $fullTableName\n     *\n     * @return array\n     */\n    public function splitTableName($fullTableName)\n    {\n        if (($dot = \\strpos($fullTableName, '.')) !== false) {\n            return [\n                'schema' => \\substr($fullTableName, 0, $dot),\n                'table'  => \\substr($fullTableName, $dot + 1)\n            ];\n        }\n\n        return [\n                'schema' => null,\n                'table'  => $fullTableName\n            ];\n    }\n\n    /**\n     * Returns the command for the database to truncate a table.\n     *\n     * @return string\n     */\n    public function getTruncateCommand()\n    {\n        return $this->truncateCommand;\n    }\n\n    /**\n     * Returns true if the rdbms allows cascading\n     *\n     * @return bool\n     */\n    public function allowsCascading()\n    {\n        return false;\n    }\n\n    /**\n     * Disables primary keys if the rdbms does not allow setting them otherwise\n     *\n     * @param string $tableName\n     */\n    public function disablePrimaryKeys($tableName): void\n    {\n        return;\n    }\n\n    /**\n     * Reenables primary keys after they have been disabled\n     *\n     * @param string $tableName\n     */\n    public function enablePrimaryKeys($tableName): void\n    {\n        return;\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/Dblib.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\n/**\n * Provides functionality to retrieve meta data from an Dblib (SQL Server) database.\n */\nclass Dblib extends AbstractMetadata\n{\n    /**\n     * No character used to quote schema objects.\n     *\n     * @var string\n     */\n    protected $schemaObjectQuoteChar = '';\n\n    /**\n     * The command used to perform a TRUNCATE operation.\n     *\n     * @var string\n     */\n    protected $truncateCommand = 'TRUNCATE TABLE';\n\n    /**\n     * @var array\n     */\n    protected $columns = [];\n\n    /**\n     * @var array\n     */\n    protected $keys = [];\n\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $tableNames = [];\n\n        $query = 'SELECT name\n                    FROM sys.tables\n                   ORDER BY name';\n\n        $result = $this->pdo->query($query);\n\n        while ($tableName = $result->fetchColumn(0)) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        if (!isset($this->columns[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->columns[$tableName];\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        if (!isset($this->keys[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->keys[$tableName];\n    }\n\n    /**\n     * Loads column info from a sql server database.\n     *\n     * @param string $tableName\n     */\n    protected function loadColumnInfo($tableName): void\n    {\n        $query = \"SELECT name\n\t\t\tFROM sys.columns\n\t\t   WHERE object_id = OBJECT_ID('\" . $tableName . \"')\n\t\t   ORDER BY column_id\";\n\n        $result = $this->pdo->query($query);\n\n        while ($columnName = $result->fetchColumn(0)) {\n            $this->columns[$tableName][] = $columnName;\n        }\n\n        $keyQuery = \"SELECT COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName\n\t\t\tFROM    sys.indexes AS i INNER JOIN \n\t\t\t\tsys.index_columns AS ic ON  i.OBJECT_ID = ic.OBJECT_ID\n\t\t\t\t\t\t        AND i.index_id = ic.index_id\n\t\t\tWHERE   i.is_primary_key = 1 AND OBJECT_NAME(ic.OBJECT_ID) = '\" . $tableName . \"'\";\n\n        $result = $this->pdo->query($keyQuery);\n\n        while ($columnName = $result->fetchColumn(0)) {\n            $this->keys[$tableName][] = $columnName;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/Firebird.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\n/**\n * Provides functionality to retrieve meta data from a Firebird database.\n */\nclass Firebird extends AbstractMetadata\n{\n    /**\n     * The command used to perform a TRUNCATE operation.\n     *\n     * @var string\n     */\n    protected $truncateCommand = 'DELETE FROM';\n\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $query = \"\n            SELECT DISTINCT\n                TABLE_NAME\n            FROM INFORMATION_SCHEMA.TABLES\n            WHERE\n                TABLE_TYPE='BASE TABLE' AND\n                TABLE_SCHEMA = ?\n            ORDER BY TABLE_NAME\n        \";\n\n        $query = \"\n            select\n              RDB$RELATION_NAME as TABLE_NAME\n            from RDB$RELATIONS\n            where\n              ((RDB$RELATION_TYPE = 0) or\n               (RDB$RELATION_TYPE is null)) and\n              (RDB$SYSTEM_FLAG = 0)\n            order by (RDB$RELATION_NAME)\n        \";\n\n        $statement = $this->pdo->prepare($query);\n        $statement->execute([$this->getSchema()]);\n\n        $tableNames = [];\n\n        while ($tableName = $statement->fetchColumn(0)) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        if (!isset($this->columns[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->columns[$tableName];\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        if (!isset($this->keys[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->keys[$tableName];\n    }\n\n    /**\n     * Returns the schema for the connection.\n     *\n     * @return string\n     */\n    public function getSchema()\n    {\n        if (empty($this->schema)) {\n            return 'public';\n        }\n\n        return $this->schema;\n    }\n\n    /**\n     * Returns true if the rdbms allows cascading\n     *\n     * @return bool\n     */\n    public function allowsCascading()\n    {\n        return false;\n    }\n\n    /**\n     * Returns a quoted schema object. (table name, column name, etc)\n     *\n     * @param string $object\n     *\n     * @return string\n     */\n    public function quoteSchemaObject($object)\n    {\n        return $object; //firebird does not allow object quoting\n    }\n\n    /**\n     * Loads column info from a database table.\n     *\n     * @param string $tableName\n     */\n    protected function loadColumnInfo($tableName): void\n    {\n        $this->columns[$tableName] = [];\n        $this->keys[$tableName]    = [];\n\n        $columnQuery = '\n            SELECT DISTINCT\n                COLUMN_NAME, ORDINAL_POSITION\n            FROM INFORMATION_SCHEMA.COLUMNS\n            WHERE\n                TABLE_NAME = ? AND\n                TABLE_SCHEMA = ?\n            ORDER BY ORDINAL_POSITION\n        ';\n\n        $columnQuery = '\n            select\n              rf.RDB$FIELD_NAME as COLUMN_NAME,\n              rf.RDB$FIELD_POSITION as ORDINAL_POSITION\n            from RDB$RELATION_FIELDS as rf\n            where\n              upper(RDB$RELATION_NAME) = upper(?)\n            order by\n              ORDINAL_POSITION\n\n        ';\n\n        $columnStatement = $this->pdo->prepare($columnQuery);\n        $columnStatement->execute([$tableName]);\n\n        while ($columName = $columnStatement->fetchColumn(0)) {\n            $this->columns[$tableName][] = $columName;\n        }\n\n        $keyQuery = \"\n            SELECT\n                KCU.COLUMN_NAME,\n                KCU.ORDINAL_POSITION\n            FROM\n                INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU\n            LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC\n                ON TC.TABLE_NAME = KCU.TABLE_NAME\n            WHERE\n                TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND\n                TC.TABLE_NAME = ? AND\n                TC.TABLE_SCHEMA = ?\n            ORDER BY\n                KCU.ORDINAL_POSITION ASC\n        \";\n\n        $keyQuery = \"\n            select\n              idseg.rdb\\$field_name as COLUMN_NAME,\n              idseg.rdb\\$field_position as ORDINAL_POSITION,\n              rc.rdb\\$relation_name as tablename,\n              rc.rdb\\$constraint_name as pk_name\n            from\n              RDB\\$RELATION_CONSTRAINTS AS rc\n                left join\n              rdb\\$index_segments as idseg on\n                (rc.rdb\\$index_name = idseg.rdb\\$index_name)\n            where\n              rc.RDB\\$CONSTRAINT_TYPE = 'PRIMARY KEY'\n              and upper(rc.RDB\\$RELATION_NAME) = upper(?)\n            order by\n              rc.rdb\\$constraint_name, idseg.rdb\\$field_position\n        \";\n\n        $keyStatement = $this->pdo->prepare($keyQuery);\n        $keyStatement->execute([$tableName]);\n\n        while ($columName = $keyStatement->fetchColumn(0)) {\n            $this->keys[$tableName][] = $columName;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/InformationSchema.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\n/**\n * Provides functionality to retrieve meta data from a database with information_schema support.\n */\nclass InformationSchema extends AbstractMetadata\n{\n    protected $columns = [];\n\n    protected $keys = [];\n\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $query = \"\n            SELECT DISTINCT\n                TABLE_NAME\n            FROM INFORMATION_SCHEMA.TABLES\n            WHERE\n                TABLE_TYPE='BASE TABLE' AND\n                TABLE_SCHEMA = ?\n            ORDER BY TABLE_NAME\n        \";\n\n        $statement = $this->pdo->prepare($query);\n        $statement->execute([$this->getSchema()]);\n\n        $tableNames = [];\n\n        while ($tableName = $statement->fetchColumn(0)) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        if (!isset($this->columns[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->columns[$tableName];\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        if (!isset($this->keys[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->keys[$tableName];\n    }\n\n    /**\n     * Loads column info from a sqlite database.\n     *\n     * @param string $tableName\n     */\n    protected function loadColumnInfo($tableName): void\n    {\n        $this->columns[$tableName] = [];\n        $this->keys[$tableName]    = [];\n\n        $columnQuery = '\n            SELECT DISTINCT\n                COLUMN_NAME\n            FROM INFORMATION_SCHEMA.COLUMNS\n            WHERE\n                TABLE_NAME = ? AND\n                TABLE_SCHEMA = ?\n            ORDER BY ORDINAL_POSITION\n        ';\n\n        $columnStatement = $this->pdo->prepare($columnQuery);\n        $columnStatement->execute([$tableName, $this->getSchema()]);\n\n        while ($columName = $columnStatement->fetchColumn(0)) {\n            $this->columns[$tableName][] = $columName;\n        }\n\n        $keyQuery = \"\n            SELECT\n                KCU.COLUMN_NAME\n            FROM\n                INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC,\n                INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU\n            WHERE\n                TC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND\n                TC.TABLE_NAME = KCU.TABLE_NAME AND\n                TC.TABLE_SCHEMA = KCU.TABLE_SCHEMA AND\n                TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND\n                TC.TABLE_NAME = ? AND\n                TC.TABLE_SCHEMA = ?\n            ORDER BY\n                KCU.ORDINAL_POSITION ASC\n        \";\n\n        $keyStatement = $this->pdo->prepare($keyQuery);\n        $keyStatement->execute([$tableName, $this->getSchema()]);\n\n        while ($columName = $keyStatement->fetchColumn(0)) {\n            $this->keys[$tableName][] = $columName;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/Metadata.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\n/**\n * Provides a basic interface for retreiving metadata from a database.\n */\ninterface Metadata\n{\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames();\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName);\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName);\n\n    /**\n     * Returns the name of the default schema.\n     *\n     * @return string\n     */\n    public function getSchema();\n\n    /**\n     * Returns a quoted schema object. (table name, column name, etc)\n     *\n     * @param string $object\n     *\n     * @return string\n     */\n    public function quoteSchemaObject($object);\n\n    /**\n     * Returns true if the rdbms allows cascading\n     *\n     * @return bool\n     */\n    public function allowsCascading();\n\n    /**\n     * Disables primary keys if rdbms does not allow setting them otherwise\n     *\n     * @param string $tableName\n     */\n    public function disablePrimaryKeys($tableName);\n\n    /**\n     * Reenables primary keys after they have been disabled\n     *\n     * @param string $tableName\n     */\n    public function enablePrimaryKeys($tableName);\n}\n"
  },
  {
    "path": "src/Database/Metadata/MySQL.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\nuse PDO;\n\n/**\n * Provides functionality to retrieve meta data from a MySQL database.\n */\nclass MySQL extends AbstractMetadata\n{\n    protected $schemaObjectQuoteChar = '`';\n\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $query     = 'SHOW TABLES';\n        $statement = $this->pdo->prepare($query);\n        $statement->execute();\n\n        $tableNames = [];\n\n        while (($tableName = $statement->fetchColumn(0))) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        $query     = 'SHOW COLUMNS FROM ' . $this->quoteSchemaObject($tableName);\n        $statement = $this->pdo->prepare($query);\n        $statement->execute();\n\n        $columnNames = [];\n\n        while (($columnName = $statement->fetchColumn(0))) {\n            $columnNames[] = $columnName;\n        }\n\n        return $columnNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        $query     = 'SHOW INDEX FROM ' . $this->quoteSchemaObject($tableName);\n        $statement = $this->pdo->prepare($query);\n        $statement->execute();\n        $statement->setFetchMode(PDO::FETCH_ASSOC);\n\n        $columnNames = [];\n\n        while (($column = $statement->fetch())) {\n            if ($column['Key_name'] == 'PRIMARY') {\n                $columnNames[] = $column['Column_name'];\n            }\n        }\n\n        return $columnNames;\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/Oci.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\n/**\n * Provides functionality to retrieve meta data from an Oracle database.\n */\nclass Oci extends AbstractMetadata\n{\n    /**\n     * No character used to quote schema objects.\n     *\n     * @var string\n     */\n    protected $schemaObjectQuoteChar = '';\n\n    /**\n     * The command used to perform a TRUNCATE operation.\n     *\n     * @var string\n     */\n    protected $truncateCommand = 'TRUNCATE TABLE';\n\n    /**\n     * @var array\n     */\n    protected $columns = [];\n\n    /**\n     * @var array\n     */\n    protected $keys = [];\n\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $tableNames = [];\n\n        $query = \"SELECT table_name\n                    FROM cat\n                   WHERE table_type='TABLE'\n                   ORDER BY table_name\";\n\n        $result = $this->pdo->query($query);\n\n        while ($tableName = $result->fetchColumn(0)) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        if (!isset($this->columns[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->columns[$tableName];\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        if (!isset($this->keys[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->keys[$tableName];\n    }\n\n    /**\n     * Loads column info from a oracle database.\n     *\n     * @param string $tableName\n     */\n    protected function loadColumnInfo($tableName): void\n    {\n        $ownerQuery    = '';\n        $conOwnerQuery = '';\n        $tableParts    = $this->splitTableName($tableName);\n\n        $this->columns[$tableName] = [];\n        $this->keys[$tableName]    = [];\n\n        if (!empty($tableParts['schema'])) {\n            $ownerQuery    = \" AND OWNER = '{$tableParts['schema']}'\";\n            $conOwnerQuery = \" AND a.owner = '{$tableParts['schema']}'\";\n        }\n\n        $query = \"SELECT DISTINCT COLUMN_NAME\n                    FROM USER_TAB_COLUMNS\n                   WHERE TABLE_NAME='\" . $tableParts['table'] . \"'\n                    $ownerQuery\n                   ORDER BY COLUMN_NAME\";\n\n        $result = $this->pdo->query($query);\n\n        while ($columnName = $result->fetchColumn(0)) {\n            $this->columns[$tableName][] = $columnName;\n        }\n\n        $keyQuery = \"SELECT b.column_name\n                       FROM user_constraints a, user_cons_columns b\n                      WHERE a.constraint_type='P'\n                        AND a.constraint_name=b.constraint_name\n                        $conOwnerQuery\n                        AND a.table_name = '\" . $tableParts['table'] . \"' \";\n\n        $result = $this->pdo->query($keyQuery);\n\n        while ($columnName = $result->fetchColumn(0)) {\n            $this->keys[$tableName][] = $columnName;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/PgSQL.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\n/**\n * Provides functionality to retrieve meta data from a PostgreSQL database.\n */\nclass PgSQL extends AbstractMetadata\n{\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $query = \"\n            SELECT DISTINCT\n                TABLE_NAME\n            FROM INFORMATION_SCHEMA.TABLES\n            WHERE\n                TABLE_TYPE='BASE TABLE' AND\n                TABLE_SCHEMA = ?\n            ORDER BY TABLE_NAME\n        \";\n\n        $statement = $this->pdo->prepare($query);\n        $statement->execute([$this->getSchema()]);\n\n        $tableNames = [];\n\n        while ($tableName = $statement->fetchColumn(0)) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        if (!isset($this->columns[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->columns[$tableName];\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        if (!isset($this->keys[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->keys[$tableName];\n    }\n\n    /**\n     * Returns the schema for the connection.\n     *\n     * @return string\n     */\n    public function getSchema()\n    {\n        if (empty($this->schema)) {\n            return 'public';\n        }\n\n        return $this->schema;\n    }\n\n    /**\n     * Returns true if the rdbms allows cascading\n     *\n     * @return bool\n     */\n    public function allowsCascading()\n    {\n        return true;\n    }\n\n    /**\n     * Loads column info from a database table.\n     *\n     * @param string $tableName\n     */\n    protected function loadColumnInfo($tableName): void\n    {\n        $this->columns[$tableName] = [];\n        $this->keys[$tableName]    = [];\n\n        $columnQuery = '\n            SELECT DISTINCT\n                COLUMN_NAME, ORDINAL_POSITION\n            FROM INFORMATION_SCHEMA.COLUMNS\n            WHERE\n                TABLE_NAME = ? AND\n                TABLE_SCHEMA = ?\n            ORDER BY ORDINAL_POSITION\n        ';\n\n        $columnStatement = $this->pdo->prepare($columnQuery);\n        $columnStatement->execute([$tableName, $this->getSchema()]);\n\n        while ($columName = $columnStatement->fetchColumn(0)) {\n            $this->columns[$tableName][] = $columName;\n        }\n\n        $keyQuery = \"\n            SELECT\n                KCU.COLUMN_NAME,\n                KCU.ORDINAL_POSITION\n            FROM\n                INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU\n            LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC\n                ON TC.TABLE_NAME = KCU.TABLE_NAME AND\n                TC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME\n            WHERE\n                TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND\n                TC.TABLE_NAME = ? AND\n                TC.TABLE_SCHEMA = ?\n            ORDER BY\n                KCU.ORDINAL_POSITION ASC\n        \";\n\n        $keyStatement = $this->pdo->prepare($keyQuery);\n        $keyStatement->execute([$tableName, $this->getSchema()]);\n\n        while ($columName = $keyStatement->fetchColumn(0)) {\n            $this->keys[$tableName][] = $columName;\n        }\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/SqlSrv.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\nuse PDO;\nuse PDOException;\n\n/**\n * Provides functionality to retrieve meta data from a Microsoft SQL Server database.\n */\nclass SqlSrv extends AbstractMetadata\n{\n    /**\n     * No character used to quote schema objects.\n     *\n     * @var string\n     */\n    protected $schemaObjectQuoteChar = '';\n\n    /**\n     * The command used to perform a TRUNCATE operation.\n     *\n     * @var string\n     */\n    protected $truncateCommand = 'TRUNCATE TABLE';\n\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $query = \"SELECT name\n                    FROM sysobjects\n                   WHERE type='U'\";\n\n        $statement = $this->pdo->prepare($query);\n        $statement->execute();\n\n        $tableNames = [];\n\n        while (($tableName = $statement->fetchColumn(0))) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        $query = \"SELECT c.name\n                    FROM syscolumns c\n               LEFT JOIN sysobjects o ON c.id = o.id\n                   WHERE o.name = '$tableName'\";\n\n        $statement = $this->pdo->prepare($query);\n        $statement->execute();\n\n        $columnNames = [];\n\n        while (($columnName = $statement->fetchColumn(0))) {\n            $columnNames[] = $columnName;\n        }\n\n        return $columnNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        $query     = \"EXEC sp_statistics '$tableName'\";\n        $statement = $this->pdo->prepare($query);\n        $statement->execute();\n        $statement->setFetchMode(PDO::FETCH_ASSOC);\n\n        $columnNames = [];\n\n        while (($column = $statement->fetch())) {\n            if ($column['TYPE'] == 1) {\n                $columnNames[] = $column['COLUMN_NAME'];\n            }\n        }\n\n        return $columnNames;\n    }\n\n    /**\n     * Allow overwriting identities for the given table.\n     *\n     * @param string $tableName\n     */\n    public function disablePrimaryKeys($tableName): void\n    {\n        try {\n            $query = \"SET IDENTITY_INSERT $tableName ON\";\n            $this->pdo->exec($query);\n        } catch (PDOException $e) {\n            // ignore the error here - can happen if primary key is not an identity\n        }\n    }\n\n    /**\n     * Reenable auto creation of identities for the given table.\n     *\n     * @param string $tableName\n     */\n    public function enablePrimaryKeys($tableName): void\n    {\n        try {\n            $query = \"SET IDENTITY_INSERT $tableName OFF\";\n            $this->pdo->exec($query);\n        } catch (PDOException $e) {\n            // ignore the error here - can happen if primary key is not an identity\n        }\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/Sqlite.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\nuse PDO;\nuse PDOStatement;\n\n/**\n * Provides functionality to retrieve meta data from an Sqlite database.\n */\nclass Sqlite extends AbstractMetadata\n{\n    protected $columns = [];\n\n    protected $keys = [];\n\n    protected $truncateCommand = 'DELETE FROM';\n\n    /**\n     * Returns an array containing the names of all the tables in the database.\n     *\n     * @return array\n     */\n    public function getTableNames()\n    {\n        $query = \"\n            SELECT name\n            FROM sqlite_master\n            WHERE\n                type='table' AND\n                name <> 'sqlite_sequence'\n            ORDER BY name\n        \";\n\n        $result = $this->pdo->query($query);\n\n        $tableNames = [];\n\n        while ($tableName = $result->fetchColumn(0)) {\n            $tableNames[] = $tableName;\n        }\n\n        return $tableNames;\n    }\n\n    /**\n     * Returns an array containing the names of all the columns in the\n     * $tableName table,\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTableColumns($tableName)\n    {\n        if (!isset($this->columns[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->columns[$tableName];\n    }\n\n    /**\n     * Returns an array containing the names of all the primary key columns in\n     * the $tableName table.\n     *\n     * @param string $tableName\n     *\n     * @return array\n     */\n    public function getTablePrimaryKeys($tableName)\n    {\n        if (!isset($this->keys[$tableName])) {\n            $this->loadColumnInfo($tableName);\n        }\n\n        return $this->keys[$tableName];\n    }\n\n    /**\n     * Loads column info from a sqlite database.\n     *\n     * @param string $tableName\n     */\n    protected function loadColumnInfo($tableName): void\n    {\n        $query     = \"PRAGMA table_info('{$tableName}')\";\n        $statement = $this->pdo->query($query);\n\n        /* @var $statement PDOStatement */\n        $this->columns[$tableName] = [];\n        $this->keys[$tableName]    = [];\n\n        while ($columnData = $statement->fetch(PDO::FETCH_NUM)) {\n            $this->columns[$tableName][] = $columnData[1];\n\n            if ((int) $columnData[5] !== 0) {\n                $this->keys[$tableName][] = $columnData[1];\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Database/Metadata/Table.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database\\Metadata;\n\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\n\n/**\n * This class loads a table metadata object with database metadata.\n */\nclass Table extends DefaultTableMetadata\n{\n    public function __construct($tableName, Metadata $databaseMetaData)\n    {\n        $this->tableName   = $tableName;\n        $this->columns     = $databaseMetaData->getTableColumns($tableName);\n        $this->primaryKeys = $databaseMetaData->getTablePrimaryKeys($tableName);\n    }\n}\n"
  },
  {
    "path": "src/Database/ResultSetTable.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database;\n\nuse PDO;\nuse PDOStatement;\nuse PHPUnit\\DbUnit\\DataSet\\AbstractTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\n\n/**\n * Provides the functionality to represent a database result set as a DBUnit\n * table.\n *\n * @deprecated The PHPUnit_Extension_Database_DataSet_QueryTable should be used instead\n * @see        PHPUnit_Extension_Database_DataSet_QueryTable\n * @see        PHPUnit_Extension_Database_DataSet_QueryDataSet\n */\nclass ResultSetTable extends AbstractTable\n{\n    /**\n     * Creates a new result set table.\n     *\n     * @param string       $tableName\n     * @param PDOStatement $pdoStatement\n     */\n    public function __construct($tableName, PDOStatement $pdoStatement)\n    {\n        $this->data = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);\n\n        if (\\count($this->data)) {\n            $columns = \\array_keys($this->data[0]);\n        } else {\n            $columns = [];\n        }\n\n        $this->setTableMetaData(new DefaultTableMetadata($tableName, $columns));\n    }\n}\n"
  },
  {
    "path": "src/Database/Table.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database;\n\nuse PDO;\nuse PHPUnit\\DbUnit\\DataSet\\AbstractTable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\n\n/**\n * Provides the functionality to represent a database table.\n */\nclass Table extends AbstractTable\n{\n    /**\n     * Creates a new database table object.\n     *\n     * @param ITableMetadata $tableMetaData\n     * @param Connection     $databaseConnection\n     */\n    public function __construct(ITableMetadata $tableMetaData, Connection $databaseConnection)\n    {\n        $this->setTableMetaData($tableMetaData);\n\n        $pdoStatement = $databaseConnection->getConnection()->prepare(DataSet::buildTableSelect($tableMetaData, $databaseConnection));\n        $pdoStatement->execute();\n        $this->data = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);\n    }\n}\n"
  },
  {
    "path": "src/Database/TableIterator.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Database;\n\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableIterator;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\n\n/**\n * Provides iterative access to tables from a database instance.\n */\nclass TableIterator implements ITableIterator\n{\n    /**\n     * An array of tablenames.\n     *\n     * @var array\n     */\n    protected $tableNames;\n\n    /**\n     * If this property is true then the tables will be iterated in reverse\n     * order.\n     *\n     * @var bool\n     */\n    protected $reverse;\n\n    /**\n     * The database dataset that this iterator iterates over.\n     *\n     * @var DataSet\n     */\n    protected $dataSet;\n\n    public function __construct($tableNames, DataSet $dataSet, $reverse = false)\n    {\n        $this->tableNames = $tableNames;\n        $this->dataSet    = $dataSet;\n        $this->reverse    = $reverse;\n\n        $this->rewind();\n    }\n\n    /**\n     * Returns the current table.\n     *\n     * @return ITable\n     */\n    public function getTable()\n    {\n        return $this->current();\n    }\n\n    /**\n     * Returns the current table's meta data.\n     *\n     * @return ITableMetadata\n     */\n    public function getTableMetaData()\n    {\n        return $this->current()->getTableMetaData();\n    }\n\n    /**\n     * Returns the current table.\n     *\n     * @return ITable\n     */\n    public function current()\n    {\n        $tableName = \\current($this->tableNames);\n\n        return $this->dataSet->getTable($tableName);\n    }\n\n    /**\n     * Returns the name of the current table.\n     *\n     * @return string\n     */\n    public function key()\n    {\n        return $this->current()->getTableMetaData()->getTableName();\n    }\n\n    /**\n     * advances to the next element.\n     */\n    public function next(): void\n    {\n        if ($this->reverse) {\n            \\prev($this->tableNames);\n        } else {\n            \\next($this->tableNames);\n        }\n    }\n\n    /**\n     * Rewinds to the first element\n     */\n    public function rewind(): void\n    {\n        if ($this->reverse) {\n            \\end($this->tableNames);\n        } else {\n            \\reset($this->tableNames);\n        }\n    }\n\n    /**\n     * Returns true if the current index is valid\n     *\n     * @return bool\n     */\n    public function valid()\n    {\n        return \\current($this->tableNames) !== false;\n    }\n}\n"
  },
  {
    "path": "src/DatabaseListConsumer.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\n/**\n * An interface for classes that require a list of databases to operate.\n */\ninterface DatabaseListConsumer\n{\n    /**\n     * Sets the database for the spec\n     *\n     * @param array $databases\n     */\n    public function setDatabases(array $databases);\n}\n"
  },
  {
    "path": "src/DefaultTester.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\n\n/**\n * This is the default implementation of the database tester. It receives its\n * connection object from the constructor.\n */\nclass DefaultTester extends AbstractTester\n{\n    /**\n     * @var Connection\n     */\n    protected $connection;\n\n    /**\n     * Creates a new default database tester using the given connection.\n     *\n     * @param Connection $connection\n     */\n    public function __construct(Connection $connection)\n    {\n        parent::__construct();\n\n        $this->connection = $connection;\n    }\n\n    /**\n     * Returns the test database connection.\n     *\n     * @return Connection\n     */\n    public function getConnection()\n    {\n        return $this->connection;\n    }\n}\n"
  },
  {
    "path": "src/Exception/Exception.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\ninterface Exception\n{\n}\n"
  },
  {
    "path": "src/Exception/InvalidArgumentException.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\nclass InvalidArgumentException extends \\InvalidArgumentException implements Exception\n{\n}\n"
  },
  {
    "path": "src/Exception/RuntimeException.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\nclass RuntimeException extends \\RuntimeException implements Exception\n{\n}\n"
  },
  {
    "path": "src/Operation/Composite.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\InvalidArgumentException;\n\n/**\n * This class facilitates combining database operations. To create a composite\n * operation pass an array of classes that implement\n * PHPUnit_Extensions_Database_Operation_IDatabaseOperation and they will be\n * executed in that order against all data sets.\n */\nclass Composite implements Operation\n{\n    /**\n     * @var array\n     */\n    protected $operations = [];\n\n    /**\n     * Creates a composite operation.\n     *\n     * @param array $operations\n     */\n    public function __construct(array $operations)\n    {\n        foreach ($operations as $operation) {\n            if ($operation instanceof Operation) {\n                $this->operations[] = $operation;\n            } else {\n                throw new InvalidArgumentException('Only database operation instances can be passed to a composite database operation.');\n            }\n        }\n    }\n\n    public function execute(Connection $connection, IDataSet $dataSet): void\n    {\n        try {\n            foreach ($this->operations as $operation) {\n                /* @var $operation Operation */\n                $operation->execute($connection, $dataSet);\n            }\n        } catch (Exception $e) {\n            throw new Exception(\"COMPOSITE[{$e->getOperation()}]\", $e->getQuery(), $e->getArgs(), $e->getTable(), $e->getError());\n        }\n    }\n}\n"
  },
  {
    "path": "src/Operation/Delete.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\n\n/**\n * Deletes the rows in a given dataset using primary key columns.\n */\nclass Delete extends RowBased\n{\n    protected $operationName = 'DELETE';\n\n    protected $iteratorDirection = self::ITERATOR_TYPE_REVERSE;\n\n    protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)\n    {\n        $keys = $databaseTableMetaData->getPrimaryKeys();\n\n        $whereStatement = 'WHERE ' . \\implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));\n\n        $query = \"\n            DELETE FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n            {$whereStatement}\n        \";\n\n        return $query;\n    }\n\n    protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row)\n    {\n        $args = [];\n\n        foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {\n            $args[] = $table->getValue($row, $columnName);\n        }\n\n        return $args;\n    }\n}\n"
  },
  {
    "path": "src/Operation/DeleteAll.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PDOException;\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\n\n/**\n * Deletes all rows from all tables in a dataset.\n */\nclass DeleteAll implements Operation\n{\n    public function execute(Connection $connection, IDataSet $dataSet): void\n    {\n        foreach ($dataSet->getReverseIterator() as $table) {\n            /* @var $table ITable */\n\n            $query = \"\n                DELETE FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n            \";\n\n            try {\n                $connection->getConnection()->query($query);\n            } catch (PDOException $e) {\n                throw new Exception('DELETE_ALL', $query, [], $table, $e->getMessage());\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "src/Operation/Exception.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\RuntimeException;\n\n/**\n * Thrown for exceptions encountered with database operations. Provides\n * information regarding which operations failed and the query (if any) it\n * failed on.\n */\nclass Exception extends RuntimeException\n{\n    /**\n     * @var string\n     */\n    protected $operation;\n\n    /**\n     * @var string\n     */\n    protected $preparedQuery;\n\n    /**\n     * @var array\n     */\n    protected $preparedArgs;\n\n    /**\n     * @var ITable\n     */\n    protected $table;\n\n    /**\n     * @var string\n     */\n    protected $error;\n\n    /**\n     * Creates a new dbunit operation exception\n     *\n     * @param string $operation\n     * @param string $current_query\n     * @param ITable $current_table\n     * @param string $error\n     * @param mixed  $current_args\n     */\n    public function __construct($operation, $current_query, $current_args, $current_table, $error)\n    {\n        parent::__construct(\"{$operation} operation failed on query: {$current_query} using args: \" . \\print_r($current_args, true) . \" [{$error}]\");\n\n        $this->operation     = $operation;\n        $this->preparedQuery = $current_query;\n        $this->preparedArgs  = $current_args;\n        $this->table         = $current_table;\n        $this->error         = $error;\n    }\n\n    public function getOperation()\n    {\n        return $this->operation;\n    }\n\n    public function getQuery()\n    {\n        return $this->preparedQuery;\n    }\n\n    public function getTable()\n    {\n        return $this->table;\n    }\n\n    public function getArgs()\n    {\n        return $this->preparedArgs;\n    }\n\n    public function getError()\n    {\n        return $this->error;\n    }\n}\n"
  },
  {
    "path": "src/Operation/Factory.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\n/**\n * A class factory to easily return database operations.\n */\nclass Factory\n{\n    /**\n     * Returns a null database operation\n     *\n     * @return Operation\n     */\n    public static function NONE()\n    {\n        return new None();\n    }\n\n    /**\n     * Returns a clean insert database operation. It will remove all contents\n     * from the table prior to re-inserting rows.\n     *\n     * @param bool $cascadeTruncates set to true to force truncates to cascade on databases that support this\n     *\n     * @return Operation\n     */\n    public static function CLEAN_INSERT($cascadeTruncates = false)\n    {\n        return new Composite([\n            self::TRUNCATE($cascadeTruncates),\n            self::INSERT()\n        ]);\n    }\n\n    /**\n     * Returns an insert database operation.\n     *\n     * @return Operation\n     */\n    public static function INSERT()\n    {\n        return new Insert();\n    }\n\n    /**\n     * Returns a truncate database operation.\n     *\n     * @param bool $cascadeTruncates set to true to force truncates to cascade on databases that support this\n     *\n     * @return Operation\n     */\n    public static function TRUNCATE($cascadeTruncates = false)\n    {\n        $truncate = new Truncate();\n        $truncate->setCascade($cascadeTruncates);\n\n        return $truncate;\n    }\n\n    /**\n     * Returns a delete database operation.\n     *\n     * @return Operation\n     */\n    public static function DELETE()\n    {\n        return new Delete();\n    }\n\n    /**\n     * Returns a delete_all database operation.\n     *\n     * @return Operation\n     */\n    public static function DELETE_ALL()\n    {\n        return new DeleteAll();\n    }\n\n    /**\n     * Returns an update database operation.\n     *\n     * @return Operation\n     */\n    public static function UPDATE()\n    {\n        return new Update();\n    }\n}\n"
  },
  {
    "path": "src/Operation/Insert.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\n\n/**\n * This class provides functionality for inserting rows from a dataset into a database.\n */\nclass Insert extends RowBased\n{\n    protected $operationName = 'INSERT';\n\n    protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)\n    {\n        $columnCount = \\count($table->getTableMetaData()->getColumns());\n\n        if ($columnCount > 0) {\n            $placeHolders = \\implode(', ', \\array_fill(0, $columnCount, '?'));\n\n            $columns = '';\n\n            foreach ($table->getTableMetaData()->getColumns() as $column) {\n                $columns .= $connection->quoteSchemaObject($column) . ', ';\n            }\n\n            $columns = \\substr($columns, 0, -2);\n\n            $query = \"\n                INSERT INTO {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n                ({$columns})\n                VALUES\n                ({$placeHolders})\n            \";\n\n            return $query;\n        }\n\n        return false;\n    }\n\n    protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row)\n    {\n        $args = [];\n\n        foreach ($table->getTableMetaData()->getColumns() as $columnName) {\n            $args[] = $table->getValue($row, $columnName);\n        }\n\n        return $args;\n    }\n\n    protected function disablePrimaryKeys(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)\n    {\n        if (\\count($databaseTableMetaData->getPrimaryKeys())) {\n            return true;\n        }\n\n        return false;\n    }\n}\n"
  },
  {
    "path": "src/Operation/None.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\n\n/**\n * This class represents a null database operation.\n */\nclass None implements Operation\n{\n    public function execute(Connection $connection, IDataSet $dataSet): void\n    {\n        /* do nothing */\n    }\n}\n"
  },
  {
    "path": "src/Operation/Operation.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\n\n/**\n * Provides a basic interface and functionality for executing database\n * operations against a connection using a specific dataSet.\n */\ninterface Operation\n{\n    /**\n     * Executes the database operation against the given $connection for the\n     * given $dataSet.\n     *\n     * @param Connection $connection\n     * @param IDataSet   $dataSet\n     *\n     * @throws Exception\n     */\n    public function execute(Connection $connection, IDataSet $dataSet);\n}\n"
  },
  {
    "path": "src/Operation/Replace.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\n\n/**\n * Updates the rows in a given dataset using primary key columns.\n */\nclass Replace extends RowBased\n{\n    protected $operationName = 'REPLACE';\n\n    /**\n     * @param Connection $connection\n     * @param IDataSet   $dataSet\n     */\n    public function execute(Connection $connection, IDataSet $dataSet): void\n    {\n        $insertOperation = new Insert;\n        $updateOperation = new Update;\n        $databaseDataSet = $connection->createDataSet();\n\n        foreach ($dataSet as $table) {\n            /* @var $table ITable */\n            $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());\n\n            $insertQuery = $insertOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);\n            $updateQuery = $updateOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);\n            $selectQuery = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);\n\n            $insertStatement = $connection->getConnection()->prepare($insertQuery);\n            $updateStatement = $connection->getConnection()->prepare($updateQuery);\n            $selectStatement = $connection->getConnection()->prepare($selectQuery);\n\n            $rowCount = $table->getRowCount();\n\n            for ($i = 0; $i < $rowCount; $i++) {\n                $selectArgs = $this->buildOperationArguments($databaseTableMetaData, $table, $i);\n                $query      = $selectQuery;\n                $args       = $selectArgs;\n\n                try {\n                    $selectStatement->execute($selectArgs);\n\n                    if ($selectStatement->fetchColumn(0) > 0) {\n                        $updateArgs = $updateOperation->buildOperationArguments($databaseTableMetaData, $table, $i);\n                        $query      = $updateQuery;\n                        $args       = $updateArgs;\n\n                        $updateStatement->execute($updateArgs);\n                    } else {\n                        $insertArgs = $insertOperation->buildOperationArguments($databaseTableMetaData, $table, $i);\n                        $query      = $insertQuery;\n                        $args       = $insertArgs;\n\n                        $insertStatement->execute($insertArgs);\n                    }\n                } catch (\\Exception $e) {\n                    throw new Exception(\n                        $this->operationName,\n                        $query,\n                        $args,\n                        $table,\n                        $e->getMessage()\n                    );\n                }\n            }\n        }\n    }\n\n    protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)\n    {\n        $keys = $databaseTableMetaData->getPrimaryKeys();\n\n        $whereStatement = 'WHERE ' . \\implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));\n\n        $query = \"\n            SELECT COUNT(*)\n            FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n            {$whereStatement}\n        \";\n\n        return $query;\n    }\n\n    protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row)\n    {\n        $args = [];\n\n        foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {\n            $args[] = $table->getValue($row, $columnName);\n        }\n\n        return $args;\n    }\n}\n"
  },
  {
    "path": "src/Operation/RowBased.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\n\n/**\n * Provides basic functionality for row based operations.\n *\n * To create a row based operation you must create two functions. The first\n * one, buildOperationQuery(), must return a query that will be used to create\n * a prepared statement. The second one, buildOperationArguments(), should\n * return an array containing arguments for each row.\n */\nabstract class RowBased implements Operation\n{\n    const ITERATOR_TYPE_FORWARD = 0;\n    const ITERATOR_TYPE_REVERSE = 1;\n\n    protected $operationName;\n\n    protected $iteratorDirection = self::ITERATOR_TYPE_FORWARD;\n\n    /**\n     * @param Connection $connection\n     * @param IDataSet   $dataSet\n     */\n    public function execute(Connection $connection, IDataSet $dataSet): void\n    {\n        $databaseDataSet = $connection->createDataSet();\n\n        $dsIterator = $this->iteratorDirection == self::ITERATOR_TYPE_REVERSE ? $dataSet->getReverseIterator() : $dataSet->getIterator();\n\n        foreach ($dsIterator as $table) {\n            $rowCount = $table->getRowCount();\n\n            if ($rowCount == 0) {\n                continue;\n            }\n\n            /* @var $table ITable */\n            $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());\n            $query                 = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);\n            $disablePrimaryKeys    = $this->disablePrimaryKeys($databaseTableMetaData, $table, $connection);\n\n            if ($query === false) {\n                if ($table->getRowCount() > 0) {\n                    throw new Exception($this->operationName, '', [], $table, 'Rows requested for insert, but no columns provided!');\n                }\n\n                continue;\n            }\n\n            if ($disablePrimaryKeys) {\n                $connection->disablePrimaryKeys($databaseTableMetaData->getTableName());\n            }\n\n            $statement = $connection->getConnection()->prepare($query);\n\n            for ($i = 0; $i < $rowCount; $i++) {\n                $args = $this->buildOperationArguments($databaseTableMetaData, $table, $i);\n\n                try {\n                    $statement->execute($args);\n                } catch (\\Exception $e) {\n                    throw new Exception(\n                        $this->operationName,\n                        $query,\n                        $args,\n                        $table,\n                        $e->getMessage()\n                    );\n                }\n            }\n\n            if ($disablePrimaryKeys) {\n                $connection->enablePrimaryKeys($databaseTableMetaData->getTableName());\n            }\n        }\n    }\n\n    /**\n     * @return bool|string String containing the query or FALSE if a valid query cannot be constructed\n     */\n    abstract protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection);\n\n    abstract protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row);\n\n    /**\n     * Allows an operation to disable primary keys if necessary.\n     *\n     * @param ITableMetadata $databaseTableMetaData\n     * @param ITable         $table\n     * @param Connection     $connection\n     */\n    protected function disablePrimaryKeys(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)\n    {\n        return false;\n    }\n\n    protected function buildPreparedColumnArray($columns, Connection $connection)\n    {\n        $columnArray = [];\n\n        foreach ($columns as $columnName) {\n            $columnArray[] = \"{$connection->quoteSchemaObject($columnName)} = ?\";\n        }\n\n        return $columnArray;\n    }\n}\n"
  },
  {
    "path": "src/Operation/Truncate.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PDO;\nuse PDOException;\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\n\n/**\n * Executes a truncate against all tables in a dataset.\n */\nclass Truncate implements Operation\n{\n    protected $useCascade = false;\n\n    public function setCascade($cascade = true): void\n    {\n        $this->useCascade = $cascade;\n    }\n\n    public function execute(Connection $connection, IDataSet $dataSet): void\n    {\n        foreach ($dataSet->getReverseIterator() as $table) {\n            /* @var $table ITable */\n            $query = \"\n                {$connection->getTruncateCommand()} {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n            \";\n\n            if ($this->useCascade && $connection->allowsCascading()) {\n                $query .= ' CASCADE';\n            }\n\n            try {\n                $this->disableForeignKeyChecksForMysql($connection);\n                $connection->getConnection()->query($query);\n                $this->enableForeignKeyChecksForMysql($connection);\n            } catch (\\Exception $e) {\n                $this->enableForeignKeyChecksForMysql($connection);\n\n                if ($e instanceof PDOException) {\n                    throw new Exception('TRUNCATE', $query, [], $table, $e->getMessage());\n                }\n\n                throw $e;\n            }\n        }\n    }\n\n    private function disableForeignKeyChecksForMysql(Connection $connection): void\n    {\n        if ($this->isMysql($connection)) {\n            $connection->getConnection()->query('SET @PHPUNIT_OLD_FOREIGN_KEY_CHECKS = @@FOREIGN_KEY_CHECKS');\n            $connection->getConnection()->query('SET FOREIGN_KEY_CHECKS = 0');\n        }\n    }\n\n    private function enableForeignKeyChecksForMysql(Connection $connection): void\n    {\n        if ($this->isMysql($connection)) {\n            $connection->getConnection()->query('SET FOREIGN_KEY_CHECKS=@PHPUNIT_OLD_FOREIGN_KEY_CHECKS');\n        }\n    }\n\n    private function isMysql(Connection $connection)\n    {\n        return $connection->getConnection()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql';\n    }\n}\n"
  },
  {
    "path": "src/Operation/Update.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit\\Operation;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\n\n/**\n * Updates the rows in a given dataset using primary key columns.\n */\nclass Update extends RowBased\n{\n    protected $operationName = 'UPDATE';\n\n    protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)\n    {\n        $keys           = $databaseTableMetaData->getPrimaryKeys();\n        $columns        = $table->getTableMetaData()->getColumns();\n        $whereStatement = 'WHERE ' . \\implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));\n        $setStatement   = 'SET ' . \\implode(', ', $this->buildPreparedColumnArray($columns, $connection));\n\n        $query = \"\n            UPDATE {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}\n            {$setStatement}\n            {$whereStatement}\n        \";\n\n        return $query;\n    }\n\n    protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row)\n    {\n        $args = [];\n\n        foreach ($table->getTableMetaData()->getColumns() as $columnName) {\n            $args[] = $table->getValue($row, $columnName);\n        }\n\n        foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {\n            $args[] = $table->getValue($row, $columnName);\n        }\n\n        return $args;\n    }\n\n    protected function disablePrimaryKeys(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)\n    {\n        if (\\count($databaseTableMetaData->getPrimaryKeys())) {\n            return true;\n        }\n\n        return false;\n    }\n}\n"
  },
  {
    "path": "src/TestCase.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\n/**\n * A TestCase extension that provides functionality for testing and asserting\n * against a real database.\n */\nabstract class TestCase extends \\PHPUnit\\Framework\\TestCase\n{\n    use TestCaseTrait;\n}\n"
  },
  {
    "path": "src/TestCaseTrait.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\nuse PDO;\nuse PHPUnit\\DbUnit\\Constraint\\DataSetIsEqual;\nuse PHPUnit\\DbUnit\\Constraint\\TableIsEqual;\nuse PHPUnit\\DbUnit\\Constraint\\TableRowCount;\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DataSet\\ArrayDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\FlatXmlDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\MysqlXmlDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\XmlDataSet;\nuse PHPUnit\\DbUnit\\Operation\\Factory;\nuse PHPUnit\\DbUnit\\Operation\\Operation;\n\ntrait TestCaseTrait\n{\n    /**\n     * @var Tester\n     */\n    protected $databaseTester;\n\n    /**\n     * Asserts that two given tables are equal.\n     *\n     * @param ITable $expected\n     * @param ITable $actual\n     * @param string $message\n     */\n    public static function assertTablesEqual(ITable $expected, ITable $actual, $message = ''): void\n    {\n        $constraint = new TableIsEqual($expected);\n\n        self::assertThat($actual, $constraint, $message);\n    }\n\n    /**\n     * Asserts that two given datasets are equal.\n     *\n     * @param ITable $expected\n     * @param ITable $actual\n     * @param string $message\n     */\n    public static function assertDataSetsEqual(IDataSet $expected, IDataSet $actual, $message = ''): void\n    {\n        $constraint = new DataSetIsEqual($expected);\n\n        self::assertThat($actual, $constraint, $message);\n    }\n\n    /**\n     * Performs operation returned by getSetUpOperation().\n     */\n    protected function setUp(): void\n    {\n        parent::setUp();\n\n        $this->databaseTester = null;\n\n        $this->getDatabaseTester()->setSetUpOperation($this->getSetUpOperation());\n        $this->getDatabaseTester()->setDataSet($this->getDataSet());\n        $this->getDatabaseTester()->onSetUp();\n    }\n\n    /**\n     * Performs operation returned by getTearDownOperation().\n     */\n    protected function tearDown(): void\n    {\n        parent::tearDown();\n\n        $this->getDatabaseTester()->setTearDownOperation($this->getTearDownOperation());\n        $this->getDatabaseTester()->setDataSet($this->getDataSet());\n        $this->getDatabaseTester()->onTearDown();\n\n        /*\n         * Destroy the tester after the test is run to keep DB connections\n         * from piling up.\n         */\n        $this->databaseTester = null;\n    }\n\n    /**\n     * Assert that a given table has a given amount of rows\n     *\n     * @param string $tableName Name of the table\n     * @param int    $expected  Expected amount of rows in the table\n     * @param string $message   Optional message\n     */\n    public function assertTableRowCount($tableName, $expected, $message = ''): void\n    {\n        $constraint = new TableRowCount($tableName, $expected);\n        $actual     = $this->getConnection()->getRowCount($tableName);\n\n        self::assertThat($actual, $constraint, $message);\n    }\n\n    /**\n     * Asserts that a given table contains a given row\n     *\n     * @param array  $expectedRow Row expected to find\n     * @param ITable $table       Table to look into\n     * @param string $message     Optional message\n     */\n    public function assertTableContains(array $expectedRow, ITable $table, $message = ''): void\n    {\n        self::assertThat($table->assertContainsRow($expectedRow), self::isTrue(), $message);\n    }\n\n    /**\n     * Closes the specified connection.\n     *\n     * @param Connection $connection\n     */\n    protected function closeConnection(Connection $connection): void\n    {\n        $this->getDatabaseTester()->closeConnection($connection);\n    }\n\n    /**\n     * Returns the test database connection.\n     *\n     * @return Connection\n     */\n    abstract protected function getConnection();\n\n    /**\n     * Gets the IDatabaseTester for this testCase. If the IDatabaseTester is\n     * not set yet, this method calls newDatabaseTester() to obtain a new\n     * instance.\n     *\n     * @return Tester\n     */\n    protected function getDatabaseTester()\n    {\n        if (empty($this->databaseTester)) {\n            $this->databaseTester = $this->newDatabaseTester();\n        }\n\n        return $this->databaseTester;\n    }\n\n    /**\n     * Returns the test dataset.\n     *\n     * @return IDataSet\n     */\n    abstract protected function getDataSet();\n\n    /**\n     * Returns the database operation executed in test setup.\n     *\n     * @return Operation\n     */\n    protected function getSetUpOperation()\n    {\n        return Factory::CLEAN_INSERT();\n    }\n\n    /**\n     * Returns the database operation executed in test cleanup.\n     *\n     * @return Operation\n     */\n    protected function getTearDownOperation()\n    {\n        return Factory::NONE();\n    }\n\n    /**\n     * Creates a IDatabaseTester for this testCase.\n     *\n     * @return Tester\n     */\n    protected function newDatabaseTester()\n    {\n        return new DefaultTester($this->getConnection());\n    }\n\n    /**\n     * Creates a new DefaultDatabaseConnection using the given PDO connection\n     * and database schema name.\n     *\n     * @param PDO    $connection\n     * @param string $schema\n     *\n     * @return DefaultConnection\n     */\n    protected function createDefaultDBConnection(PDO $connection, $schema = '')\n    {\n        return new DefaultConnection($connection, $schema);\n    }\n\n    /**\n     * Creates a new ArrayDataSet with the given array.\n     * The array parameter is an associative array of tables where the key is\n     * the table name and the value an array of rows. Each row is an associative\n     * array by itself with keys representing the field names and the values the\n     * actual data.\n     * For example:\n     * array(\n     *     \"addressbook\" => array(\n     *         array(\"id\" => 1, \"name\" => \"...\", \"address\" => \"...\"),\n     *         array(\"id\" => 2, \"name\" => \"...\", \"address\" => \"...\")\n     *     )\n     * )\n     *\n     * @param array $data\n     *\n     * @return ArrayDataSet\n     */\n    protected function createArrayDataSet(array $data)\n    {\n        return new ArrayDataSet($data);\n    }\n\n    /**\n     * Creates a new FlatXmlDataSet with the given $xmlFile. (absolute path.)\n     *\n     * @param string $xmlFile\n     *\n     * @return FlatXmlDataSet\n     */\n    protected function createFlatXMLDataSet($xmlFile)\n    {\n        return new FlatXmlDataSet($xmlFile);\n    }\n\n    /**\n     * Creates a new XMLDataSet with the given $xmlFile. (absolute path.)\n     *\n     * @param string $xmlFile\n     *\n     * @return XmlDataSet\n     */\n    protected function createXMLDataSet($xmlFile)\n    {\n        return new XmlDataSet($xmlFile);\n    }\n\n    /**\n     * Create a a new MysqlXmlDataSet with the given $xmlFile. (absolute path.)\n     *\n     * @param string $xmlFile\n     *\n     * @return MysqlXmlDataSet\n     */\n    protected function createMySQLXMLDataSet($xmlFile)\n    {\n        return new MysqlXmlDataSet($xmlFile);\n    }\n\n    /**\n     * Returns an operation factory instance that can be used to instantiate\n     * new operations.\n     *\n     * @return Factory\n     */\n    protected function getOperations()\n    {\n        return new Factory();\n    }\n}\n"
  },
  {
    "path": "src/Tester.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nnamespace PHPUnit\\DbUnit;\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\DataSet\\IDataSet;\nuse PHPUnit\\DbUnit\\Operation\\Operation;\n\n/**\n * This is the interface for DatabaseTester objects. These objects are used to\n * add database testing to existing test cases using composition instead of\n * extension.\n */\ninterface Tester\n{\n    /**\n     * Closes the specified connection.\n     *\n     * @param Connection $connection\n     */\n    public function closeConnection(Connection $connection);\n\n    /**\n     * Returns the test database connection.\n     *\n     * @return Connection\n     */\n    public function getConnection();\n\n    /**\n     * Returns the test dataset.\n     *\n     * @return IDataSet\n     */\n    public function getDataSet();\n\n    /**\n     * TestCases must call this method inside setUp().\n     */\n    public function onSetUp();\n\n    /**\n     * TestCases must call this method inside tearDown().\n     */\n    public function onTearDown();\n\n    /**\n     * Sets the test dataset to use.\n     *\n     * @param IDataSet $dataSet\n     */\n    public function setDataSet(IDataSet $dataSet);\n\n    /**\n     * Sets the schema value.\n     *\n     * @param string $schema\n     */\n    public function setSchema($schema);\n\n    /**\n     * Sets the DatabaseOperation to call when starting the test.\n     *\n     * @param Operation $setUpOperation\n     */\n    public function setSetUpOperation(Operation $setUpOperation);\n\n    /**\n     * Sets the DatabaseOperation to call when stopping the test.\n     *\n     * @param Operation $tearDownOperation\n     */\n    public function setTearDownOperation(Operation $tearDownOperation);\n}\n"
  },
  {
    "path": "tests/Constraint/TableRowCountTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Constraint\\TableRowCount;\nuse PHPUnit\\Framework\\ExpectationFailedException;\nuse PHPUnit\\Framework\\TestCase;\n\nclass Extensions_Database_Constraint_TableRowCountTest extends TestCase\n{\n    public function testConstraint(): void\n    {\n        $constraint = new TableRowCount('name', 42);\n\n        $this->assertTrue($constraint->evaluate(42, '', true));\n        $this->assertFalse($constraint->evaluate(24, '', true));\n        $this->assertEquals('is equal to expected row count 42', $constraint->toString());\n\n        try {\n            $this->assertThat(24, $constraint, '');\n        } catch (ExpectationFailedException $e) {\n            $this->assertEquals(\n                'Failed asserting that 24 is equal to expected row count 42.',\n                $e->getMessage()\n            );\n        }\n    }\n}\n"
  },
  {
    "path": "tests/DB/DefaultDatabaseConnectionTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\Framework\\TestCase;\n\nclass DefaultDatabaseConnectionTest extends TestCase\n{\n    protected $db;\n\n    protected function setUp(): void\n    {\n        $this->db = new PDO('sqlite::memory:');\n        $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n        $this->db->exec('CREATE TABLE test (field1 VARCHAR(100))');\n    }\n\n    public function testRowCountForEmptyTableReturnsZero(): void\n    {\n        $conn = new DefaultConnection($this->db);\n        $this->assertEquals(0, $conn->getRowCount('test'));\n    }\n\n    public function testRowCountForTableWithTwoRowsReturnsTwo(): void\n    {\n        $this->db->exec('INSERT INTO test (field1) VALUES (\\'foobar\\')');\n        $this->db->exec('INSERT INTO test (field1) VALUES (\\'foobarbaz\\')');\n\n        $conn = new DefaultConnection($this->db);\n        $this->assertEquals(2, $conn->getRowCount('test'));\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/AbstractTableTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\QueryTable;\nuse PHPUnit\\Framework\\TestCase;\n\nclass Extensions_Database_DataSet_AbstractTableTest extends TestCase\n{\n    /**\n     * @var QueryTable\n     */\n    protected $table;\n\n    public function setUp(): void\n    {\n        $tableMetaData = new DefaultTableMetadata(\n            'table',\n            ['id', 'column1']\n        );\n\n        $this->table = new DefaultTable($tableMetaData);\n\n        $this->table->addRow([\n            'id'      => 1,\n            'column1' => 'randomValue'\n        ]);\n    }\n\n    /**\n     * @param array $row\n     * @param bool  $exists\n     * @dataProvider providerTableContainsRow\n     */\n    public function testTableContainsRow($row, $exists): void\n    {\n        $result = $this->table->assertContainsRow($row);\n        $this->assertEquals($exists, $result);\n    }\n\n    public function providerTableContainsRow()\n    {\n        return [\n            [['id' => 1, 'column1' => 'randomValue'], true],\n            [['id' => 1, 'column1' => 'notExistingValue'], false]\n        ];\n    }\n\n    public function testMatchesWithNonMatchingMetaData(): void\n    {\n        $tableMetaData = $this->createMock(ITableMetadata::class);\n        $otherMetaData = $this->createMock(ITableMetadata::class);\n\n        $otherTable = $this->createMock(ITable::class);\n        $otherTable->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($otherMetaData));\n\n        $tableMetaData->expects($this->once())\n            ->method('matches')\n            ->with($otherMetaData)\n            ->will($this->returnValue(false));\n\n        $table = new DefaultTable($tableMetaData);\n        $this->assertFalse($table->matches($otherTable));\n    }\n\n    public function testMatchesWithNonMatchingRowCount(): void\n    {\n        $tableMetaData = $this->createMock(ITableMetadata::class);\n        $otherMetaData = $this->createMock(ITableMetadata::class);\n        $otherTable    = $this->createMock(ITable::class);\n\n        $table = $this->getMockBuilder(DefaultTable::class)\n                      ->setConstructorArgs([$tableMetaData])\n                      ->setMethods(['getRowCount'])\n                      ->getMock();\n\n        $otherTable->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($otherMetaData));\n        $otherTable->expects($this->once())\n            ->method('getRowCount')\n            ->will($this->returnValue(0));\n\n        $tableMetaData->expects($this->once())\n            ->method('matches')\n            ->with($otherMetaData)\n            ->will($this->returnValue(true));\n\n        $table->expects($this->once())\n            ->method('getRowCount')\n            ->will($this->returnValue(1));\n        $this->assertFalse($table->matches($otherTable));\n    }\n\n    /**\n     * @param array $tableColumnValues\n     * @param array $otherColumnValues\n     * @param bool  $matches\n     * @dataProvider providerMatchesWithColumnValueComparisons\n     */\n    public function testMatchesWithColumnValueComparisons($tableColumnValues, $otherColumnValues, $matches): void\n    {\n        $tableMetaData = $this->createMock(ITableMetadata::class);\n        $otherMetaData = $this->createMock(ITableMetadata::class);\n        $otherTable    = $this->createMock(ITable::class);\n\n        $table = $this->getMockBuilder(DefaultTable::class)\n                      ->setConstructorArgs([$tableMetaData])\n                      ->setMethods(['getRowCount', 'getValue'])\n                      ->getMock();\n\n        $otherTable->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($otherMetaData));\n        $otherTable->expects($this->once())\n            ->method('getRowCount')\n            ->will($this->returnValue(\\count($otherColumnValues)));\n\n        $tableMetaData->expects($this->once())\n            ->method('getColumns')\n            ->will($this->returnValue(\\array_keys(\\reset($tableColumnValues))));\n        $tableMetaData->expects($this->once())\n            ->method('matches')\n            ->with($otherMetaData)\n            ->will($this->returnValue(true));\n\n        $table->expects($this->any())\n            ->method('getRowCount')\n            ->will($this->returnValue(\\count($tableColumnValues)));\n\n        $tableMap = [];\n        $otherMap = [];\n\n        foreach ($tableColumnValues as $rowIndex => $rowData) {\n            foreach ($rowData as $columnName => $columnValue) {\n                $tableMap[] = [$rowIndex, $columnName, $columnValue];\n                $otherMap[] = [$rowIndex, $columnName, $otherColumnValues[$rowIndex][$columnName]];\n            }\n        }\n        $table->expects($this->any())\n            ->method('getValue')\n            ->will($this->returnValueMap($tableMap));\n        $otherTable->expects($this->any())\n            ->method('getValue')\n            ->will($this->returnValueMap($otherMap));\n\n        $this->assertSame($matches, $table->matches($otherTable));\n    }\n\n    public function providerMatchesWithColumnValueComparisons()\n    {\n        return [\n\n            // One row, one column, matches\n            [\n                [\n                    ['id' => 1],\n                ],\n                [\n                    ['id' => 1],\n                ],\n                true,\n            ],\n\n            // One row, one column, does not match\n            [\n                [\n                    ['id' => 1],\n                ],\n                [\n                    ['id' => 2],\n                ],\n                false,\n            ],\n\n            // Multiple rows, one column, matches\n            [\n                [\n                    ['id' => 1],\n                    ['id' => 2],\n                ],\n                [\n                    ['id' => 1],\n                    ['id' => 2],\n                ],\n                true,\n            ],\n\n            // Multiple rows, one column, do not match\n            [\n                [\n                    ['id' => 1],\n                    ['id' => 2],\n                ],\n                [\n                    ['id' => 1],\n                    ['id' => 3],\n                ],\n                false,\n            ],\n\n            // Multiple rows, multiple columns, matches\n            [\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'bar'],\n                ],\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'bar'],\n                ],\n                true,\n            ],\n\n            // Multiple rows, multiple columns, do not match\n            [\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'bar'],\n                ],\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'baz'],\n                ],\n                false,\n            ],\n\n            // Int and int as string must match\n            [\n                [\n                    ['id' => 42],\n                ],\n                [\n                    ['id' => '42'],\n                ],\n                true,\n            ],\n\n            // Float and float as string must match\n            [\n                [\n                    ['id' => 15.3],\n                ],\n                [\n                    ['id' => '15.3'],\n                ],\n                true,\n            ],\n\n            // Int and float must match\n            [\n                [\n                    ['id' => 18.00],\n                ],\n                [\n                    ['id' => 18],\n                ],\n                true,\n            ],\n\n            // 0 and empty string must not match\n            [\n                [\n                    ['id' => 0],\n                ],\n                [\n                    ['id' => ''],\n                ],\n                false,\n            ],\n\n            // 0 and null must not match\n            [\n                [\n                    ['id' => 0],\n                ],\n                [\n                    ['id' => null],\n                ],\n                false,\n            ],\n\n            // empty string and null must not match\n            [\n                [\n                    ['id' => ''],\n                ],\n                [\n                    ['id' => null],\n                ],\n                false,\n            ],\n        ];\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/CompositeDataSetTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\DataSet\\CompositeDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\TestCase;\n\nclass Extensions_Database_DataSet_CompositeDataSetTest extends \\PHPUnit\\Framework\\TestCase\n{\n    protected $expectedDataSet1;\n    protected $expectedDataSet2;\n    protected $expectedDataSet3;\n\n    public function setUp(): void\n    {\n        $table1MetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n        $table2MetaData = new DefaultTableMetadata(\n            'table2',\n            ['table2_id', 'column5', 'column6', 'column7', 'column8']\n        );\n\n        $table3MetaData = new DefaultTableMetadata(\n            'table3',\n            ['table3_id', 'column9', 'column10', 'column11', 'column12']\n        );\n\n        $table1 = new DefaultTable($table1MetaData);\n        $table2 = new DefaultTable($table2MetaData);\n        $table3 = new DefaultTable($table3MetaData);\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'tgfahgasdf',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table1->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => 1654.4,\n            'column4'   => 'asfgklg'\n        ]);\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fhah',\n            'column6'   => 456,\n            'column7'   => 46.5,\n            'column8'   => 'fsdb, ghfdas'\n        ]);\n        $table2->addRow([\n            'table2_id' => 2,\n            'column5'   => 'asdhfoih',\n            'column6'   => 654,\n            'column7'   => 'blah',\n            'column8'   => '43asd \"fhgj\" sfadh'\n        ]);\n        $table2->addRow([\n            'table2_id' => 3,\n            'column5'   => 'ajsdlkfguitah',\n            'column6'   => 654,\n            'column7'   => 'blah',\n            'column8'   => 'thesethasdl\nasdflkjsadf asdfsadfhl \"adsf, halsdf\" sadfhlasdf'\n        ]);\n\n        $table3->addRow([\n            'table3_id' => 1,\n            'column9'   => 'sfgsda',\n            'column10'  => 16,\n            'column11'  => 45.57,\n            'column12'  => 'sdfh .ds,ajfas asdf h'\n        ]);\n        $table3->addRow([\n            'table3_id' => 2,\n            'column9'   => 'afdstgb',\n            'column10'  => 41,\n            'column11'  => 46.645,\n            'column12'  => '87yhasdf sadf yah;/a '\n        ]);\n        $table3->addRow([\n            'table3_id' => 3,\n            'column9'   => 'gldsf',\n            'column10'  => 46,\n            'column11'  => 123.456,\n            'column12'  => '0y8hosnd a/df7y olgbjs da'\n        ]);\n\n        $this->expectedDataSet1 = new DefaultDataSet([$table1, $table2]);\n        $this->expectedDataSet2 = new DefaultDataSet([$table3]);\n        $this->expectedDataSet3 = new DefaultDataSet([$table1, $table2, $table3]);\n    }\n\n    public function testCompositeDataSet(): void\n    {\n        $actual = new CompositeDataSet([$this->expectedDataSet1, $this->expectedDataSet2]);\n\n        TestCase::assertDataSetsEqual($this->expectedDataSet3, $actual);\n    }\n\n    public function testCompatibleTablesInDifferentDataSetsNonDuplicateRows(): void\n    {\n        $compatibleTable = new DefaultTable(\n            $this->expectedDataSet3->getTable('table3')->getTableMetaData()\n        );\n\n        $compatibleTable->addRow([\n            'table3_id' => 4,\n            'column9'   => 'asdasd',\n            'column10'  => 17,\n            'column11'  => 42.57,\n            'column12'  => 'askldja'\n        ]);\n\n        $compositeDataSet = new CompositeDataSet([\n            new DefaultDataSet([$compatibleTable]),\n            $this->expectedDataSet2\n        ]);\n\n        $this->assertEquals(4, $compositeDataSet->getTable('table3')->getRowCount());\n    }\n\n    /**\n     * @expectedException           InvalidArgumentException\n     * @expectedExceptionMessage    There is already a table named table3 with different table definition\n     */\n    public function testExceptionOnIncompatibleTablesSameTableNames(): void\n    {\n        $inCompatibleTableMetaData = new DefaultTableMetadata(\n            'table3',\n            ['table3_id', 'column13', 'column14', 'column15', 'column16']\n        );\n\n        $inCompatibleTable = new DefaultTable($inCompatibleTableMetaData);\n        $inCompatibleTable->addRow([\n            'column13' => 'asdasda asdasd',\n            'column14' => 'aiafsjas asd',\n            'column15' => 'asdasdasd',\n            'column16' => 2141\n        ]);\n\n        $compositeDataSet = new CompositeDataSet([\n            $this->expectedDataSet2,\n            new DefaultDataSet([$inCompatibleTable])\n        ]);\n    }\n\n    /**\n     * @expectedException           InvalidArgumentException\n     * @expectedExceptionMessage    There is already a table named table3 with different table definition\n     */\n    public function testExceptionOnIncompatibleTablesSameTableNames2(): void\n    {\n        $inCompatibleTableMetaData = new DefaultTableMetadata(\n            'table3',\n            ['table3_id', 'column13', 'column14', 'column15', 'column16']\n        );\n\n        $inCompatibleTable = new DefaultTable($inCompatibleTableMetaData);\n        $inCompatibleTable->addRow([\n            'column13' => 'asdasda asdasd',\n            'column14' => 'aiafsjas asd',\n            'column15' => 'asdasdasd',\n            'column16' => 2141\n        ]);\n\n        $compositeDataSet = new CompositeDataSet([\n            new DefaultDataSet([$inCompatibleTable]),\n            $this->expectedDataSet2\n        ]);\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/CsvDataSetTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\DataSet\\CsvDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\TestCase;\n\nclass Extensions_Database_DataSet_CsvDataSetTest extends \\PHPUnit\\Framework\\TestCase\n{\n    protected $expectedDataSet;\n\n    public function testCSVDataSet(): void\n    {\n        $table1MetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n        $table2MetaData = new DefaultTableMetadata(\n            'table2',\n            ['table2_id', 'column5', 'column6', 'column7', 'column8']\n        );\n\n        $table1 = new DefaultTable($table1MetaData);\n        $table2 = new DefaultTable($table2MetaData);\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'tgfahgasdf',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table1->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => 1654.4,\n            'column4'   => 'asfgklg'\n        ]);\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fhah',\n            'column6'   => 456,\n            'column7'   => 46.5,\n            'column8'   => 'fsdb, ghfdas'\n        ]);\n        $table2->addRow([\n            'table2_id' => 2,\n            'column5'   => 'asdhfoih',\n            'column6'   => 654,\n            'column7'   => 'blah',\n            'column8'   => '43asd \"fhgj\" sfadh'\n        ]);\n        $table2->addRow([\n            'table2_id' => 3,\n            'column5'   => 'ajsdlkfguitah',\n            'column6'   => 654,\n            'column7'   => 'blah',\n            'column8'   => 'thesethasdl\nasdflkjsadf asdfsadfhl \"adsf, halsdf\" sadfhlasdf'\n        ]);\n\n        $expectedDataSet = new DefaultDataSet([$table1, $table2]);\n\n        $csvDataSet = new CsvDataSet();\n        $csvDataSet->addTable('table1', __DIR__ . '/../_files/CsvDataSets/table1.csv');\n        $csvDataSet->addTable('table2', __DIR__ . '/../_files/CsvDataSets/table2.csv');\n\n        TestCase::assertDataSetsEqual($expectedDataSet, $csvDataSet);\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/FilterTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Constraint\\DataSetIsEqual;\nuse PHPUnit\\DbUnit\\DataSet\\Filter;\nuse PHPUnit\\DbUnit\\DataSet\\FlatXmlDataSet;\nuse PHPUnit\\Framework\\TestCase;\n\nclass Extensions_Database_DataSet_FilterTest extends TestCase\n{\n    protected $expectedDataSet;\n\n    public function setUp(): void\n    {\n        $this->expectedDataSet = new FlatXmlDataSet(\n            __DIR__ . '/../_files/XmlDataSets/FilteredTestFixture.xml'\n        );\n    }\n\n    public function testDeprecatedFilteredDataSetConstructor(): void\n    {\n        $constraint = new DataSetIsEqual($this->expectedDataSet);\n        $dataSet    = new FlatXmlDataSet(\n            __DIR__ . '/../_files/XmlDataSets/FilteredTestComparison.xml'\n        );\n\n        $filteredDataSet = new Filter($dataSet, [\n            'table1' => ['table1_id'],\n            'table2' => '*',\n            'table3' => 'table3_id'\n        ]);\n\n        self::assertThat($filteredDataSet, $constraint);\n    }\n\n    public function testExcludeFilteredDataSet(): void\n    {\n        $constraint = new DataSetIsEqual($this->expectedDataSet);\n        $dataSet    = new FlatXmlDataSet(\n            __DIR__ . '/../_files/XmlDataSets/FilteredTestComparison.xml'\n        );\n\n        $filteredDataSet = new Filter($dataSet);\n\n        $filteredDataSet->addExcludeTables(['table2']);\n        $filteredDataSet->setExcludeColumnsForTable('table1', ['table1_id']);\n        $filteredDataSet->setExcludeColumnsForTable('table3', ['table3_id']);\n\n        self::assertThat($filteredDataSet, $constraint);\n    }\n\n    public function testIncludeFilteredDataSet(): void\n    {\n        $constraint = new DataSetIsEqual($this->expectedDataSet);\n        $dataSet    = new FlatXmlDataSet(\n            __DIR__ . '/../_files/XmlDataSets/FilteredTestComparison.xml'\n        );\n\n        $filteredDataSet = new Filter($dataSet);\n\n        $filteredDataSet->addIncludeTables(['table1', 'table3']);\n        $filteredDataSet->setIncludeColumnsForTable('table1', ['column1', 'column2', 'column3', 'column4']);\n        $filteredDataSet->setIncludeColumnsForTable('table3', ['column9', 'column10', 'column11', 'column12']);\n\n        self::assertThat($filteredDataSet, $constraint);\n    }\n\n    public function testIncludeExcludeMixedDataSet(): void\n    {\n        $constraint = new DataSetIsEqual($this->expectedDataSet);\n        $dataSet    = new FlatXmlDataSet(\n            __DIR__ . '/../_files/XmlDataSets/FilteredTestComparison.xml'\n        );\n\n        $filteredDataSet = new Filter($dataSet);\n\n        $filteredDataSet->addIncludeTables(['table1', 'table3']);\n        $filteredDataSet->setExcludeColumnsForTable('table1', ['table1_id']);\n        $filteredDataSet->setIncludeColumnsForTable('table3', ['column9', 'column10', 'column11', 'column12']);\n\n        self::assertThat($filteredDataSet, $constraint);\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/QueryDataSetTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\QueryDataSet;\nuse PHPUnit\\DbUnit\\TestCase;\n\nclass Extensions_Database_DataSet_QueryDataSetTest extends TestCase\n{\n    /**\n     * @var QueryDataSet\n     */\n    protected $dataSet;\n\n    protected $pdo;\n\n    public function setUp(): void\n    {\n        $this->pdo = DBUnitTestUtility::getSQLiteMemoryDB();\n        parent::setUp();\n        $this->dataSet = new QueryDataSet($this->getConnection());\n        $this->dataSet->addTable('table1');\n        $this->dataSet->addTable('query1', '\n            SELECT\n                t1.column1 tc1, t2.column5 tc2\n            FROM\n                table1 t1\n                JOIN table2 t2 ON t1.table1_id = t2.table2_id\n        ');\n    }\n\n    public function testGetTable(): void\n    {\n        $expectedTable1 = $this->getConnection()->createDataSet(['table1'])->getTable('table1');\n\n        $expectedTable2 = new DefaultTable(\n            new DefaultTableMetadata('query1', ['tc1', 'tc2'])\n        );\n\n        $expectedTable2->addRow(['tc1' => 'bar', 'tc2' => 'blah']);\n\n        $this->assertTablesEqual($expectedTable1, $this->dataSet->getTable('table1'));\n        $this->assertTablesEqual($expectedTable2, $this->dataSet->getTable('query1'));\n    }\n\n    public function testGetTableNames(): void\n    {\n        $this->assertEquals(['table1', 'query1'], $this->dataSet->getTableNames());\n    }\n\n    public function testCreateIterator(): void\n    {\n        $expectedTable1 = $this->getConnection()->createDataSet(['table1'])->getTable('table1');\n\n        $expectedTable2 = new DefaultTable(\n            new DefaultTableMetadata('query1', ['tc1', 'tc2'])\n        );\n\n        $expectedTable2->addRow(['tc1' => 'bar', 'tc2' => 'blah']);\n\n        foreach ($this->dataSet as $i => $table) {\n            /* @var $table ITable */\n            switch ($table->getTableMetaData()->getTableName()) {\n                case 'table1':\n                    $this->assertTablesEqual($expectedTable1, $table);\n\n                    break;\n                case 'query1':\n                    $this->assertTablesEqual($expectedTable2, $table);\n\n                    break;\n                default:\n                    $this->fail('Proper keys not present from the iterator');\n            }\n        }\n    }\n\n    /**\n     * @return DefaultConnection\n     */\n    protected function getConnection()\n    {\n        return $this->createDefaultDBConnection($this->pdo, 'test');\n    }\n\n    protected function getDataSet()\n    {\n        return $this->createFlatXMLDataSet(__DIR__ . '/../_files/XmlDataSets/QueryDataSetTest.xml');\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/QueryTableTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\QueryTable;\nuse PHPUnit\\Framework\\TestCase;\n\nclass Extensions_Database_DataSet_QueryTableTest extends TestCase\n{\n    /**\n     * @var QueryTable\n     */\n    protected $table;\n\n    public static function providerTestGetValue()\n    {\n        return [\n            [0, 'col1', 'value1'],\n            [0, 'col2', 'value2'],\n            [0, 'col3', 'value3'],\n            [1, 'col1', 'value4'],\n            [1, 'col2', 'value5'],\n            [1, 'col3', 'value6'],\n        ];\n    }\n\n    public function setUp(): void\n    {\n        $query = \"\n            SELECT\n                'value1' as col1,\n                'value2' as col2,\n                'value3' as col3\n            UNION SELECT\n                'value4' as col1,\n                'value5' as col2,\n                'value6' as col3\n        \";\n        $this->table = new QueryTable(\n            'table1',\n            $query,\n            new DefaultConnection(new PDO('sqlite::memory:'), 'test')\n        );\n    }\n\n    public function testGetEmptyTableMetaData(): void\n    {\n        $metaData = new DefaultTableMetadata('table1', ['table1_id', 'column1', 'column2', 'column3', 'column4']);\n\n        $conn = new PDO('sqlite::memory:');\n        $conn->exec(\n          'CREATE TABLE IF NOT EXISTS table1 (\n            table1_id INTEGER PRIMARY KEY AUTOINCREMENT,\n            column1 VARCHAR(20),\n            column2 INT(10),\n            column3 DECIMAL(6,2),\n            column4 TEXT\n          )'\n        );\n\n        $query = '\n            SELECT *\n            FROM table1\n        ';\n\n        $empty_table = new QueryTable(\n            'table1',\n            $query,\n            new DefaultConnection($conn)\n        );\n\n        $this->assertEquals($metaData, $empty_table->getTableMetaData());\n    }\n\n    public function testGetTableMetaData(): void\n    {\n        $metaData = new DefaultTableMetadata('table1', ['col1', 'col2', 'col3']);\n\n        $this->assertEquals($metaData, $this->table->getTableMetaData());\n    }\n\n    public function testGetRowCount(): void\n    {\n        $this->assertEquals(2, $this->table->getRowCount());\n    }\n\n    /**\n     * @dataProvider providerTestGetValue\n     *\n     * @param mixed $row\n     * @param mixed $column\n     * @param mixed $value\n     */\n    public function testGetValue($row, $column, $value): void\n    {\n        $this->assertEquals($value, $this->table->getValue($row, $column));\n    }\n\n    public function testGetRow(): void\n    {\n        $this->assertEquals(['col1' => 'value1', 'col2' => 'value2', 'col3' => 'value3'], $this->table->getRow(0));\n    }\n\n    public function testAssertEquals(): void\n    {\n        $expected_table = new DefaultTable(new DefaultTableMetadata('table1', ['col1', 'col2', 'col3']));\n        $expected_table->addRow(['col1' => 'value1', 'col2' => 'value2', 'col3' => 'value3']);\n        $expected_table->addRow(['col1' => 'value4', 'col2' => 'value5', 'col3' => 'value6']);\n        $this->assertTrue($this->table->matches($expected_table));\n    }\n\n    public function testAssertEqualsFails(): void\n    {\n        $expected_table = new DefaultTable(new DefaultTableMetadata('table1', ['col1', 'col2', 'col3']));\n        $expected_table->addRow(['col1' => 'value1', 'col2' => 'value2', 'col3' => 'value3']);\n        $expected_table->addRow(['col1' => 'value4', 'col2' => 'value5', 'col3' => 'value6']);\n        $expected_table->addRow(['col1' => 'value7', 'col2' => 'value8', 'col3' => 'value9']);\n        $this->assertFalse($this->table->matches($expected_table));\n    }\n\n    public function testAssertRowContains(): void\n    {\n        $this->assertTrue($this->table->assertContainsRow(\n            ['col1' => 'value1', 'col2' => 'value2', 'col3' => 'value3']\n        ));\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/ReplacementDataSetTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\ReplacementDataSet;\nuse PHPUnit\\DbUnit\\TestCase;\n\nclass Extensions_Database_DataSet_ReplacementDataSetTest extends \\PHPUnit\\Framework\\TestCase\n{\n    /**\n     * @var DefaultDataSet\n     */\n    protected $startingDataSet;\n\n    public function setUp(): void\n    {\n        $table1MetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n        $table2MetaData = new DefaultTableMetadata(\n            'table2',\n            ['table2_id', 'column5', 'column6', 'column7', 'column8']\n        );\n\n        $table1 = new DefaultTable($table1MetaData);\n        $table2 = new DefaultTable($table2MetaData);\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is %%%name%%%',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table1->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => 1654.4,\n            'column4'   => '[NULL]'\n        ]);\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fhah',\n            'column6'   => 456,\n            'column7'   => 46.5,\n            'column8'   => 'My name is %%%name%%%'\n        ]);\n        $table2->addRow([\n            'table2_id' => 2,\n            'column5'   => 'asdhfoih',\n            'column6'   => 654,\n            'column7'   => '[NULL]',\n            'column8'   => '43asdfhgj'\n        ]);\n        $table2->addRow([\n            'table2_id' => 3,\n            'column5'   => 'ajsdlkfguitah',\n            'column6'   => 654,\n            'column7'   => '[NULL]',\n            'column8'   => '[NULL] not really'\n        ]);\n\n        $this->startingDataSet = new DefaultDataSet([$table1, $table2]);\n    }\n\n    public function testNoReplacement(): void\n    {\n        TestCase::assertDataSetsEqual(\n            $this->startingDataSet,\n            new ReplacementDataSet($this->startingDataSet)\n        );\n    }\n\n    public function testFullReplacement(): void\n    {\n        $table1MetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n        $table2MetaData = new DefaultTableMetadata(\n            'table2',\n            ['table2_id', 'column5', 'column6', 'column7', 'column8']\n        );\n\n        $table1 = new DefaultTable($table1MetaData);\n        $table2 = new DefaultTable($table2MetaData);\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is %%%name%%%',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table1->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => 1654.4,\n            'column4'   => null\n        ]);\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fhah',\n            'column6'   => 456,\n            'column7'   => 46.5,\n            'column8'   => 'My name is %%%name%%%'\n        ]);\n        $table2->addRow([\n            'table2_id' => 2,\n            'column5'   => 'asdhfoih',\n            'column6'   => 654,\n            'column7'   => null,\n            'column8'   => '43asdfhgj'\n        ]);\n        $table2->addRow([\n            'table2_id' => 3,\n            'column5'   => 'ajsdlkfguitah',\n            'column6'   => 654,\n            'column7'   => null,\n            'column8'   => '[NULL] not really'\n        ]);\n\n        $expected = new DefaultDataSet([$table1, $table2]);\n        $actual   = new ReplacementDataSet($this->startingDataSet);\n        $actual->addFullReplacement('[NULL]', null);\n\n        TestCase::assertDataSetsEqual($expected, $actual);\n    }\n\n    public function testSubStrReplacement(): void\n    {\n        $table1MetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n        $table2MetaData = new DefaultTableMetadata(\n            'table2',\n            ['table2_id', 'column5', 'column6', 'column7', 'column8']\n        );\n\n        $table1 = new DefaultTable($table1MetaData);\n        $table2 = new DefaultTable($table2MetaData);\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is Mike Lively',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table1->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => 1654.4,\n            'column4'   => '[NULL]'\n        ]);\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fhah',\n            'column6'   => 456,\n            'column7'   => 46.5,\n            'column8'   => 'My name is Mike Lively'\n        ]);\n        $table2->addRow([\n            'table2_id' => 2,\n            'column5'   => 'asdhfoih',\n            'column6'   => 654,\n            'column7'   => '[NULL]',\n            'column8'   => '43asdfhgj'\n        ]);\n        $table2->addRow([\n            'table2_id' => 3,\n            'column5'   => 'ajsdlkfguitah',\n            'column6'   => 654,\n            'column7'   => '[NULL]',\n            'column8'   => '[NULL] not really'\n        ]);\n\n        $expected = new DefaultDataSet([$table1, $table2]);\n        $actual   = new ReplacementDataSet($this->startingDataSet);\n        $actual->addSubStrReplacement('%%%name%%%', 'Mike Lively');\n\n        TestCase::assertDataSetsEqual($expected, $actual);\n    }\n\n    public function testConstructorReplacements(): void\n    {\n        $table1MetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n        $table2MetaData = new DefaultTableMetadata(\n            'table2',\n            ['table2_id', 'column5', 'column6', 'column7', 'column8']\n        );\n\n        $table1 = new DefaultTable($table1MetaData);\n        $table2 = new DefaultTable($table2MetaData);\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is Mike Lively',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table1->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => 1654.4,\n            'column4'   => null\n        ]);\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fhah',\n            'column6'   => 456,\n            'column7'   => 46.5,\n            'column8'   => 'My name is Mike Lively'\n        ]);\n        $table2->addRow([\n            'table2_id' => 2,\n            'column5'   => 'asdhfoih',\n            'column6'   => 654,\n            'column7'   => null,\n            'column8'   => '43asdfhgj'\n        ]);\n        $table2->addRow([\n            'table2_id' => 3,\n            'column5'   => 'ajsdlkfguitah',\n            'column6'   => 654,\n            'column7'   => null,\n            'column8'   => '[NULL] not really'\n        ]);\n\n        $expected = new DefaultDataSet([$table1, $table2]);\n        $actual   = new ReplacementDataSet(\n            $this->startingDataSet,\n            ['[NULL]'     => null],\n            ['%%%name%%%' => 'Mike Lively']\n        );\n\n        TestCase::assertDataSetsEqual($expected, $actual);\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/ReplacementTableTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\ReplacementTable;\nuse PHPUnit\\DbUnit\\TestCase;\n\nclass Extensions_Database_DataSet_ReplacementTableTest extends \\PHPUnit\\Framework\\TestCase\n{\n    /**\n     * @var DefaultTable\n     */\n    protected $startingTable;\n\n    public function setUp(): void\n    {\n        $tableMetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n\n        $table = new DefaultTable($tableMetaData);\n\n        $table->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is %%%name%%%',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => '[NULL] not really',\n            'column4'   => '[NULL]'\n        ]);\n\n        $this->startingTable = $table;\n    }\n\n    public function testNoReplacement(): void\n    {\n        TestCase::assertTablesEqual(\n            $this->startingTable,\n            new ReplacementTable($this->startingTable)\n        );\n    }\n\n    public function testFullReplacement(): void\n    {\n        $tableMetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n\n        $table = new DefaultTable($tableMetaData);\n\n        $table->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is %%%name%%%',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => '[NULL] not really',\n            'column4'   => null\n        ]);\n\n        $actual = new ReplacementTable($this->startingTable);\n        $actual->addFullReplacement('[NULL]', null);\n\n        TestCase::assertTablesEqual($table, $actual);\n    }\n\n    public function testSubStrReplacement(): void\n    {\n        $tableMetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n\n        $table = new DefaultTable($tableMetaData);\n\n        $table->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is Mike Lively',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => '[NULL] not really',\n            'column4'   => '[NULL]'\n        ]);\n\n        $actual = new ReplacementTable($this->startingTable);\n        $actual->addSubStrReplacement('%%%name%%%', 'Mike Lively');\n\n        TestCase::assertTablesEqual($table, $actual);\n    }\n\n    public function testConstructorReplacements(): void\n    {\n        $tableMetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n\n        $table = new DefaultTable($tableMetaData);\n\n        $table->addRow([\n            'table1_id' => 1,\n            'column1'   => 'My name is Mike Lively',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => '[NULL] not really',\n            'column4'   => null\n        ]);\n\n        $actual = new ReplacementTable(\n            $this->startingTable,\n            ['[NULL]'     => null],\n            ['%%%name%%%' => 'Mike Lively']\n        );\n\n        TestCase::assertTablesEqual($table, $actual);\n    }\n\n    public function testGetRow(): void\n    {\n        $actual = new ReplacementTable(\n            $this->startingTable,\n            ['[NULL]'     => null],\n            ['%%%name%%%' => 'Mike Lively']\n        );\n\n        $this->assertEquals(\n            [\n                'table1_id' => 1,\n                'column1'   => 'My name is Mike Lively',\n                'column2'   => 200,\n                'column3'   => 34.64,\n                'column4'   => 'yghkf;a  hahfg8ja h;'\n            ],\n            $actual->getRow(0)\n        );\n\n        $this->assertEquals(\n            [\n                'table1_id' => 3,\n                'column1'   => 'ha;gyt',\n                'column2'   => 462,\n                'column3'   => '[NULL] not really',\n                'column4'   => null\n            ],\n            $actual->getRow(2)\n        );\n    }\n\n    public function testGetValue(): void\n    {\n        $actual = new ReplacementTable(\n            $this->startingTable,\n            ['[NULL]'     => null],\n            ['%%%name%%%' => 'Mike Lively']\n        );\n\n        $this->assertNull($actual->getValue(2, 'column4'));\n        $this->assertEquals('My name is Mike Lively', $actual->getValue(0, 'column1'));\n    }\n\n    public function testMatchesWithNonMatchingMetaData(): void\n    {\n        $tableMetaData = $this->createMock(ITableMetadata::class);\n        $otherMetaData = $this->createMock(ITableMetadata::class);\n        $table         = $this->createMock(ITable::class);\n        $otherTable    = $this->createMock(ITable::class);\n\n        $table->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($tableMetaData));\n\n        $otherTable->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($otherMetaData));\n\n        $tableMetaData->expects($this->once())\n            ->method('matches')\n            ->with($otherMetaData)\n            ->will($this->returnValue(false));\n\n        $replacementTable = new ReplacementTable($table);\n        $this->assertFalse($replacementTable->matches($otherTable));\n    }\n\n    public function testMatchesWithNonMatchingRowCount(): void\n    {\n        $tableMetaData = $this->createMock(ITableMetadata::class);\n        $otherMetaData = $this->createMock(ITableMetadata::class);\n        $table         = $this->createMock(ITable::class);\n        $otherTable    = $this->createMock(ITable::class);\n\n        $replacementTable = $this->getMockBuilder(ReplacementTable::class)\n                                 ->setConstructorArgs([$table])\n                                 ->setMethods(['getRowCount'])\n                                 ->getMock();\n\n        $table->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($tableMetaData));\n\n        $otherTable->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($otherMetaData));\n        $otherTable->expects($this->once())\n            ->method('getRowCount')\n            ->will($this->returnValue(0));\n\n        $tableMetaData->expects($this->once())\n            ->method('matches')\n            ->with($otherMetaData)\n            ->will($this->returnValue(true));\n\n        $replacementTable->expects($this->once())\n            ->method('getRowCount')\n            ->will($this->returnValue(1));\n        $this->assertFalse($replacementTable->matches($otherTable));\n    }\n\n    /**\n     * @param array $tableColumnValues\n     * @param array $otherColumnValues\n     * @param bool  $matches\n     * @dataProvider providerMatchesWithColumnValueComparisons\n     */\n    public function testMatchesWithColumnValueComparisons($tableColumnValues, $otherColumnValues, $matches): void\n    {\n        $tableMetaData = $this->createMock(ITableMetadata::class);\n        $otherMetaData = $this->createMock(ITableMetadata::class);\n        $table         = $this->createMock(ITable::class);\n        $otherTable    = $this->createMock(ITable::class);\n\n        $table->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($tableMetaData));\n\n        $otherTable->expects($this->once())\n            ->method('getTableMetaData')\n            ->will($this->returnValue($otherMetaData));\n        $otherTable->expects($this->once())\n            ->method('getRowCount')\n            ->will($this->returnValue(\\count($otherColumnValues)));\n\n        $tableMetaData->expects($this->once())\n            ->method('getColumns')\n            ->will($this->returnValue(\\array_keys(\\reset($tableColumnValues))));\n        $tableMetaData->expects($this->once())\n            ->method('matches')\n            ->with($otherMetaData)\n            ->will($this->returnValue(true));\n\n        $replacementTable = $this->getMockBuilder(ReplacementTable::class)\n                                 ->setConstructorArgs([$table])\n                                 ->setMethods(['getRowCount', 'getValue'])\n                                 ->getMock();\n\n        $replacementTable->expects($this->any())\n            ->method('getRowCount')\n            ->will($this->returnValue(\\count($tableColumnValues)));\n\n        $tableMap = [];\n        $otherMap = [];\n\n        foreach ($tableColumnValues as $rowIndex => $rowData) {\n            foreach ($rowData as $columnName => $columnValue) {\n                $tableMap[] = [$rowIndex, $columnName, $columnValue];\n                $otherMap[] = [$rowIndex, $columnName, $otherColumnValues[$rowIndex][$columnName]];\n            }\n        }\n        $replacementTable->expects($this->any())\n            ->method('getValue')\n            ->will($this->returnValueMap($tableMap));\n        $otherTable->expects($this->any())\n            ->method('getValue')\n            ->will($this->returnValueMap($otherMap));\n\n        $this->assertSame($matches, $replacementTable->matches($otherTable));\n    }\n\n    public function providerMatchesWithColumnValueComparisons()\n    {\n        return [\n\n            // One row, one column, matches\n            [\n                [\n                    ['id' => 1],\n                ],\n                [\n                    ['id' => 1],\n                ],\n                true,\n            ],\n\n            // One row, one column, does not match\n            [\n                [\n                    ['id' => 1],\n                ],\n                [\n                    ['id' => 2],\n                ],\n                false,\n            ],\n\n            // Multiple rows, one column, matches\n            [\n                [\n                    ['id' => 1],\n                    ['id' => 2],\n                ],\n                [\n                    ['id' => 1],\n                    ['id' => 2],\n                ],\n                true,\n            ],\n\n            // Multiple rows, one column, do not match\n            [\n                [\n                    ['id' => 1],\n                    ['id' => 2],\n                ],\n                [\n                    ['id' => 1],\n                    ['id' => 3],\n                ],\n                false,\n            ],\n\n            // Multiple rows, multiple columns, matches\n            [\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'bar'],\n                ],\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'bar'],\n                ],\n                true,\n            ],\n\n            // Multiple rows, multiple columns, do not match\n            [\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'bar'],\n                ],\n                [\n                    ['id' => 1, 'name' => 'foo'],\n                    ['id' => 2, 'name' => 'baz'],\n                ],\n                false,\n            ],\n\n            // Int and int as string must match\n            [\n                [\n                    ['id' => 42],\n                ],\n                [\n                    ['id' => '42'],\n                ],\n                true,\n            ],\n\n            // Float and float as string must match\n            [\n                [\n                    ['id' => 15.3],\n                ],\n                [\n                    ['id' => '15.3'],\n                ],\n                true,\n            ],\n\n            // Int and float must match\n            [\n                [\n                    ['id' => 18.00],\n                ],\n                [\n                    ['id' => 18],\n                ],\n                true,\n            ],\n\n            // 0 and empty string must not match\n            [\n                [\n                    ['id' => 0],\n                ],\n                [\n                    ['id' => ''],\n                ],\n                false,\n            ],\n\n            // 0 and null must not match\n            [\n                [\n                    ['id' => 0],\n                ],\n                [\n                    ['id' => null],\n                ],\n                false,\n            ],\n\n            // empty string and null must not match\n            [\n                [\n                    ['id' => ''],\n                ],\n                [\n                    ['id' => null],\n                ],\n                false,\n            ],\n        ];\n    }\n}\n"
  },
  {
    "path": "tests/DataSet/XmlDataSetsTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Constraint\\DataSetIsEqual;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\FlatXmlDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\MysqlXmlDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\XmlDataSet;\nuse PHPUnit\\Framework\\TestCase;\n\nclass Extensions_Database_DataSet_XmlDataSetsTest extends TestCase\n{\n    protected $expectedDataSet;\n\n    public function setUp(): void\n    {\n        $table1MetaData = new DefaultTableMetadata(\n            'table1',\n            ['table1_id', 'column1', 'column2', 'column3', 'column4']\n        );\n        $table2MetaData = new DefaultTableMetadata(\n            'table2',\n            ['table2_id', 'column5', 'column6', 'column7', 'column8']\n        );\n\n        $table1 = new DefaultTable($table1MetaData);\n        $table2 = new DefaultTable($table2MetaData);\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'tgfahgasdf',\n            'column2'   => 200,\n            'column3'   => 34.64,\n            'column4'   => 'yghkf;a  hahfg8ja h;'\n        ]);\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'hk;afg',\n            'column2'   => 654,\n            'column3'   => 46.54,\n            'column4'   => '24rwehhads'\n        ]);\n        $table1->addRow([\n            'table1_id' => 3,\n            'column1'   => 'ha;gyt',\n            'column2'   => 462,\n            'column3'   => 1654.4,\n            'column4'   => 'asfgklg'\n        ]);\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fhah',\n            'column6'   => 456,\n            'column7'   => 46.5,\n            'column8'   => 'fsdbghfdas'\n        ]);\n        $table2->addRow([\n            'table2_id' => 2,\n            'column5'   => 'asdhfoih',\n            'column6'   => 654,\n            'column7'   => null,\n            'column8'   => '43asdfhgj'\n        ]);\n        $table2->addRow([\n            'table2_id' => 3,\n            'column5'   => 'ajsdlkfguitah',\n            'column6'   => 654,\n            'column7'   => null,\n            'column8'   => null\n        ]);\n\n        $this->expectedDataSet = new DefaultDataSet([$table1, $table2]);\n    }\n\n    public function testFlatXmlDataSet(): void\n    {\n        $constraint     = new DataSetIsEqual($this->expectedDataSet);\n        $xmlFlatDataSet = new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/FlatXmlDataSet.xml');\n\n        self::assertThat($xmlFlatDataSet, $constraint);\n    }\n\n    public function testXmlDataSet(): void\n    {\n        $constraint = new DataSetIsEqual($this->expectedDataSet);\n        $xmlDataSet = new XmlDataSet(__DIR__ . '/../_files/XmlDataSets/XmlDataSet.xml');\n\n        self::assertThat($xmlDataSet, $constraint);\n    }\n\n    public function testMysqlXmlDataSet(): void\n    {\n        $constraint      = new DataSetIsEqual($this->expectedDataSet);\n        $mysqlXmlDataSet = new MysqlXmlDataSet(__DIR__ . '/../_files/XmlDataSets/MysqlXmlDataSet.xml');\n\n        self::assertThat($mysqlXmlDataSet, $constraint);\n    }\n}\n"
  },
  {
    "path": "tests/Operation/OperationsMySQLTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DataSet\\CompositeDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\FlatXmlDataSet;\nuse PHPUnit\\DbUnit\\Operation\\Truncate;\nuse PHPUnit\\DbUnit\\TestCase;\n\nrequire_once \\dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'DatabaseTestUtility.php';\n\nclass Extensions_Database_Operation_OperationsMySQLTest extends TestCase\n{\n    protected function setUp(): void\n    {\n        if (!\\extension_loaded('pdo_mysql')) {\n            $this->markTestSkipped('pdo_mysql is required to run this test.');\n        }\n\n        if (!\\defined('PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN')) {\n            $this->markTestSkipped('No MySQL server configured for this test.');\n        }\n\n        parent::setUp();\n    }\n\n    public function getConnection()\n    {\n        return new DefaultConnection(DBUnitTestUtility::getMySQLDB(), 'mysql');\n    }\n\n    public function getDataSet()\n    {\n        return new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/OperationsMySQLTestFixture.xml');\n    }\n\n    /**\n     * @covers Truncate::execute\n     */\n    public function testTruncate(): void\n    {\n        $truncateOperation = new Truncate();\n        $truncateOperation->execute($this->getConnection(), $this->getDataSet());\n\n        $expectedDataSet = new DefaultDataSet([\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table1',\n                    ['table1_id', 'column1', 'column2', 'column3', 'column4']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table2',\n                    ['table2_id', 'table1_id', 'column5', 'column6', 'column7', 'column8']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table3',\n                    ['table3_id', 'table2_id', 'column9', 'column10', 'column11', 'column12']\n                )\n            ),\n        ]);\n\n        $this->assertDataSetsEqual($expectedDataSet, $this->getConnection()->createDataSet());\n    }\n\n    public function getCompositeDataSet()\n    {\n        $compositeDataset = new CompositeDataSet();\n\n        $dataset = $this->createXMLDataSet(__DIR__ . '/../_files/XmlDataSets/TruncateCompositeTest.xml');\n        $compositeDataset->addDataSet($dataset);\n\n        return $compositeDataset;\n    }\n\n    public function testTruncateComposite(): void\n    {\n        $truncateOperation = new Truncate();\n        $truncateOperation->execute($this->getConnection(), $this->getCompositeDataSet());\n\n        $expectedDataSet = new DefaultDataSet([\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table1',\n                    ['table1_id', 'column1', 'column2', 'column3', 'column4']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table2',\n                    ['table2_id', 'table1_id', 'column5', 'column6', 'column7', 'column8']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table3',\n                    ['table3_id', 'table2_id', 'column9', 'column10', 'column11', 'column12']\n                )\n            ),\n        ]);\n\n        $this->assertDataSetsEqual($expectedDataSet, $this->getConnection()->createDataSet());\n    }\n}\n"
  },
  {
    "path": "tests/Operation/OperationsTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\FlatXmlDataSet;\nuse PHPUnit\\DbUnit\\Operation\\Delete;\nuse PHPUnit\\DbUnit\\Operation\\DeleteAll;\nuse PHPUnit\\DbUnit\\Operation\\Insert;\nuse PHPUnit\\DbUnit\\Operation\\Replace;\nuse PHPUnit\\DbUnit\\Operation\\Truncate;\nuse PHPUnit\\DbUnit\\Operation\\Update;\nuse PHPUnit\\DbUnit\\TestCase;\n\nrequire_once \\dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'DatabaseTestUtility.php';\n\nclass Extensions_Database_Operation_OperationsTest extends TestCase\n{\n    protected function setUp(): void\n    {\n        if (!\\extension_loaded('pdo_sqlite')) {\n            $this->markTestSkipped('PDO/SQLite is required to run this test.');\n        }\n\n        parent::setUp();\n    }\n\n    public function getConnection()\n    {\n        return new DefaultConnection(DBUnitTestUtility::getSQLiteMemoryDB(), 'sqlite');\n    }\n\n    public function getDataSet()\n    {\n        return new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/OperationsTestFixture.xml');\n    }\n\n    public function testDelete(): void\n    {\n        $deleteOperation = new Delete();\n\n        $deleteOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/DeleteOperationTest.xml'));\n\n        $this->assertDataSetsEqual(new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/DeleteOperationResult.xml'), $this->getConnection()->createDataSet());\n    }\n\n    public function testDeleteAll(): void\n    {\n        $deleteAllOperation = new DeleteAll();\n\n        $deleteAllOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/DeleteAllOperationTest.xml'));\n\n        $expectedDataSet = new DefaultDataSet([\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table1',\n                    ['table1_id', 'column1', 'column2', 'column3', 'column4']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table2',\n                    ['table2_id', 'column5', 'column6', 'column7', 'column8']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table3',\n                    ['table3_id', 'column9', 'column10', 'column11', 'column12']\n                )\n            ),\n        ]);\n\n        $this->assertDataSetsEqual($expectedDataSet, $this->getConnection()->createDataSet());\n    }\n\n    public function testTruncate(): void\n    {\n        $truncateOperation = new Truncate();\n\n        $truncateOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/DeleteAllOperationTest.xml'));\n\n        $expectedDataSet = new DefaultDataSet([\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table1',\n                    ['table1_id', 'column1', 'column2', 'column3', 'column4']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table2',\n                    ['table2_id', 'column5', 'column6', 'column7', 'column8']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table3',\n                    ['table3_id', 'column9', 'column10', 'column11', 'column12']\n                )\n            ),\n        ]);\n\n        $this->assertDataSetsEqual($expectedDataSet, $this->getConnection()->createDataSet());\n    }\n\n    public function testInsert(): void\n    {\n        $insertOperation = new Insert();\n\n        $insertOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/InsertOperationTest.xml'));\n\n        $this->assertDataSetsEqual(new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/InsertOperationResult.xml'), $this->getConnection()->createDataSet());\n    }\n\n    public function testUpdate(): void\n    {\n        $updateOperation = new Update();\n\n        $updateOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/UpdateOperationTest.xml'));\n\n        $this->assertDataSetsEqual(new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/UpdateOperationResult.xml'), $this->getConnection()->createDataSet());\n    }\n\n    public function testReplace(): void\n    {\n        $replaceOperation = new Replace();\n\n        $replaceOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/ReplaceOperationTest.xml'));\n\n        $this->assertDataSetsEqual(new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/ReplaceOperationResult.xml'), $this->getConnection()->createDataSet());\n    }\n\n    public function testInsertEmptyTable(): void\n    {\n        $insertOperation = new Insert();\n\n        $insertOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/EmptyTableInsertTest.xml'));\n\n        $this->assertDataSetsEqual(new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/EmptyTableInsertResult.xml'), $this->getConnection()->createDataSet());\n    }\n\n    public function testInsertAllEmptyTables(): void\n    {\n        $insertOperation = new Insert();\n\n        $insertOperation->execute($this->getConnection(), new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/AllEmptyTableInsertTest.xml'));\n\n        $this->assertDataSetsEqual(new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/AllEmptyTableInsertResult.xml'), $this->getConnection()->createDataSet());\n    }\n}\n"
  },
  {
    "path": "tests/Operation/RowBasedTest.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nuse PHPUnit\\DbUnit\\Database\\Connection;\nuse PHPUnit\\DbUnit\\Database\\DefaultConnection;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTable;\nuse PHPUnit\\DbUnit\\DataSet\\DefaultTableMetadata;\nuse PHPUnit\\DbUnit\\DataSet\\FlatXmlDataSet;\nuse PHPUnit\\DbUnit\\DataSet\\ITable;\nuse PHPUnit\\DbUnit\\DataSet\\ITableMetadata;\nuse PHPUnit\\DbUnit\\Operation\\Exception as OperationException;\nuse PHPUnit\\DbUnit\\Operation\\RowBased;\nuse PHPUnit\\DbUnit\\TestCase;\n\nrequire_once \\dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'DatabaseTestUtility.php';\n\nclass Extensions_Database_Operation_RowBasedTest extends TestCase\n{\n    protected function setUp(): void\n    {\n        if (!\\extension_loaded('pdo_sqlite')) {\n            $this->markTestSkipped('PDO/SQLite is required to run this test.');\n        }\n\n        parent::setUp();\n    }\n\n    public function getConnection()\n    {\n        return new DefaultConnection(DBUnitTestUtility::getSQLiteMemoryDB(), 'sqlite');\n    }\n\n    public function getDataSet()\n    {\n        $tables = [\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table1',\n                    ['table1_id', 'column1', 'column2', 'column3', 'column4']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table2',\n                    ['table2_id', 'column5', 'column6', 'column7', 'column8']\n                )\n            ),\n            new DefaultTable(\n                new DefaultTableMetadata(\n                    'table3',\n                    ['table3_id', 'column9', 'column10', 'column11', 'column12']\n                )\n            ),\n        ];\n\n        return new DefaultDataSet($tables);\n    }\n\n    public function testExecute(): void\n    {\n        $connection = $this->getConnection();\n        /* @var $connection DefaultConnection */\n        $table1 = new DefaultTable(\n            new DefaultTableMetadata('table1', ['table1_id', 'column1', 'column2', 'column3', 'column4'])\n        );\n\n        $table1->addRow([\n            'table1_id' => 1,\n            'column1'   => 'foo',\n            'column2'   => 42,\n            'column3'   => 4.2,\n            'column4'   => 'bar'\n        ]);\n\n        $table1->addRow([\n            'table1_id' => 2,\n            'column1'   => 'qwerty',\n            'column2'   => 23,\n            'column3'   => 2.3,\n            'column4'   => 'dvorak'\n        ]);\n\n        $table2 = new DefaultTable(\n            new DefaultTableMetadata('table2', ['table2_id', 'column5', 'column6', 'column7', 'column8'])\n        );\n\n        $table2->addRow([\n            'table2_id' => 1,\n            'column5'   => 'fdyhkn',\n            'column6'   => 64,\n            'column7'   => 4568.64,\n            'column8'   => 'hkladfg'\n        ]);\n\n        $dataSet = new DefaultDataSet([$table1, $table2]);\n\n        $mockOperation = $this->createPartialMock(\n            RowBased::class,\n                ['buildOperationQuery', 'buildOperationArguments']\n        );\n\n        /* @var $mockOperation PHPUnit_Framework_MockObject_MockObject */\n        $mockOperation->expects($this->at(0))\n                ->method('buildOperationQuery')\n                ->with($connection->createDataSet()->getTableMetaData('table1'), $table1)\n                ->will(\n                    $this->returnValue('INSERT INTO table1 (table1_id, column1, column2, column3, column4) VALUES (?, ?, ?, ?, ?)')\n                );\n\n        $mockOperation->expects($this->at(1))\n                ->method('buildOperationArguments')\n                ->with($connection->createDataSet()->getTableMetaData('table1'), $table1, 0)\n                ->will(\n                    $this->returnValue([1, 'foo', 42, 4.2, 'bar'])\n                );\n\n        $mockOperation->expects($this->at(2))\n                ->method('buildOperationArguments')\n                ->with($connection->createDataSet()->getTableMetaData('table1'), $table1, 1)\n                ->will(\n                    $this->returnValue([2, 'qwerty', 23, 2.3, 'dvorak'])\n                );\n\n        $mockOperation->expects($this->at(3))\n                ->method('buildOperationQuery')\n                ->with($connection->createDataSet()->getTableMetaData('table2'), $table2)\n                ->will(\n                    $this->returnValue('INSERT INTO table2 (table2_id, column5, column6, column7, column8) VALUES (?, ?, ?, ?, ?)')\n                );\n\n        $mockOperation->expects($this->at(4))\n                ->method('buildOperationArguments')\n                ->with($connection->createDataSet()->getTableMetaData('table2'), $table2, 0)\n                ->will(\n                    $this->returnValue([1, 'fdyhkn', 64, 4568.64, 'hkladfg'])\n                );\n\n        /* @var $mockOperation RowBased */\n        $mockOperation->execute($connection, $dataSet);\n\n        $this->assertDataSetsEqual(new FlatXmlDataSet(__DIR__ . '/../_files/XmlDataSets/RowBasedExecute.xml'), $connection->createDataSet(['table1', 'table2']));\n    }\n\n    public function testExecuteWithBadQuery(): void\n    {\n        $mockDatabaseDataSet = $this->createMock(DefaultDataSet::class);\n        $mockDatabaseDataSet->expects($this->never())->method('getTableMetaData');\n\n        $mockConnection = $this->createMock(Connection::class);\n        $mockConnection->expects($this->once())->method('createDataSet')->will($this->returnValue($mockDatabaseDataSet));\n\n        foreach (['getConnection', 'disablePrimaryKeys', 'enablePrimaryKeys'] as $method) {\n            $mockConnection->expects($this->never())->method($method);\n        }\n\n        $mockTableMetaData = $this->createMock(ITableMetadata::class);\n        $mockTableMetaData->expects($this->any())->method('getTableName')->will($this->returnValue('table'));\n        $mockTable = $this->createMock(ITable::class);\n        $mockTable->expects($this->any())->method('getTableMetaData')->will($this->returnValue($mockTableMetaData));\n        $mockTable->expects($this->once())->method('getRowCount')->will($this->returnValue(0));\n\n        $mockDataSet = $this->createMock(DefaultDataSet::class);\n        $mockDataSet->expects($this->once())->method('getIterator')->will($this->returnValue(new ArrayIterator([$mockTable])));\n\n        $mockOperation = $this->createPartialMock(\n            RowBased::class,\n            ['buildOperationQuery', 'buildOperationArguments']\n        );\n        $mockOperation->expects($this->never())->method('buildOperationArguments');\n        $mockOperation->expects($this->never())->method('buildOperationQuery');\n\n        $mockOperation->execute($mockConnection, $mockDataSet);\n    }\n\n    public function testExecuteHandlesException(): void\n    {\n        $this->expectException(OperationException::class);\n\n        $rowCount          = 1;\n        $mockTableMetaData = $this->createMock(ITableMetadata::class);\n        $mockTableMetaData->expects($this->any())->method('getTableName')->will($this->returnValue('table'));\n        $mockTable = $this->createMock(ITable::class);\n        $mockTable->expects($this->any())->method('getTableMetaData')->will($this->returnValue($mockTableMetaData));\n        $mockTable->expects($this->once())->method('getRowCount')->will($this->returnValue($rowCount));\n\n        $mockDatabaseDataSet = $this->createMock(DefaultDataSet::class);\n        $mockDatabaseDataSet->expects($this->once())->method('getTableMetaData')->will($this->returnValue($mockTableMetaData));\n\n        $mockPdoStatement = $this->createMock(PDOStatement::class);\n        $mockPdoStatement->expects($this->once())->method('execute')->will($this->throwException(new Exception()));\n        $mockPdoConnection = $this->createMock(PDO::class);\n        $mockPdoConnection->expects($this->once())->method('prepare')->will($this->returnValue($mockPdoStatement));\n\n        $mockConnection = $this->createMock(Connection::class);\n        $mockConnection->expects($this->once())->method('createDataSet')->will($this->returnValue($mockDatabaseDataSet));\n        $mockConnection->expects($this->once())->method('getConnection')->will($this->returnValue($mockPdoConnection));\n        $mockConnection->expects($this->never())->method('disablePrimaryKeys');\n        $mockConnection->expects($this->never())->method('enablePrimaryKeys');\n\n        $mockDataSet = $this->createMock(DefaultDataSet::class);\n        $mockDataSet->expects($this->once())->method('getIterator')->will($this->returnValue(new ArrayIterator([$mockTable])));\n\n        $mockOperation = $this->createPartialMock(\n            RowBased::class,\n            ['buildOperationQuery', 'buildOperationArguments']\n        );\n        $mockOperation->expects($this->once())->method('buildOperationQuery')->will($this->returnValue(''));\n        $mockOperation->expects($this->exactly($rowCount))->method('buildOperationArguments')->will($this->returnValue([]));\n\n        $mockOperation->execute($mockConnection, $mockDataSet);\n    }\n}\n"
  },
  {
    "path": "tests/_files/CsvDataSets/table1.csv",
    "content": "table1_id,column1,column2,column3,column4\n1,tgfahgasdf,200,34.64,\"yghkf;a  hahfg8ja h;\"\n2,hk;afg,654,46.54,24rwehhads\n3,ha;gyt,462,1654.4,asfgklg\n"
  },
  {
    "path": "tests/_files/CsvDataSets/table2.csv",
    "content": "table2_id,column5,column6,column7,column8\n1,fhah,456,46.5,\"fsdb, ghfdas\"\n2,asdhfoih,654,blah,\"43asd \"\"fhgj\"\" sfadh\"\n3,ajsdlkfguitah,654,blah,\"thesethasdl\nasdflkjsadf asdfsadfhl \"\"adsf, halsdf\"\" sadfhlasdf\"\n"
  },
  {
    "path": "tests/_files/DatabaseTestUtility.php",
    "content": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nclass DBUnitTestUtility\n{\n    protected static $connection;\n    protected static $mySQLConnection;\n\n    public static function getSQLiteMemoryDB()\n    {\n        if (self::$connection === null) {\n            self::$connection = new PDO('sqlite::memory:');\n            self::setUpDatabase(self::$connection);\n        }\n\n        return self::$connection;\n    }\n\n    /**\n     * Creates connection to test MySQL database\n     *\n     * MySQL server must be installed locally, with root access\n     * and empty password and listening on unix socket\n     *\n     * @return PDO\n     *\n     * @see    DBUnitTestUtility::setUpMySqlDatabase()\n     */\n    public static function getMySQLDB()\n    {\n        if (self::$mySQLConnection === null) {\n            self::$mySQLConnection = new PDO(PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN, PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_USERNAME, PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_PASSWORD);\n\n            self::setUpMySQLDatabase(self::$mySQLConnection);\n        }\n\n        return self::$mySQLConnection;\n    }\n\n    protected static function setUpDatabase(PDO $connection): void\n    {\n        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);\n\n        $connection->exec(\n          'CREATE TABLE IF NOT EXISTS table1 (\n            table1_id INTEGER PRIMARY KEY AUTOINCREMENT,\n            column1 VARCHAR(20),\n            column2 INT(10),\n            column3 DECIMAL(6,2),\n            column4 TEXT\n          )'\n        );\n\n        $connection->exec(\n          'CREATE TABLE IF NOT EXISTS table2 (\n            table2_id INTEGER PRIMARY KEY AUTOINCREMENT,\n            column5 VARCHAR(20),\n            column6 INT(10),\n            column7 DECIMAL(6,2),\n            column8 TEXT\n          )'\n        );\n\n        $connection->exec(\n          'CREATE TABLE IF NOT EXISTS table3 (\n            table3_id INTEGER PRIMARY KEY AUTOINCREMENT,\n            column9 VARCHAR(20),\n            column10 INT(10),\n            column11 DECIMAL(6,2),\n            column12 TEXT\n          )'\n        );\n    }\n\n    /**\n     * Creates default testing schema for MySQL database\n     *\n     * Tables must containt foreign keys and use InnoDb storage engine\n     * for constraint tests to be executed properly\n     *\n     * @param PDO $connection PDO instance representing connection to MySQL database\n     *\n     * @see   DBUnitTestUtility::getMySQLDB()\n     */\n    protected static function setUpMySqlDatabase(PDO $connection): void\n    {\n        $connection->exec(\n          'CREATE TABLE IF NOT EXISTS table1 (\n            table1_id INTEGER AUTO_INCREMENT,\n            column1 VARCHAR(20),\n            column2 INT(10),\n            column3 DECIMAL(6,2),\n            column4 TEXT,\n            PRIMARY KEY (table1_id)\n          ) ENGINE=INNODB;\n        '\n        );\n\n        $connection->exec(\n          'CREATE TABLE IF NOT EXISTS table2 (\n            table2_id INTEGER AUTO_INCREMENT,\n            table1_id INTEGER,\n            column5 VARCHAR(20),\n            column6 INT(10),\n            column7 DECIMAL(6,2),\n            column8 TEXT,\n            PRIMARY KEY (table2_id),\n            FOREIGN KEY (table1_id) REFERENCES table1(table1_id)\n          ) ENGINE=INNODB;\n        '\n        );\n\n        $connection->exec(\n          'CREATE TABLE IF NOT EXISTS table3 (\n            table3_id INTEGER AUTO_INCREMENT,\n            table2_id INTEGER,\n            column9 VARCHAR(20),\n            column10 INT(10),\n            column11 DECIMAL(6,2),\n            column12 TEXT,\n            PRIMARY KEY (table3_id),\n            FOREIGN KEY (table2_id) REFERENCES table2(table2_id)\n          ) ENGINE=INNODB;\n        '\n        );\n    }\n}\n"
  },
  {
    "path": "tests/_files/XmlDataSets/AllEmptyTableInsertResult.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n    <table2 table2_id=\"1\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"2\" column9=\"asdfgh\" column10=\"76\" column11=\"9413.521\" column12=\"ghgkj;guagfghjhfd\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/AllEmptyTableInsertTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1/>\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/DeleteAllOperationTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" />\n    <table2 table2_id=\"1\" />\n    <table3 table3_id=\"1\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/DeleteOperationResult.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table2 table2_id=\"1\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/DeleteOperationTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"2\" />\n    <table3 table3_id=\"2\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/EmptyTableInsertResult.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n    <table2 table2_id=\"1\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n    <table2 table2_id=\"2\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"2\" column9=\"asdfgh\" column10=\"76\" column11=\"9413.521\" column12=\"ghgkj;guagfghjhfd\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n    <table3 table3_id=\"4\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/EmptyTableInsertTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1/>\n    <table2 table2_id=\"2\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table3 table3_id=\"4\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/FilteredTestComparison.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n    <table2 table2_id=\"1\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"2\" column9=\"asdfgh\" column10=\"76\" column11=\"9413.521\" column12=\"ghgkj;guagfghjhfd\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/FilteredTestFixture.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n    <table3 column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 column9=\"asdfgh\" column10=\"76\" column11=\"9413.521\" column12=\"ghgkj;guagfghjhfd\" />\n    <table3 column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/FlatXmlDataSet.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"tgfahgasdf\" column2=\"200\" column3=\"34.64\" column4=\"yghkf;a  hahfg8ja h;\" />\n    <table1 table1_id=\"2\" column1=\"hk;afg\" column2=\"654\" column3=\"46.54\" column4=\"24rwehhads\" />\n    <table1 table1_id=\"3\" column1=\"ha;gyt\" column2=\"462\" column3=\"1654.4\" column4=\"asfgklg\" />\n    <table2 table2_id=\"1\" column5=\"fhah\" column6=\"456\" column7=\"46.5\" column8=\"fsdbghfdas\" />\n    <table2 table2_id=\"2\" column5=\"asdhfoih\" column6=\"654\" column8=\"43asdfhgj\" />\n    <table2 table2_id=\"3\" column5=\"ajsdlkfguitah\" column6=\"654\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/FlatXmlWriter.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1\n        col1=\"val1\"\n        col2=\"val2\"\n        col3=\"val3\"\n    />\n    <table1\n        col1=\"val4\"\n        col2=\"val5\"\n        col3=\"val6\"\n    />\n    <table1\n        col1=\"val7\"\n        col2=\"val8\"\n        col3=\"val9\"\n    />\n    <emptytable />\n    <table2\n        col1=\"val10\"\n        col2=\"val11\"\n        col3=\"val12\"\n    />\n    <table2\n        col1=\"val13\"\n        col3=\"val14\"\n    />\n    <table2\n        col1=\"val15\"\n        col2=\"val16\"\n    />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/FlatXmlWriterEntities.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<dataset>\n    <table1\n        col1=\"1\"\n        col2=\"&lt;?xml version=&quot;1.0&quot;?&gt;&lt;myxml&gt;test&lt;/myxml&gt;\"\n    />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/InsertOperationResult.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n    <table1 table1_id=\"3\" column1=\"ggfdsa\" column2=\"4654\" column3=\"45.65\" column4=\"41gkjfdhyglj54dsfaf\" />\n    <table2 table2_id=\"1\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n    <table2 table2_id=\"2\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"2\" column9=\"asdfgh\" column10=\"76\" column11=\"9413.521\" column12=\"ghgkj;guagfghjhfd\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n    <table3 table3_id=\"4\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/InsertOperationTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"3\" column1=\"ggfdsa\" column2=\"4654\" column3=\"45.65\" column4=\"41gkjfdhyglj54dsfaf\" />\n    <table2 table2_id=\"2\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table3 table3_id=\"4\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/MysqlXmlDataSet.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mysqldump xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n<database name=\"database_name\">\n    <table_data name=\"table1\">\n    <row>\n        <field name=\"table1_id\">1</field>\n        <field name=\"column1\">tgfahgasdf</field>\n        <field name=\"column2\">200</field>\n        <field name=\"column3\">34.64</field>\n        <field name=\"column4\">yghkf;a  hahfg8ja h;</field>\n    </row>\n    <row>\n        <field name=\"table1_id\">2</field>\n        <field name=\"column1\">hk;afg</field>\n        <field name=\"column2\">654</field>\n        <field name=\"column3\">46.54</field>\n        <field name=\"column4\">24rwehhads</field>\n    </row>\n    <row>\n        <field name=\"table1_id\">3</field>\n        <field name=\"column1\">ha;gyt</field>\n        <field name=\"column2\">462</field>\n        <field name=\"column3\">1654.4</field>\n        <field name=\"column4\">asfgklg</field>\n    </row>\n    </table_data>\n    <table_data name=\"table2\">\n    <row>\n        <field name=\"table2_id\">1</field>\n        <field name=\"column5\">fhah</field>\n        <field name=\"column6\">456</field>\n        <field name=\"column7\">46.5</field>\n        <field name=\"column8\">fsdbghfdas</field>\n    </row>\n    <row>\n        <field name=\"table2_id\">2</field>\n        <field name=\"column5\">asdhfoih</field>\n        <field name=\"column6\">654</field>\n        <field name=\"column7\" xsi:nil=\"true\" />\n        <field name=\"column8\">43asdfhgj</field>\n    </row>\n    <row>\n        <field name=\"table2_id\">3</field>\n        <field name=\"column5\">ajsdlkfguitah</field>\n        <field name=\"column6\">654</field>\n        <field name=\"column7\" xsi:nil=\"true\" />\n        <field name=\"column8\" xsi:nil=\"true\" />\n    </row>\n    </table_data>\n</database>\n</mysqldump>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/OperationsMySQLTestFixture.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n  <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n  <table1 table1_id=\"2\" column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n  <table2 table2_id=\"1\" table1_id=\"2\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n  <table3 table3_id=\"1\" table2_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n  <table3 table3_id=\"2\" table2_id=\"1\" column9=\"asdfgh\" column10=\"76\" column11=\"9413.521\" column12=\"ghgkj;guagfghjhfd\" />\n  <table3 table3_id=\"3\" table2_id=\"1\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/OperationsTestFixture.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n    <table2 table2_id=\"1\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"2\" column9=\"asdfgh\" column10=\"76\" column11=\"9413.521\" column12=\"ghgkj;guagfghjhfd\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/QueryDataSetTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n<table1\n    table1_id=\"1\"\n    column1=\"test\"\n    column2=\"10\"\n    column3=\"20.5\"\n    column4=\"query test\"\n/>\n<table1\n    table1_id=\"2\"\n    column1=\"foo\"\n    column2=\"20\"\n    column3=\"30.6\"\n    column4=\"query test 2\"\n/>\n<table1\n    table1_id=\"3\"\n    column1=\"bar\"\n    column2=\"30\"\n    column3=\"40.7\"\n    column4=\"query test 3\"\n/>\n<table2\n    table2_id=\"3\"\n    column5=\"blah\"\n    column6=\"40\"\n    column7=\"50.8\"\n    column8=\"query test 4\"\n/>\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/ReplaceOperationResult.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"jgfdasg\" column2=\"4654\" column3=\"45.65\" column4=\"41gkjfdhyglj54dsfaf\" />\n    <table1 table1_id=\"3\" column1=\"ggfdsa\" column2=\"45\" column3=\"1.4\" column4=\"asfhajj\" />\n    <table2 table2_id=\"1\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table2 table2_id=\"2\" column5=\"gasupj\" column6=\"9165\" column7=\"456.65\" column8=\"asfdh sdghkj\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"2\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n    <table3 table3_id=\"4\" column9=\"asdfgaf\" column10=\"152\" column11=\"465.4\" column12=\"dsafhl;a sji[uh ;\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/ReplaceOperationTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"2\" column1=\"jgfdasg\" column2=\"4654\" column3=\"45.65\" column4=\"41gkjfdhyglj54dsfaf\" />\n    <table1 table1_id=\"3\" column1=\"ggfdsa\" column2=\"45\" column3=\"1.4\" column4=\"asfhajj\" />\n    <table2 table2_id=\"1\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table2 table2_id=\"2\" column5=\"gasupj\" column6=\"9165\" column7=\"456.65\" column8=\"asfdh sdghkj\" />\n    <table3 table3_id=\"2\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n    <table3 table3_id=\"4\" column9=\"asdfgaf\" column10=\"152\" column11=\"465.4\" column12=\"dsafhl;a sji[uh ;\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/RowBasedExecute.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"qwerty\" column2=\"23\" column3=\"2.3\" column4=\"dvorak\" />\n    <table2 table2_id=\"1\" column5=\"fdyhkn\" column6=\"64\" column7=\"4568.64\" column8=\"hkladfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/TruncateCompositeTest.xml",
    "content": "<?xml version=\"1.0\" ?>\n<dataset>\n    <table name=\"table1\">\n        <column>table1_id</column>\n        <column>column1</column>\n        <column>column2</column>\n        <column>column3</column>\n        <column>column4</column>\n        <row>\n            <value>1</value>\n            <null />\n            <null />\n            <null />\n            <null />\n        </row>\n    </table>\n    <table name=\"table2\">\n        <column>table2_id</column>\n        <column>table1_id</column>\n        <column>column5</column>\n        <column>column6</column>\n        <column>column7</column>\n        <column>column8</column>\n        <row>\n            <value>1</value>\n            <value>1</value>\n            <null />\n            <null />\n            <null />\n            <null />\n        </row>\n    </table>\n    <table name=\"table3\">\n        <column>table3_id</column>\n        <column>table2_id</column>\n        <column>column9</column>\n        <column>column10</column>\n        <column>column11</column>\n        <column>column12</column>\n        <row>\n            <value>1</value>\n            <value>1</value>\n            <null />\n            <null />\n            <null />\n            <null />\n        </row>\n    </table>\n</dataset>"
  },
  {
    "path": "tests/_files/XmlDataSets/UpdateOperationResult.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n    <table1 table1_id=\"2\" column1=\"ggfdsa\" column2=\"4654\" column3=\"45.65\" column4=\"41gkjfdhyglj54dsfaf\" />\n    <table2 table2_id=\"1\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table3 table3_id=\"1\" column9=\"hgdshhh\" column10=\"94\" column11=\"8745.94\" column12=\"ghsf;ugjhgdsfyhjhkdfa\" />\n    <table3 table3_id=\"2\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n    <table3 table3_id=\"3\" column9=\"itgewqe\" column10=\"16\" column11=\"1562.65\" column12=\"jkkjhgjhgcfddfg\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/UpdateOperationTest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"2\" column1=\"ggfdsa\" column2=\"4654\" column3=\"45.65\" column4=\"41gkjfdhyglj54dsfaf\" />\n    <table2 table2_id=\"1\" column5=\"gfdsagfpwah\" column6=\"464\" column7=\"462.45\" column8=\"hsafd;jhsadfyh;wafsfg gfv s,da b\" />\n    <table3 table3_id=\"2\" column9=\"hoafsd\" column10=\"54563\" column11=\"14.54\" column12=\"hsda8oh   hklsdgsd hiisvinv mdsav;;\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/XmlDataSet.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table name=\"table1\">\n        <column>table1_id</column>\n        <column>column1</column>\n        <column>column2</column>\n        <column>column3</column>\n        <column>column4</column>\n        <row>\n            <value>1</value>\n            <value>tgfahgasdf</value>\n            <value>200</value>\n            <value>34.64</value>\n            <value>yghkf;a  hahfg8ja h;</value>\n        </row>\n        <row>\n            <value>2</value>\n            <value>hk;afg</value>\n            <value>654</value>\n            <value>46.54</value>\n            <value>24rwehhads</value>\n        </row>\n        <row>\n            <value>3</value>\n            <value>ha;gyt</value>\n            <value>462</value>\n            <value>1654.4</value>\n            <value>asfgklg</value>\n        </row>\n    </table>\n    <table name=\"table2\">\n        <column>table2_id</column>\n        <column>column5</column>\n        <column>column6</column>\n        <column>column7</column>\n        <column>column8</column>\n        <row>\n            <value>1</value>\n            <value>fhah</value>\n            <value>456</value>\n            <value>46.5</value>\n            <value>fsdbghfdas</value>\n        </row>\n        <row>\n            <value>2</value>\n            <value>asdhfoih</value>\n            <value>654</value>\n            <null />\n            <value>43asdfhgj</value>\n        </row>\n        <row>\n            <value>3</value>\n            <value>ajsdlkfguitah</value>\n            <value>654</value>\n            <null />\n            <null />\n        </row>\n    </table>\n    <table1 table1_id=\"1\" column1=\"tgfahgasdf\" column2=\"200\" column3=\"34.64\" column4=\"yghkf;a  hahfg8ja h;\" />\n    <table1 table1_id=\"2\" column1=\"hk;afg\" column2=\"654\" column3=\"46.54\" column4=\"24rwehhads\" />\n    <table1 table1_id=\"3\" column1=\"ha;gyt\" column2=\"462\" column3=\"1654.4\" column4=\"asfgklg\" />\n    <table2 table2_id=\"1\" column5=\"fhah\" column6=\"456\" column7=\"46.5\" column8=\"fsdbghfdas\" />\n    <table2 table2_id=\"2\" column5=\"asdhfoih\" column6=\"654\" column8=\"43asdfhgj\" />\n    <table2 table2_id=\"3\" column5=\"ajsdlkfguitah\" column6=\"654\" />\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/XmlWriter.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table name=\"table1\">\n        <column>col1</column>\n        <column>col2</column>\n        <column>col3</column>\n        <row>\n            <value>val1</value>\n            <value>val2</value>\n            <value>val3</value>\n        </row>\n        <row>\n            <value></value>\n            <null />\n            <value>val4</value>\n        </row>\n        <row>\n            <value>val5</value>\n            <value>val6</value>\n            <value>val7</value>\n        </row>\n    </table>\n    <table name=\"table2\">\n        <column>col1</column>\n        <column>col2</column>\n        <column>col3</column>\n    </table>\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/XmlWriterEntities.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<dataset>\n    <table name=\"table1\">\n        <column>col1</column>\n        <column>col2</column>\n        <row>\n            <value>1</value>\n            <value>&lt;?xml version=&quot;1.0&quot;?&gt;&lt;myxml&gt;test&lt;/myxml&gt;</value>\n        </row>\n    </table>\n</dataset>\n"
  },
  {
    "path": "tests/_files/YamlDataSets/testDataSet.yaml",
    "content": "table1:\n  -\n    table1_id: 1\n    column1: \"tgfahgasdf\"\n    column2: 200\n    column3: 34.64\n    column4: \"yghkf;a  hahfg8ja h;\"\n  -\n    table1_id: 2\n    column1: \"hk;afg\"\n    column2: 654\n    column3: 46.54\n    column4: 24rwehhads\n    extraColumn: 'causes no worries'\n  -\n    table1_id: 3\n    column1: ha;gyt\n    column2: 462\n    column3: 1654.4\n    column4: asfgklg\ntable2:\n  -\n    table2_id: 1\n    column5: fhah\n    column6: 456\n    column7: 46.5\n    column8: \"fsdb, ghfdas\"\n  -\n    table2_id: 2\n    column5: asdhfoih\n    column6: 654\n    column7: blah\n    column8: \"43asd \\\"fhgj\\\" sfadh\"\n  -\n    table2_id: 3\n    column5: ajsdlkfguitah\n    column6: 654\n    column7: blah\n    column8: |-\n      thesethasdl\n      asdflkjsadf asdfsadfhl \"adsf, halsdf\" sadfhlasdf\n\nemptyTable:\n\n"
  }
]