Full Code of sebastianbergmann/dbunit for AI

master 15e4875f5778 cached
138 files
294.3 KB
77.5k tokens
527 symbols
1 requests
Download .txt
Showing preview only (327K chars total). Download the full file or copy to clipboard to get everything.
Repository: sebastianbergmann/dbunit
Branch: master
Commit: 15e4875f5778
Files: 138
Total size: 294.3 KB

Directory structure:
gitextract_j8io8xmv/

├── .gitattributes
├── .gitignore
├── .php_cs.dist
├── .travis.yml
├── ChangeLog.md
├── LICENSE
├── README.md
├── build.xml
├── composer.json
├── manifest.xml
├── phive.xml
├── phpunit-travis.xml
├── phpunit.xml
├── src/
│   ├── AbstractTester.php
│   ├── Constraint/
│   │   ├── DataSetIsEqual.php
│   │   ├── TableIsEqual.php
│   │   └── TableRowCount.php
│   ├── DataSet/
│   │   ├── AbstractDataSet.php
│   │   ├── AbstractTable.php
│   │   ├── AbstractTableMetadata.php
│   │   ├── AbstractXmlDataSet.php
│   │   ├── ArrayDataSet.php
│   │   ├── CompositeDataSet.php
│   │   ├── CsvDataSet.php
│   │   ├── DefaultDataSet.php
│   │   ├── DefaultTable.php
│   │   ├── DefaultTableIterator.php
│   │   ├── DefaultTableMetadata.php
│   │   ├── Filter.php
│   │   ├── FlatXmlDataSet.php
│   │   ├── IDataSet.php
│   │   ├── ITable.php
│   │   ├── ITableIterator.php
│   │   ├── ITableMetadata.php
│   │   ├── IYamlParser.php
│   │   ├── MysqlXmlDataSet.php
│   │   ├── QueryDataSet.php
│   │   ├── QueryTable.php
│   │   ├── ReplacementDataSet.php
│   │   ├── ReplacementTable.php
│   │   ├── ReplacementTableIterator.php
│   │   ├── Specification/
│   │   │   ├── Csv.php
│   │   │   ├── Factory.php
│   │   │   ├── FlatXml.php
│   │   │   ├── IFactory.php
│   │   │   ├── Query.php
│   │   │   ├── Specification.php
│   │   │   ├── Table.php
│   │   │   ├── Xml.php
│   │   │   └── Yaml.php
│   │   ├── SymfonyYamlParser.php
│   │   ├── TableFilter.php
│   │   ├── TableMetadataFilter.php
│   │   ├── XmlDataSet.php
│   │   └── YamlDataSet.php
│   ├── Database/
│   │   ├── Connection.php
│   │   ├── DataSet.php
│   │   ├── DefaultConnection.php
│   │   ├── FilteredDataSet.php
│   │   ├── Metadata/
│   │   │   ├── AbstractMetadata.php
│   │   │   ├── Dblib.php
│   │   │   ├── Firebird.php
│   │   │   ├── InformationSchema.php
│   │   │   ├── Metadata.php
│   │   │   ├── MySQL.php
│   │   │   ├── Oci.php
│   │   │   ├── PgSQL.php
│   │   │   ├── SqlSrv.php
│   │   │   ├── Sqlite.php
│   │   │   └── Table.php
│   │   ├── ResultSetTable.php
│   │   ├── Table.php
│   │   └── TableIterator.php
│   ├── DatabaseListConsumer.php
│   ├── DefaultTester.php
│   ├── Exception/
│   │   ├── Exception.php
│   │   ├── InvalidArgumentException.php
│   │   └── RuntimeException.php
│   ├── Operation/
│   │   ├── Composite.php
│   │   ├── Delete.php
│   │   ├── DeleteAll.php
│   │   ├── Exception.php
│   │   ├── Factory.php
│   │   ├── Insert.php
│   │   ├── None.php
│   │   ├── Operation.php
│   │   ├── Replace.php
│   │   ├── RowBased.php
│   │   ├── Truncate.php
│   │   └── Update.php
│   ├── TestCase.php
│   ├── TestCaseTrait.php
│   └── Tester.php
└── tests/
    ├── Constraint/
    │   └── TableRowCountTest.php
    ├── DB/
    │   └── DefaultDatabaseConnectionTest.php
    ├── DataSet/
    │   ├── AbstractTableTest.php
    │   ├── CompositeDataSetTest.php
    │   ├── CsvDataSetTest.php
    │   ├── FilterTest.php
    │   ├── QueryDataSetTest.php
    │   ├── QueryTableTest.php
    │   ├── ReplacementDataSetTest.php
    │   ├── ReplacementTableTest.php
    │   └── XmlDataSetsTest.php
    ├── Operation/
    │   ├── OperationsMySQLTest.php
    │   ├── OperationsTest.php
    │   └── RowBasedTest.php
    └── _files/
        ├── CsvDataSets/
        │   ├── table1.csv
        │   └── table2.csv
        ├── DatabaseTestUtility.php
        ├── XmlDataSets/
        │   ├── AllEmptyTableInsertResult.xml
        │   ├── AllEmptyTableInsertTest.xml
        │   ├── DeleteAllOperationTest.xml
        │   ├── DeleteOperationResult.xml
        │   ├── DeleteOperationTest.xml
        │   ├── EmptyTableInsertResult.xml
        │   ├── EmptyTableInsertTest.xml
        │   ├── FilteredTestComparison.xml
        │   ├── FilteredTestFixture.xml
        │   ├── FlatXmlDataSet.xml
        │   ├── FlatXmlWriter.xml
        │   ├── FlatXmlWriterEntities.xml
        │   ├── InsertOperationResult.xml
        │   ├── InsertOperationTest.xml
        │   ├── MysqlXmlDataSet.xml
        │   ├── OperationsMySQLTestFixture.xml
        │   ├── OperationsTestFixture.xml
        │   ├── QueryDataSetTest.xml
        │   ├── ReplaceOperationResult.xml
        │   ├── ReplaceOperationTest.xml
        │   ├── RowBasedExecute.xml
        │   ├── TruncateCompositeTest.xml
        │   ├── UpdateOperationResult.xml
        │   ├── UpdateOperationTest.xml
        │   ├── XmlDataSet.xml
        │   ├── XmlWriter.xml
        │   └── XmlWriterEntities.xml
        └── YamlDataSets/
            └── testDataSet.yaml

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitattributes
================================================
*.php diff=php


================================================
FILE: .gitignore
================================================
/.idea
/.php_cs.cache
/composer.lock
/build
/vendor
/tools


================================================
FILE: .php_cs.dist
================================================
<?php
$header = <<<'EOF'
This file is part of DbUnit.

(c) Sebastian Bergmann <sebastian@phpunit.de>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

return PhpCsFixer\Config::create()
    ->setRiskyAllowed(true)
    ->setRules(
        [
            'array_syntax' => ['syntax' => 'short'],
            'binary_operator_spaces' => [
                'operators' => [
                    '=' => 'align',
                    '=>' => 'align',
                ],
            ],
            'blank_line_after_namespace' => true,
            'blank_line_before_statement' => [
                'statements' => [
                    'break',
                    'continue',
                    'declare',
                    'do',
                    'for',
                    'foreach',
                    'if',
                    'include',
                    'include_once',
                    'require',
                    'require_once',
                    'return',
                    'switch',
                    'throw',
                    'try',
                    'while',
                    'yield',
                ],
            ],
            'braces' => true,
            'cast_spaces' => true,
            'class_attributes_separation' => ['elements' => ['method']],
            'compact_nullable_typehint' => true,
            'concat_space' => ['spacing' => 'one'],
            'declare_equal_normalize' => ['space' => 'none'],
            'dir_constant' => true,
            'elseif' => true,
            'encoding' => true,
            'full_opening_tag' => true,
            'function_declaration' => true,
            'header_comment' => ['header' => $header, 'separate' => 'none'],
            'indentation_type' => true,
            'line_ending' => true,
            'list_syntax' => ['syntax' => 'short'],
            'lowercase_cast' => true,
            'lowercase_constants' => true,
            'lowercase_keywords' => true,
            'magic_constant_casing' => true,
            'method_argument_space' => ['ensure_fully_multiline' => true],
            'modernize_types_casting' => true,
            'native_function_casing' => true,
            'native_function_invocation' => true,
            'no_alias_functions' => true,
            'no_blank_lines_after_class_opening' => true,
            'no_blank_lines_after_phpdoc' => true,
            'no_closing_tag' => true,
            'no_empty_comment' => true,
            'no_empty_phpdoc' => true,
            'no_empty_statement' => true,
            'no_extra_blank_lines' => true,
            'no_homoglyph_names' => true,
            'no_leading_import_slash' => true,
            'no_leading_namespace_whitespace' => true,
            'no_mixed_echo_print' => ['use' => 'print'],
            'no_null_property_initialization' => true,
            'no_short_bool_cast' => true,
            'no_short_echo_tag' => true,
            'no_singleline_whitespace_before_semicolons' => true,
            'no_spaces_after_function_name' => true,
            'no_spaces_inside_parenthesis' => true,
            'no_superfluous_elseif' => true,
            'no_trailing_comma_in_list_call' => true,
            'no_trailing_comma_in_singleline_array' => true,
            'no_trailing_whitespace' => true,
            'no_trailing_whitespace_in_comment' => true,
            'no_unneeded_control_parentheses' => true,
            'no_unneeded_curly_braces' => true,
            'no_unneeded_final_method' => true,
            'no_unreachable_default_argument_value' => true,
            'no_unused_imports' => true,
            'no_useless_else' => true,
            'no_whitespace_before_comma_in_array' => true,
            'no_whitespace_in_blank_line' => true,
            'non_printable_character' => true,
            'normalize_index_brace' => true,
            'object_operator_without_whitespace' => true,
            'ordered_class_elements' => [
                'order' => [
                    'use_trait',
                    'constant_public',
                    'constant_protected',
                    'constant_private',
                    'property_public_static',
                    'property_protected_static',
                    'property_private_static',
                    'property_public',
                    'property_protected',
                    'property_private',
                    'method_public_static',
                    'construct',
                    'destruct',
                    'magic',
                    'phpunit',
                    'method_public',
                    'method_protected',
                    'method_private',
                    'method_protected_static',
                    'method_private_static',
                ],
            ],
            'ordered_imports' => true,
            'phpdoc_add_missing_param_annotation' => true,
            'phpdoc_align' => true,
            'phpdoc_annotation_without_dot' => true,
            'phpdoc_indent' => true,
            'phpdoc_no_access' => true,
            'phpdoc_no_empty_return' => true,
            'phpdoc_no_package' => true,
            'phpdoc_order' => true,
            'phpdoc_return_self_reference' => true,
            'phpdoc_scalar' => true,
            'phpdoc_separation' => true,
            'phpdoc_single_line_var_spacing' => true,
            'phpdoc_to_comment' => true,
            'phpdoc_trim' => true,
            'phpdoc_types' => true,
            'phpdoc_types_order' => true,
            'phpdoc_var_without_name' => true,
            'pow_to_exponentiation' => true,
            'protected_to_private' => true,
            'return_type_declaration' => ['space_before' => 'none'],
            'self_accessor' => true,
            'short_scalar_cast' => true,
            'simplified_null_return' => true,
            'single_blank_line_at_eof' => true,
            'single_import_per_statement' => true,
            'single_line_after_imports' => true,
            'single_quote' => true,
            'standardize_not_equals' => true,
            'ternary_to_null_coalescing' => true,
            'trim_array_spaces' => true,
            'unary_operator_spaces' => true,
            'visibility_required' => true,
            'void_return' => true,
            'whitespace_after_comma_in_array' => true,
        ]
    )
    ->setFinder(
        PhpCsFixer\Finder::create()
        ->files()
        ->in(__DIR__ . '/src')
        ->in(__DIR__ . '/tests')
        ->notName('*.phpt')
    );


================================================
FILE: .travis.yml
================================================
language: php

sudo: false

php:
  - 7.1
  - 7.2
  - master

services:
  - mysql

env:
  matrix:
    - DEPENDENCIES="high"
    - DEPENDENCIES="low"
  global:
    - DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"

before_install:
  - composer self-update
  - composer clear-cache
  - mysql -e 'CREATE DATABASE IF NOT EXISTS dbunit;'

install:
  - if [[ "$DEPENDENCIES" = 'high' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS; fi
  - if [[ "$DEPENDENCIES" = 'low' ]]; then travis_retry composer update $DEFAULT_COMPOSER_FLAGS --prefer-lowest; fi

script:
  - ./vendor/bin/phpunit --configuration phpunit-travis.xml

notifications:
  email: false



================================================
FILE: ChangeLog.md
================================================
# Changes in DbUnit

All notable changes to DbUnit are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [4.0.0] - 2018-02-07

### Removed

* This extension now requires PHPUnit 7
* This extension is no longer supported on PHP 7.0

## [3.0.3] - 2018-01-23

### Fixed

* Fixed [#191](https://github.com/sebastianbergmann/dbunit/pull/191): MySQL's `FOREIGN_KEY_CHECKS` setting gets lost
* Fixed [#192](https://github.com/sebastianbergmann/dbunit/pull/192): Error message for wrong fixture is not good enough
* Fixed [#201](https://github.com/sebastianbergmann/dbunit/pull/201): `TestCaseTrait::tearDown()` does not call parent's `tearDown()`
* Fixed [#204](https://github.com/sebastianbergmann/dbunit/pull/204): `DefaultConnection::close()` does not close database connection
* Fixed [#205](https://github.com/sebastianbergmann/dbunit/pull/205): Metadata for empty SQLite table is not handled correctly

## [3.0.2] - 2017-11-18

### Changed

* This extension is now compatible with Symfony Console 4

## [3.0.1] - 2017-10-19

### Fixed

* Fixed [#193](https://github.com/sebastianbergmann/dbunit/pull/193): Multibyte values are not displayed correctly
* Fixed [#195](https://github.com/sebastianbergmann/dbunit/issues/195): Empty tables are not displayed correctly

## [3.0.0] - 2017-02-03

### Changed

* DbUnit's units of code are now namespaced
* DbUnit is now compatible with, and requires, PHPUnit 6.0

### Removed

* The `dbunit` CLI tool was removed

[4.0.0]: https://github.com/sebastianbergmann/dbunit/compare/3.0.3...4.0.0
[3.0.3]: https://github.com/sebastianbergmann/dbunit/compare/3.0.2...3.0.3
[3.0.2]: https://github.com/sebastianbergmann/dbunit/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/sebastianbergmann/dbunit/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/sebastianbergmann/dbunit/compare/2.0...3.0.0


================================================
FILE: LICENSE
================================================
DbUnit

Copyright (c) 2002-2018, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

 * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

 * Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

 * Neither the name of Sebastian Bergmann nor the names of his
   contributors may be used to endorse or promote products derived
   from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.


================================================
FILE: README.md
================================================
[This extension is no longer maintained](https://github.com/sebastianbergmann/dbunit/issues/217)

# DbUnit

[PHPUnit](https://phpunit.de/) extension for database interaction testing.

## Installation

### Composer

If 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:

```
$ composer require --dev phpunit/dbunit
```

### PHP Archive (PHAR)

You can download a PHAR of DbUnit:

```
$ wget https://phar.phpunit.de/dbunit.phar
```

The example below shows how to configure PHPUnit to load all `*.phar` files found in a given directory (`tools/phpunit.d` in this example):

```xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
         extensionsDirectory="tools/phpunit.d">
</phpunit>
```


================================================
FILE: build.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project name="dbunit" default="setup">
    <target name="setup" depends="clean,install-dependencies"/>

    <target name="clean" unless="clean.done" description="Cleanup build artifacts">
        <delete dir="${basedir}/build"/>
        <delete dir="${basedir}/tools"/>
        <delete dir="${basedir}/vendor"/>
        <delete file="${basedir}/composer.lock"/>

        <property name="clean.done" value="true"/>
    </target>

    <target name="prepare" unless="prepare.done" depends="clean,install-dependencies,install-tools" description="Prepare for build">
        <mkdir dir="${basedir}/build"/>

        <property name="prepare.done" value="true"/>
    </target>

    <target name="install-dependencies" depends="clean" description="Install dependencies with Composer">
        <exec executable="composer" taskname="composer">
            <arg value="update"/>
            <arg value="--no-interaction"/>
            <arg value="--no-progress"/>
            <arg value="--no-ansi"/>
            <arg value="--no-suggest"/>
            <arg value="--optimize-autoloader"/>
            <arg value="--prefer-stable"/>
        </exec>
    </target>

    <target name="install-tools" unless="tools-installed" depends="-tools-installed" description="Install tools using phive">
        <exec executable="phive" taskname="phive">
            <arg value="install"/>
        </exec>
    </target>

    <target name="package" depends="prepare,-get-version-number-from-git" description="Package as PHAR">
        <copy todir="${basedir}/build/phar" file="${basedir}/LICENSE" />
        <copy todir="${basedir}/build/phar" file="${basedir}/manifest.xml" />
        <copy todir="${basedir}/build/phar/dbunit">
            <fileset dir="${basedir}/src">
                <include name="**/*" />
            </fileset>
        </copy>

        <copy file="${basedir}/vendor/symfony/yaml/LICENSE" tofile="${basedir}/build/phar/symfony/LICENSE"/>
        <copy todir="${basedir}/build/phar/symfony">
            <fileset dir="${basedir}/vendor/symfony">
                <include name="**/*.php" />
                <exclude name="**/Tests/**" />
            </fileset>
        </copy>

        <exec executable="${basedir}/tools/phpab" taskname="phpab">
            <arg value="--all" />
            <arg value="--phar" />
            <arg value="--output" />
            <arg path="${basedir}/build/dbunit-${version}.phar" />
            <arg path="${basedir}/build/phar" />
        </exec>

        <delete dir="${basedir}/build/phar"/>

        <exec executable="gpg" failonerror="true">
            <arg value="--local-user"/>
            <arg value="sb@sebastian-bergmann.de"/>
            <arg value="--armor"/>
            <arg value="--detach-sign"/>
            <arg path="${basedir}/build/dbunit-${version}.phar"/>
        </exec>
    </target>

    <target name="-get-version-number-from-git">
        <exec executable="bash" outputproperty="version" failonerror="true" dir="${basedir}">
            <arg value="-c" />
            <arg value="/usr/bin/git describe --abbrev=0" />
        </exec>
    </target>

    <target name="-tools-installed">
        <available file="${basedir}/tools" property="tools-installed" type="dir"/>
    </target>
</project>


================================================
FILE: composer.json
================================================
{
    "name": "phpunit/dbunit",
    "description": "PHPUnit extension for database interaction testing",
    "type": "library",
    "keywords": [
        "database",
        "testing",
        "xunit"
    ],
    "homepage": "https://github.com/sebastianbergmann/dbunit/",
    "license": "BSD-3-Clause",
    "authors": [
        {
            "name": "Sebastian Bergmann",
            "email": "sebastian@phpunit.de",
            "role": "lead"
        }
    ],
    "support": {
        "issues": "https://github.com/sebastianbergmann/dbunit/issues"
    },
    "require": {
        "php": "^7.1",
        "phpunit/phpunit": "^7.0",
        "symfony/yaml": "^3.0 || ^4.0",
        "ext-pdo": "*",
        "ext-simplexml": "*"
    },
    "autoload": {
        "classmap": [
            "src/"
        ]
    },
    "extra": {
        "branch-alias": {
            "dev-master": "4.0-dev"
        }
    }
}


================================================
FILE: manifest.xml
================================================
<?xml version="1.0" encoding="utf-8" ?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
    <contains name="phpunit/dbunit" version="4.0.0" type="extension">
        <extension for="phpunit/phpunit" compatible="^7.0"/>
    </contains>

    <copyright>
        <author name="Sebastian Bergmann" email="sebastian@phpunit.de"/>
        <license type="BSD-3-Clause" url="https://github.com/sebastianbergmann/dbunit/blob/master/LICENSE"/>
    </copyright>

    <requires>
        <php version="^7.1"/>
    </requires>
</phar>


================================================
FILE: phive.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
  <phar name="phpab" version="^1.24.1" installed="1.24.1" location="./tools/phpab"/>
</phive>


================================================
FILE: phpunit-travis.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         beStrictAboutCoversAnnotation="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutTodoAnnotatedTests="true"
         verbose="true">
    <testsuite>
        <directory suffix="Test.php">tests/Constraint</directory>
        <directory suffix="Test.php">tests/DataSet</directory>
        <directory suffix="Test.php">tests/Operation</directory>
        <directory suffix="Test.php">tests/DB</directory>
    </testsuite>

    <php>
        <const name="PHPUNIT_TESTSUITE" value="true"/>
        <const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN" value="mysql:host=127.0.0.1;dbname=dbunit;port=3306"/>
        <const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_USERNAME" value="root"/>
        <const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_PASSWORD" value=""/>
    </php>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
</phpunit>


================================================
FILE: phpunit.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         beStrictAboutCoversAnnotation="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutTodoAnnotatedTests="true"
         verbose="true">
    <testsuite>
        <directory suffix="Test.php">tests/Constraint</directory>
        <directory suffix="Test.php">tests/DataSet</directory>
        <directory suffix="Test.php">tests/Operation</directory>
        <directory suffix="Test.php">tests/DB</directory>
    </testsuite>

    <php>
        <const name="PHPUNIT_TESTSUITE" value="true"/>
        <!--<const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_DSN" value="mysql:host=127.0.0.1;dbname=phpunit_tests;port=3306"/>-->
        <!--<const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_USERNAME" value="root"/>-->
        <!--<const name="PHPUNIT_TESTSUITE_EXTENSION_DATABASE_MYSQL_PASSWORD" value=""/>-->
    </php>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
</phpunit>


================================================
FILE: src/AbstractTester.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\Operation\Factory;
use PHPUnit\DbUnit\Operation\Operation;

/**
 * Can be used as a foundation for new DatabaseTesters.
 */
abstract class AbstractTester implements Tester
{
    /**
     * @var Operation
     */
    protected $setUpOperation;

    /**
     * @var Operation
     */
    protected $tearDownOperation;

    /**
     * @var IDataSet
     */
    protected $dataSet;

    /**
     * @var string
     */
    protected $schema;

    /**
     * Creates a new database tester.
     */
    public function __construct()
    {
        $this->setUpOperation    = Factory::CLEAN_INSERT();
        $this->tearDownOperation = Factory::NONE();
    }

    /**
     * Closes the specified connection.
     *
     * @param Connection $connection
     */
    public function closeConnection(Connection $connection): void
    {
        $connection->close();
    }

    /**
     * Returns the test dataset.
     *
     * @return IDataSet
     */
    public function getDataSet()
    {
        return $this->dataSet;
    }

    /**
     * TestCases must call this method inside setUp().
     */
    public function onSetUp(): void
    {
        $this->getSetUpOperation()->execute($this->getConnection(), $this->getDataSet());
    }

    /**
     * TestCases must call this method inside tearDown().
     */
    public function onTearDown(): void
    {
        $this->getTearDownOperation()->execute($this->getConnection(), $this->getDataSet());
    }

    /**
     * Sets the test dataset to use.
     *
     * @param IDataSet $dataSet
     */
    public function setDataSet(IDataSet $dataSet): void
    {
        $this->dataSet = $dataSet;
    }

    /**
     * Sets the schema value.
     *
     * @param string $schema
     */
    public function setSchema($schema): void
    {
        $this->schema = $schema;
    }

    /**
     * Sets the DatabaseOperation to call when starting the test.
     *
     * @param Operation $setUpOperation
     */
    public function setSetUpOperation(Operation $setUpOperation): void
    {
        $this->setUpOperation = $setUpOperation;
    }

    /**
     * Sets the DatabaseOperation to call when ending the test.
     *
     * @param Operation $tearDownOperation
     */
    public function setTearDownOperation(Operation $tearDownOperation): void
    {
        $this->tearDownOperation = $tearDownOperation;
    }

    /**
     * Returns the schema value
     *
     * @return string
     */
    protected function getSchema()
    {
        return $this->schema;
    }

    /**
     * Returns the database operation that will be called when starting the test.
     *
     * @return Operation
     */
    protected function getSetUpOperation()
    {
        return $this->setUpOperation;
    }

    /**
     * Returns the database operation that will be called when ending the test.
     *
     * @return Operation
     */
    protected function getTearDownOperation()
    {
        return $this->tearDownOperation;
    }
}


================================================
FILE: src/Constraint/DataSetIsEqual.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Constraint;

use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\InvalidArgumentException;
use PHPUnit\Framework\Constraint\Constraint;

/**
 * Asserts whether or not two dbunit datasets are equal.
 */
class DataSetIsEqual extends Constraint
{
    /**
     * @var IDataSet
     */
    protected $value;

    /**
     * @var string
     */
    protected $failure_reason;

    /**
     * Creates a new constraint.
     *
     * @param IDataSet $value
     */
    public function __construct(IDataSet $value)
    {
        parent::__construct();
        $this->value = $value;
    }

    /**
     * Returns a string representation of the constraint.
     *
     * @return string
     */
    public function toString(): string
    {
        return \sprintf(
            'is equal to expected %s',
            $this->value->__toString()
        );
    }

    /**
     * Evaluates the constraint for parameter $other. Returns TRUE if the
     * constraint is met, FALSE otherwise.
     *
     * This method can be overridden to implement the evaluation algorithm.
     *
     * @param mixed $other value or object to evaluate
     *
     * @return bool
     */
    protected function matches($other): bool
    {
        if (!$other instanceof IDataSet) {
            throw new InvalidArgumentException(
                'PHPUnit_Extensions_Database_DataSet_IDataSet expected'
            );
        }

        return $this->value->matches($other);
    }

    /**
     * Returns the description of the failure
     *
     * The beginning of failure messages is "Failed asserting that" in most
     * cases. This method should return the second part of that sentence.
     *
     * @param mixed $other evaluated value or object
     *
     * @return string
     */
    protected function failureDescription($other): string
    {
        return $other->__toString() . ' ' . $this->toString();
    }
}


================================================
FILE: src/Constraint/TableIsEqual.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Constraint;

use PHPUnit\DbUnit\DataSet\ITable;
use PHPUnit\DbUnit\InvalidArgumentException;
use PHPUnit\Framework\Constraint\Constraint;

/**
 * Asserts whether or not two dbunit tables are equal.
 */
class TableIsEqual extends Constraint
{
    /**
     * @var ITable
     */
    protected $value;

    /**
     * @var string
     */
    protected $failure_reason;

    /**
     * Creates a new constraint.
     *
     * @param ITable $value
     */
    public function __construct(ITable $value)
    {
        parent::__construct();
        $this->value = $value;
    }

    /**
     * Returns a string representation of the constraint.
     *
     * @return string
     */
    public function toString(): string
    {
        return \sprintf(
            'is equal to expected %s',
            $this->value->__toString()
        );
    }

    /**
     * Evaluates the constraint for parameter $other. Returns TRUE if the
     * constraint is met, FALSE otherwise.
     *
     * This method can be overridden to implement the evaluation algorithm.
     *
     * @param mixed $other value or object to evaluate
     *
     * @return bool
     */
    protected function matches($other): bool
    {
        if (!$other instanceof ITable) {
            throw new InvalidArgumentException(
                'PHPUnit_Extensions_Database_DataSet_ITable expected'
            );
        }

        return $this->value->matches($other);
    }

    /**
     * Returns the description of the failure
     *
     * The beginning of failure messages is "Failed asserting that" in most
     * cases. This method should return the second part of that sentence.
     *
     * @param mixed $other evaluated value or object
     *
     * @return string
     */
    protected function failureDescription($other): string
    {
        return $other->__toString() . ' ' . $this->toString();
    }
}


================================================
FILE: src/Constraint/TableRowCount.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Constraint;

use PHPUnit\Framework\Constraint\Constraint;

/**
 * Asserts the row count in a table
 */
class TableRowCount extends Constraint
{
    /**
     * @var int
     */
    protected $value;

    /**
     * @var string
     */
    protected $tableName;

    /**
     * Creates a new constraint.
     *
     * @param $tableName
     * @param $value
     */
    public function __construct($tableName, $value)
    {
        parent::__construct();
        $this->tableName = $tableName;
        $this->value     = $value;
    }

    /**
     * Returns a string representation of the constraint.
     *
     * @return string
     */
    public function toString(): string
    {
        return \sprintf('is equal to expected row count %d', $this->value);
    }

    /**
     * Evaluates the constraint for parameter $other. Returns TRUE if the
     * constraint is met, FALSE otherwise.
     *
     * This method can be overridden to implement the evaluation algorithm.
     *
     * @param mixed $other value or object to evaluate
     *
     * @return bool
     */
    protected function matches($other): bool
    {
        return $other == $this->value;
    }
}


================================================
FILE: src/DataSet/AbstractDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * Implements the basic functionality of data sets.
 */
abstract class AbstractDataSet implements IDataSet
{
    public function __toString()
    {
        $iterator = $this->getIterator();

        $dataSetString = '';

        foreach ($iterator as $table) {
            $dataSetString .= $table->__toString();
        }

        return $dataSetString;
    }

    /**
     * Returns an array of table names contained in the dataset.
     *
     * @return array
     */
    public function getTableNames()
    {
        $tableNames = [];

        foreach ($this->getIterator() as $table) {
            /* @var $table ITable */
            $tableNames[] = $table->getTableMetaData()->getTableName();
        }

        return $tableNames;
    }

    /**
     * Returns a table meta data object for the given table.
     *
     * @param string $tableName
     *
     * @return ITableMetadata
     */
    public function getTableMetaData($tableName)
    {
        return $this->getTable($tableName)->getTableMetaData();
    }

    /**
     * Returns a table object for the given table.
     *
     * @param string $tableName
     *
     * @return ITable
     */
    public function getTable($tableName)
    {
        foreach ($this->getIterator() as $table) {
            /* @var $table ITable */
            if ($table->getTableMetaData()->getTableName() == $tableName) {
                return $table;
            }
        }
    }

    /**
     * Returns an iterator for all table objects in the given dataset.
     *
     * @return ITableIterator
     */
    public function getIterator()
    {
        return $this->createIterator();
    }

    /**
     * Returns a reverse iterator for all table objects in the given dataset.
     *
     * @return ITableIterator
     */
    public function getReverseIterator()
    {
        return $this->createIterator(true);
    }

    /**
     * Asserts that the given data set matches this data set.
     *
     * @param IDataSet $other
     */
    public function matches(IDataSet $other)
    {
        $thisTableNames  = $this->getTableNames();
        $otherTableNames = $other->getTableNames();

        \sort($thisTableNames);
        \sort($otherTableNames);

        if ($thisTableNames != $otherTableNames) {
            return false;
        }

        foreach ($thisTableNames as $tableName) {
            $table = $this->getTable($tableName);

            if (!$table->matches($other->getTable($tableName))) {
                return false;
            }
        }

        return true;
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    abstract protected function createIterator($reverse = false);
}


================================================
FILE: src/DataSet/AbstractTable.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;
use SimpleXMLElement;

/**
 * Provides a basic functionality for dbunit tables
 */
class AbstractTable implements ITable
{
    /**
     * @var ITableMetadata
     */
    protected $tableMetaData;

    /**
     * A 2-dimensional array containing the data for this table.
     *
     * @var array
     */
    protected $data;

    /**
     * @var null|ITable
     */
    private $other;

    public function __toString()
    {
        $columns = $this->getTableMetaData()->getColumns();
        $count   = \count($columns);

        // if count less than 0 (when table is empty), then set count to 1
        $count         = $count >= 1 ? $count : 1;
        $lineSeparator = \str_repeat('+----------------------', $count) . "+\n";
        $lineLength    = \strlen($lineSeparator) - 1;

        $tableString = $lineSeparator;
        $tblName     = $this->getTableMetaData()->getTableName();
        $tableString .= '| ' . \str_pad(
            $tblName,
            $lineLength - 4,
            ' ',
                STR_PAD_RIGHT
        ) . " |\n";
        $tableString .= $lineSeparator;
        $rows = $this->rowToString($columns);
        $tableString .= !empty($rows) ? $rows . $lineSeparator : '';

        $rowCount = $this->getRowCount();

        for ($i = 0; $i < $rowCount; $i++) {
            $values = [];

            foreach ($columns as $columnName) {
                if ($this->other) {
                    try {
                        if ($this->getValue($i, $columnName) != $this->other->getValue($i, $columnName)) {
                            $values[] = \sprintf(
                                '%s != actual %s',
                                \var_export($this->getValue($i, $columnName), true),
                                \var_export($this->other->getValue($i, $columnName), true)
                            );
                        } else {
                            $values[] = $this->getValue($i, $columnName);
                        }
                    } catch (\InvalidArgumentException $ex) {
                        $values[] = $this->getValue($i, $columnName) . ': no row';
                    }
                } else {
                    $values[] = $this->getValue($i, $columnName);
                }
            }

            $tableString .= $this->rowToString($values) . $lineSeparator;
        }

        return ($this->other ? '(table diff enabled)' : '') . "\n" . $tableString . "\n";
    }

    /**
     * Returns the table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData()
    {
        return $this->tableMetaData;
    }

    /**
     * Returns the number of rows in this table.
     *
     * @return int
     */
    public function getRowCount()
    {
        return \count($this->data);
    }

    /**
     * Returns the value for the given column on the given row.
     *
     * @param int $row
     * @param int $column
     *
     * @todo reorganize this function to throw the exception first.
     */
    public function getValue($row, $column)
    {
        if (isset($this->data[$row][$column])) {
            $value = $this->data[$row][$column];

            return ($value instanceof SimpleXMLElement) ? (string) $value : $value;
        }

        if (!\in_array($column, $this->getTableMetaData()->getColumns()) || $this->getRowCount() <= $row) {
            throw new InvalidArgumentException("The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}");
        }

        return;
    }

    /**
     * Returns the an associative array keyed by columns for the given row.
     *
     * @param int $row
     *
     * @return array
     */
    public function getRow($row)
    {
        if (isset($this->data[$row])) {
            return $this->data[$row];
        }

        if ($this->getRowCount() <= $row) {
            throw new InvalidArgumentException("The given row ({$row}) does not exist in table {$this->getTableMetaData()->getTableName()}");
        }

        return;
    }

    /**
     * Asserts that the given table matches this table.
     *
     * @param ITable $other
     */
    public function matches(ITable $other)
    {
        $thisMetaData  = $this->getTableMetaData();
        $otherMetaData = $other->getTableMetaData();

        if (!$thisMetaData->matches($otherMetaData) ||
            $this->getRowCount() != $other->getRowCount()
        ) {
            return false;
        }

        $columns  = $thisMetaData->getColumns();
        $rowCount = $this->getRowCount();

        for ($i = 0; $i < $rowCount; $i++) {
            foreach ($columns as $columnName) {
                $thisValue  = $this->getValue($i, $columnName);
                $otherValue = $other->getValue($i, $columnName);

                if (\is_numeric($thisValue) && \is_numeric($otherValue)) {
                    if ($thisValue != $otherValue) {
                        $this->other = $other;

                        return false;
                    }
                } elseif ($thisValue !== $otherValue) {
                    $this->other = $other;

                    return false;
                }
            }
        }

        return true;
    }

    /**
     * Checks if a given row is in the table
     *
     * @param array $row
     *
     * @return bool
     */
    public function assertContainsRow(array $row)
    {
        return \in_array($row, $this->data);
    }

    /**
     * Sets the metadata for this table.
     *
     * @param ITableMetadata $tableMetaData
     *
     * @deprecated
     */
    protected function setTableMetaData(ITableMetadata $tableMetaData): void
    {
        $this->tableMetaData = $tableMetaData;
    }

    protected function rowToString(array $row)
    {
        $rowString = '';

        foreach ($row as $value) {
            if (null === $value) {
                $value = 'NULL';
            }

            $value_str = \mb_substr($value, 0, 20);

            // make str_pad act in multibyte manner
            $correction = \strlen($value_str) - \mb_strlen($value_str);
            $rowString .= '| ' . \str_pad($value_str, 20 + $correction, ' ', STR_PAD_BOTH) . ' ';
        }

        /** @see https://github.com/sebastianbergmann/dbunit/issues/195 */
        $rowString = !empty($row) ? $rowString . "|\n" : '';

        return $rowString;
    }
}


================================================
FILE: src/DataSet/AbstractTableMetadata.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * Provides basic functionality for table meta data.
 */
abstract class AbstractTableMetadata implements ITableMetadata
{
    /**
     * The names of all columns in the table.
     *
     * @var array
     */
    protected $columns;

    /**
     * The names of all the primary keys in the table.
     *
     * @var array
     */
    protected $primaryKeys;

    /**
     * @var string
     */
    protected $tableName;

    /**
     * Returns the names of the columns in the table.
     *
     * @return array
     */
    public function getColumns()
    {
        return $this->columns;
    }

    /**
     * Returns the names of the primary key columns in the table.
     *
     * @return array
     */
    public function getPrimaryKeys()
    {
        return $this->primaryKeys;
    }

    /**
     * Returns the name of the table.
     *
     * @return string
     */
    public function getTableName()
    {
        return $this->tableName;
    }

    /**
     * Asserts that the given tableMetaData matches this tableMetaData.
     *
     * @param ITableMetadata $other
     */
    public function matches(ITableMetadata $other)
    {
        if ($this->getTableName() != $other->getTableName() ||
            $this->getColumns() != $other->getColumns()
        ) {
            return false;
        }

        return true;
    }
}


================================================
FILE: src/DataSet/AbstractXmlDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;
use RuntimeException;
use SimpleXmlElement;

/**
 * The default implementation of a data set.
 */
abstract class AbstractXmlDataSet extends AbstractDataSet
{
    /**
     * @var array
     */
    protected $tables;

    /**
     * @var SimpleXmlElement
     */
    protected $xmlFileContents;

    /**
     * Creates a new dataset using the given tables.
     *
     * @param array $tables
     * @param mixed $xmlFile
     */
    public function __construct($xmlFile)
    {
        if (!\is_file($xmlFile)) {
            throw new InvalidArgumentException(
                "Could not find xml file: {$xmlFile}"
            );
        }

        $libxmlEntityLoader    = \libxml_disable_entity_loader(false);
        $libxmlErrorReporting  = \libxml_use_internal_errors(true);
        $this->xmlFileContents = \simplexml_load_file($xmlFile, 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);

        if (!$this->xmlFileContents) {
            $message = '';

            foreach (\libxml_get_errors() as $error) {
                $message .= \print_r($error, true);
            }

            throw new RuntimeException($message);
        }

        \libxml_clear_errors();
        \libxml_use_internal_errors($libxmlErrorReporting);
        \libxml_disable_entity_loader($libxmlEntityLoader);

        $tableColumns = [];
        $tableValues  = [];

        $this->getTableInfo($tableColumns, $tableValues);
        $this->createTables($tableColumns, $tableValues);
    }

    /**
     * Reads the simple xml object and creates the appropriate tables and meta
     * data for this dataset.
     */
    abstract protected function getTableInfo(array &$tableColumns, array &$tableValues);

    protected function createTables(array &$tableColumns, array &$tableValues): void
    {
        foreach ($tableValues as $tableName => $values) {
            $table = $this->getOrCreateTable($tableName, $tableColumns[$tableName]);

            foreach ($values as $value) {
                $table->addRow($value);
            }
        }
    }

    /**
     * Returns the table with the matching name. If the table does not exist
     * an empty one is created.
     *
     * @param string $tableName
     * @param mixed  $tableColumns
     *
     * @return ITable
     */
    protected function getOrCreateTable($tableName, $tableColumns)
    {
        if (empty($this->tables[$tableName])) {
            $tableMetaData            = new DefaultTableMetadata($tableName, $tableColumns);
            $this->tables[$tableName] = new DefaultTable($tableMetaData);
        }

        return $this->tables[$tableName];
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    protected function createIterator($reverse = false)
    {
        return new DefaultTableIterator($this->tables, $reverse);
    }
}


================================================
FILE: src/DataSet/ArrayDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * Implements the basic functionality of data sets using a PHP array.
 */
class ArrayDataSet extends AbstractDataSet
{
    /**
     * @var array
     */
    protected $tables = [];

    /**
     * Constructor to build a new ArrayDataSet with the given array.
     * The array parameter is an associative array of tables where the key is
     * the table name and the value an array of rows. Each row is an associative
     * array by itself with keys representing the field names and the values the
     * actual data.
     * For example:
     * array(
     *     "addressbook" => array(
     *         array("id" => 1, "name" => "...", "address" => "..."),
     *         array("id" => 2, "name" => "...", "address" => "...")
     *     )
     * )
     *
     * @param array $data
     */
    public function __construct(array $data)
    {
        foreach ($data as $tableName => $rows) {
            $columns = [];

            if (isset($rows[0])) {
                $columns = \array_keys($rows[0]);
            }

            $metaData = new DefaultTableMetadata($tableName, $columns);
            $table    = new DefaultTable($metaData);

            foreach ($rows as $row) {
                $table->addRow($row);
            }
            $this->tables[$tableName] = $table;
        }
    }

    public function getTable($tableName)
    {
        if (!isset($this->tables[$tableName])) {
            throw new InvalidArgumentException("$tableName is not a table in the current database.");
        }

        return $this->tables[$tableName];
    }

    protected function createIterator($reverse = false)
    {
        return new DefaultTableIterator($this->tables, $reverse);
    }
}


================================================
FILE: src/DataSet/CompositeDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * Creates Composite Datasets
 *
 * Allows for creating datasets from multiple sources (csv, query, xml, etc.)
 */
class CompositeDataSet extends AbstractDataSet
{
    protected $motherDataSet;

    /**
     * Creates a new Composite dataset
     *
     * You can pass in any data set that implements PHPUnit_Extensions_Database_DataSet_IDataSet
     *
     * @param string $delimiter
     * @param string $enclosure
     * @param string $escape
     */
    public function __construct(array $dataSets = [])
    {
        $this->motherDataSet = new DefaultDataSet();

        foreach ($dataSets as $dataSet) {
            $this->addDataSet($dataSet);
        }
    }

    /**
     * Adds a new data set to the composite.
     *
     * The dataset may not define tables that already exist in the composite.
     *
     * @param IDataSet $dataSet
     */
    public function addDataSet(IDataSet $dataSet): void
    {
        foreach ($dataSet->getTableNames() as $tableName) {
            if (!\in_array($tableName, $this->getTableNames())) {
                $this->motherDataSet->addTable($dataSet->getTable($tableName));
            } else {
                $other = $dataSet->getTable($tableName);
                $table = $this->getTable($tableName);

                if (!$table->getTableMetaData()->matches($other->getTableMetaData())) {
                    throw new InvalidArgumentException("There is already a table named $tableName with different table definition");
                }

                $table->addTableRows($dataSet->getTable($tableName));
            }
        }
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    protected function createIterator($reverse = false)
    {
        if ($reverse) {
            return $this->motherDataSet->getReverseIterator();
        }

        return $this->motherDataSet->getIterator();
    }
}


================================================
FILE: src/DataSet/CsvDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * Creates CsvDataSets.
 *
 * You can incrementally add CSV files as tables to your datasets
 */
class CsvDataSet extends AbstractDataSet
{
    /**
     * @var array
     */
    protected $tables = [];

    /**
     * @var string
     */
    protected $delimiter = ',';

    /**
     * @var string
     */
    protected $enclosure = '"';

    /**
     * @var string
     */
    protected $escape = '"';

    /**
     * Creates a new CSV dataset
     *
     * You can pass in the parameters for how csv files will be read.
     *
     * @param string $delimiter
     * @param string $enclosure
     * @param string $escape
     */
    public function __construct($delimiter = ',', $enclosure = '"', $escape = '"')
    {
        $this->delimiter = $delimiter;
        $this->enclosure = $enclosure;
        $this->escape    = $escape;
    }

    /**
     * Adds a table to the dataset
     *
     * The table will be given the passed name. $csvFile should be a path to
     * a valid csv file (based on the arguments passed to the constructor.)
     *
     * @param string $tableName
     * @param string $csvFile
     */
    public function addTable($tableName, $csvFile): void
    {
        if (!\is_file($csvFile)) {
            throw new InvalidArgumentException("Could not find csv file: {$csvFile}");
        }

        if (!\is_readable($csvFile)) {
            throw new InvalidArgumentException("Could not read csv file: {$csvFile}");
        }

        $fh           = \fopen($csvFile, 'r');
        $columns      = $this->getCsvRow($fh);
        $columnsCount = \count($columns);

        if ($columns === false) {
            throw new InvalidArgumentException("Could not determine the headers from the given file {$csvFile}");
        }

        $metaData = new DefaultTableMetadata($tableName, $columns);
        $table    = new DefaultTable($metaData);

        $rowNumber = 1;

        while (($row = $this->getCsvRow($fh)) !== false) {
            if ($columnsCount !== \count($row)) {
                throw new InvalidArgumentException("Row no. {$rowNumber} in csv file {$csvFile} should have an equal number of elements as table {$tableName}");
            }
            $table->addRow(\array_combine($columns, $row));
            $rowNumber++;
        }

        $this->tables[$tableName] = $table;
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    protected function createIterator($reverse = false)
    {
        return new DefaultTableIterator($this->tables, $reverse);
    }

    /**
     * Returns a row from the csv file in an indexed array.
     *
     * @param resource $fh
     *
     * @return array
     */
    protected function getCsvRow($fh)
    {
        if (\version_compare(PHP_VERSION, '5.3.0', '>')) {
            return \fgetcsv($fh, null, $this->delimiter, $this->enclosure, $this->escape);
        }

        return \fgetcsv($fh, null, $this->delimiter, $this->enclosure);
    }
}


================================================
FILE: src/DataSet/DefaultDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * The default implementation of a data set.
 */
class DefaultDataSet extends AbstractDataSet
{
    /**
     * An array of ITable objects.
     *
     * @var array
     */
    protected $tables;

    /**
     * Creates a new dataset using the given tables.
     *
     * @param array $tables
     */
    public function __construct(array $tables = [])
    {
        $this->tables = $tables;
    }

    /**
     * Adds a table to the dataset.
     *
     * @param ITable $table
     */
    public function addTable(ITable $table): void
    {
        $this->tables[] = $table;
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    protected function createIterator($reverse = false)
    {
        return new DefaultTableIterator($this->tables, $reverse);
    }
}


================================================
FILE: src/DataSet/DefaultTable.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * Provides default table functionality.
 */
class DefaultTable extends AbstractTable
{
    /**
     * Creates a new table object using the given $tableMetaData
     *
     * @param ITableMetadata $tableMetaData
     */
    public function __construct(ITableMetadata $tableMetaData)
    {
        $this->setTableMetaData($tableMetaData);
        $this->data = [];
    }

    /**
     * Adds a row to the table with optional values.
     *
     * @param array $values
     */
    public function addRow($values = []): void
    {
        $this->data[] = \array_replace(
            \array_fill_keys($this->getTableMetaData()->getColumns(), null),
            $values
        );
    }

    /**
     * Adds the rows in the passed table to the current table.
     *
     * @param ITable $table
     */
    public function addTableRows(ITable $table): void
    {
        $tableColumns = $this->getTableMetaData()->getColumns();
        $rowCount     = $table->getRowCount();

        for ($i = 0; $i < $rowCount; $i++) {
            $newRow = [];

            foreach ($tableColumns as $columnName) {
                $newRow[$columnName] = $table->getValue($i, $columnName);
            }
            $this->addRow($newRow);
        }
    }

    /**
     * Sets the specified column of the specied row to the specified value.
     *
     * @param int    $row
     * @param string $column
     * @param mixed  $value
     */
    public function setValue($row, $column, $value): void
    {
        if (isset($this->data[$row])) {
            $this->data[$row][$column] = $value;
        } else {
            throw new InvalidArgumentException('The row given does not exist.');
        }
    }
}


================================================
FILE: src/DataSet/DefaultTableIterator.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * The default table iterator
 */
class DefaultTableIterator implements ITableIterator
{
    /**
     * An array of tables in the iterator.
     *
     * @var array
     */
    protected $tables;

    /**
     * If this property is true then the tables will be iterated in reverse
     * order.
     *
     * @var bool
     */
    protected $reverse;

    /**
     * Creates a new default table iterator object.
     *
     * @param array $tables
     * @param bool  $reverse
     */
    public function __construct(array $tables, $reverse = false)
    {
        $this->tables  = $tables;
        $this->reverse = $reverse;

        $this->rewind();
    }

    /**
     * Returns the current table.
     *
     * @return ITable
     */
    public function getTable()
    {
        return $this->current();
    }

    /**
     * Returns the current table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData()
    {
        return $this->current()->getTableMetaData();
    }

    /**
     * Returns the current table.
     *
     * @return ITable
     */
    public function current()
    {
        return \current($this->tables);
    }

    /**
     * Returns the name of the current table.
     *
     * @return string
     */
    public function key()
    {
        return $this->current()->getTableMetaData()->getTableName();
    }

    /**
     * advances to the next element.
     */
    public function next(): void
    {
        if ($this->reverse) {
            \prev($this->tables);
        } else {
            \next($this->tables);
        }
    }

    /**
     * Rewinds to the first element
     */
    public function rewind(): void
    {
        if ($this->reverse) {
            \end($this->tables);
        } else {
            \reset($this->tables);
        }
    }

    /**
     * Returns true if the current index is valid
     *
     * @return bool
     */
    public function valid()
    {
        return $this->current() !== false;
    }
}


================================================
FILE: src/DataSet/DefaultTableMetadata.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * The default implementation of table meta data
 */
class DefaultTableMetadata extends AbstractTableMetadata
{
    /**
     * Creates a new default table meta data object.
     *
     * @param string $tableName
     * @param array  $columns
     * @param array  $primaryKeys
     */
    public function __construct($tableName, array $columns, array $primaryKeys = [])
    {
        $this->tableName   = $tableName;
        $this->columns     = $columns;
        $this->primaryKeys = [];

        foreach ($primaryKeys as $columnName) {
            if (!\in_array($columnName, $this->columns)) {
                throw new InvalidArgumentException('Primary key column passed that is not in the column list.');
            }
            $this->primaryKeys[] = $columnName;
        }
    }
}


================================================
FILE: src/DataSet/Filter.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * A dataset decorator that allows filtering out tables and table columns from
 * results.
 */
class Filter extends AbstractDataSet
{
    /**
     * The dataset being decorated.
     *
     * @var IDataSet
     */
    protected $originalDataSet;

    /**
     * The tables to exclude from the data set.
     *
     * @var array
     */
    protected $excludeTables = [];

    /**
     * The tables to exclude from the data set.
     *
     * @var array
     */
    protected $includeTables = [];

    /**
     * The columns to exclude from the data set.
     *
     * @var array
     */
    protected $excludeColumns = [];

    /**
     * The columns to exclude from the data set.
     *
     * @var array
     */
    protected $includeColumns = [];

    /**
     * Creates a new filtered data set.
     *
     * The $exclude tables should be an associative array using table names as
     * the key and an array of column names to exclude for the value. If you
     * would like to exclude a full table set the value of the table's entry
     * to the special string '*'.
     *
     * @param IDataSet $originalDataSet
     * @param array    $excludeTables   @deprecated use set* methods instead
     */
    public function __construct(IDataSet $originalDataSet, array $excludeTables = [])
    {
        $this->originalDataSet = $originalDataSet;

        $tables = [];

        foreach ($excludeTables as $tableName => $values) {
            if (\is_array($values)) {
                $this->setExcludeColumnsForTable($tableName, $values);
            } elseif ($values == '*') {
                $tables[] = $tableName;
            } else {
                $this->setExcludeColumnsForTable($tableName, (array) $values);
            }
        }

        $this->addExcludeTables($tables);
    }

    /**
     * Adds tables to be included in the data set.
     *
     * @param array $tables
     */
    public function addIncludeTables(array $tables): void
    {
        $this->includeTables = \array_unique(\array_merge($this->includeTables, $tables));
    }

    /**
     * Adds tables to be included in the data set.
     *
     * @param array $tables
     */
    public function addExcludeTables(array $tables): void
    {
        $this->excludeTables = \array_unique(\array_merge($this->excludeTables, $tables));
    }

    /**
     * Adds columns to include in the data set for the given table.
     *
     * @param string $table
     * @param array  $columns
     */
    public function setIncludeColumnsForTable($table, array $columns): void
    {
        $this->includeColumns[$table] = $columns;
    }

    /**
     * Adds columns to include in the data set for the given table.
     *
     * @param string $table
     * @param array  $columns
     */
    public function setExcludeColumnsForTable($table, array $columns): void
    {
        $this->excludeColumns[$table] = $columns;
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    protected function createIterator($reverse = false)
    {
        $original_tables = $this->originalDataSet->getIterator($reverse);
        $new_tables      = [];

        foreach ($original_tables as $table) {
            /* @var $table ITable */
            $tableName = $table->getTableMetaData()->getTableName();

            if ((!\in_array($tableName, $this->includeTables) && !empty($this->includeTables)) ||
                \in_array($tableName, $this->excludeTables)
            ) {
                continue;
            }

            if (!empty($this->excludeColumns[$tableName]) || !empty($this->includeColumns[$tableName])) {
                $new_table = new TableFilter($table);

                if (!empty($this->includeColumns[$tableName])) {
                    $new_table->addIncludeColumns($this->includeColumns[$tableName]);
                }

                if (!empty($this->excludeColumns[$tableName])) {
                    $new_table->addExcludeColumns($this->excludeColumns[$tableName]);
                }

                $new_tables[] = $new_table;
            } else {
                $new_tables[] = $table;
            }
        }

        return new DefaultTableIterator($new_tables);
    }
}


================================================
FILE: src/DataSet/FlatXmlDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\RuntimeException;

/**
 * The default implementation of a data set.
 */
class FlatXmlDataSet extends AbstractXmlDataSet
{
    protected function getTableInfo(array &$tableColumns, array &$tableValues): void
    {
        if ($this->xmlFileContents->getName() != 'dataset') {
            throw new RuntimeException('The root element of a flat xml data set file must be called <dataset>');
        }

        foreach ($this->xmlFileContents->children() as $row) {
            $tableName = $row->getName();

            if (!isset($tableColumns[$tableName])) {
                $tableColumns[$tableName] = [];
                $tableValues[$tableName]  = [];
            }

            $values = [];

            foreach ($row->attributes() as $name => $value) {
                if (!\in_array($name, $tableColumns[$tableName])) {
                    $tableColumns[$tableName][] = $name;
                }

                $values[$name] = $value;
            }

            if (\count($values)) {
                $tableValues[$tableName][] = $values;
            }
        }
    }
}


================================================
FILE: src/DataSet/IDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use IteratorAggregate;

/**
 * Provides a basic interface for creating and reading data from data sets.
 */
interface IDataSet extends IteratorAggregate
{
    /**
     * Returns an array of table names contained in the dataset.
     *
     * @return array
     */
    public function getTableNames();

    /**
     * Returns a table meta data object for the given table.
     *
     * @param string $tableName
     *
     * @return ITableMetadata
     */
    public function getTableMetaData($tableName);

    /**
     * Returns a table object for the given table.
     *
     * @param string $tableName
     *
     * @return ITable
     */
    public function getTable($tableName);

    /**
     * Returns a reverse iterator for all table objects in the given dataset.
     *
     * @return ITableIterator
     */
    public function getReverseIterator();

    /**
     * Asserts that the given data set matches this data set.
     *
     * @param IDataSet $other
     */
    public function matches(self $other);
}


================================================
FILE: src/DataSet/ITable.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * Provides a basic interface for creating and reading data from data sets.
 */
interface ITable
{
    /**
     * Returns the table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData();

    /**
     * Returns the number of rows in this table.
     *
     * @return int
     */
    public function getRowCount();

    /**
     * Returns the value for the given column on the given row.
     *
     * @param int $row
     * @param int $column
     */
    public function getValue($row, $column);

    /**
     * Returns the an associative array keyed by columns for the given row.
     *
     * @param int $row
     *
     * @return array
     */
    public function getRow($row);

    /**
     * Asserts that the given table matches this table.
     *
     * @param ITable $other
     */
    public function matches(self $other);
}


================================================
FILE: src/DataSet/ITableIterator.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use Iterator;

/**
 * Provides a basic interface for creating and reading data from data sets.
 */
interface ITableIterator extends Iterator
{
    /**
     * Returns the current table.
     *
     * @return ITable
     */
    public function getTable();

    /**
     * Returns the current table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData();
}


================================================
FILE: src/DataSet/ITableMetadata.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * Provides a basic interface for returning table meta data.
 */
interface ITableMetadata
{
    /**
     * Returns the names of the columns in the table.
     *
     * @return array
     */
    public function getColumns();

    /**
     * Returns the names of the primary key columns in the table.
     *
     * @return array
     */
    public function getPrimaryKeys();

    /**
     * Returns the name of the table.
     *
     * @return string
     */
    public function getTableName();

    /**
     * Asserts that the given tableMetaData matches this tableMetaData.
     *
     * @param ITableMetadata $other
     */
    public function matches(self $other);
}


================================================
FILE: src/DataSet/IYamlParser.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * An interface for parsing YAML files.
 */
interface IYamlParser
{
    /**
     * @param string $yamlFile
     *
     * @return array parsed YAML
     */
    public function parseYaml($yamlFile);
}


================================================
FILE: src/DataSet/MysqlXmlDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\RuntimeException;

/**
 * Data set implementation for the output of mysqldump --xml.
 */
class MysqlXmlDataSet extends AbstractXmlDataSet
{
    protected function getTableInfo(array &$tableColumns, array &$tableValues): void
    {
        if ($this->xmlFileContents->getName() != 'mysqldump') {
            throw new RuntimeException('The root element of a MySQL XML data set file must be called <mysqldump>');
        }

        foreach ($this->xmlFileContents->xpath('./database/table_data') as $tableElement) {
            if (empty($tableElement['name'])) {
                throw new RuntimeException('<table_data> elements must include a name attribute');
            }

            $tableName = (string) $tableElement['name'];

            if (!isset($tableColumns[$tableName])) {
                $tableColumns[$tableName] = [];
            }

            if (!isset($tableValues[$tableName])) {
                $tableValues[$tableName] = [];
            }

            foreach ($tableElement->xpath('./row') as $rowElement) {
                $rowValues = [];

                foreach ($rowElement->xpath('./field') as $columnElement) {
                    if (empty($columnElement['name'])) {
                        throw new RuntimeException('<field> element name attributes cannot be empty');
                    }

                    $columnName = (string) $columnElement['name'];

                    if (!\in_array($columnName, $tableColumns[$tableName])) {
                        $tableColumns[$tableName][] = $columnName;
                    }
                }

                foreach ($tableColumns[$tableName] as $columnName) {
                    $fields = $rowElement->xpath('./field[@name="' . $columnName . '"]');

                    if (!isset($fields[0])) {
                        throw new RuntimeException(
                            \sprintf(
                                '%s column doesn\'t exist in current row for table %s',
                                $columnName,
                                $tableName
                            )
                        );
                    }

                    $column = $fields[0];
                    $attr   = $column->attributes('http://www.w3.org/2001/XMLSchema-instance');

                    if (isset($attr['type']) && (string) $attr['type'] === 'xs:hexBinary') {
                        $columnValue = \pack('H*', (string) $column);
                    } else {
                        $null        = isset($column['nil']) || isset($attr[0]);
                        $columnValue = $null ? null : (string) $column;
                    }

                    $rowValues[$columnName] = $columnValue;
                }

                $tableValues[$tableName][] = $rowValues;
            }
        }

        foreach ($this->xmlFileContents->xpath('./database/table_structure') as $tableElement) {
            if (empty($tableElement['name'])) {
                throw new RuntimeException('<table_structure> elements must include a name attribute');
            }

            $tableName = (string) $tableElement['name'];

            foreach ($tableElement->xpath('./field') as $fieldElement) {
                if (empty($fieldElement['Field']) && empty($fieldElement['field'])) {
                    throw new RuntimeException('<field> elements must include a Field attribute');
                }

                $columnName = (string) (empty($fieldElement['Field']) ? $fieldElement['field'] : $fieldElement['Field']);

                if (!\in_array($columnName, $tableColumns[$tableName])) {
                    $tableColumns[$tableName][] = $columnName;
                }
            }
        }
    }
}


================================================
FILE: src/DataSet/QueryDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\Database\Table;
use PHPUnit\DbUnit\Database\TableIterator;
use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * Provides access to a database instance as a data set.
 */
class QueryDataSet extends AbstractDataSet
{
    /**
     * An array of ITable objects.
     *
     * @var array
     */
    protected $tables = [];

    /**
     * The database connection this dataset is using.
     *
     * @var Connection
     */
    protected $databaseConnection;

    /**
     * Creates a new dataset using the given database connection.
     *
     * @param Connection $databaseConnection
     */
    public function __construct(Connection $databaseConnection)
    {
        $this->databaseConnection = $databaseConnection;
    }

    public function addTable($tableName, $query = null): void
    {
        if ($query === null) {
            $query = 'SELECT * FROM ' . $tableName;
        }

        $this->tables[$tableName] = new QueryTable($tableName, $query, $this->databaseConnection);
    }

    /**
     * Returns a table object for the given table.
     *
     * @param string $tableName
     *
     * @return Table
     */
    public function getTable($tableName)
    {
        if (!isset($this->tables[$tableName])) {
            throw new InvalidArgumentException("$tableName is not a table in the current database.");
        }

        return $this->tables[$tableName];
    }

    /**
     * Returns a list of table names for the database
     *
     * @return array
     */
    public function getTableNames()
    {
        return \array_keys($this->tables);
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return TableIterator
     */
    protected function createIterator($reverse = false)
    {
        return new DefaultTableIterator($this->tables, $reverse);
    }
}


================================================
FILE: src/DataSet/QueryTable.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PDO;
use PHPUnit\DbUnit\Database\Connection;

/**
 * Provides the functionality to represent a database table.
 */
class QueryTable extends AbstractTable
{
    /**
     * @var string
     */
    protected $query;

    /**
     * @var Connection
     */
    protected $databaseConnection;

    /**
     * @var string
     */
    protected $tableName;

    /**
     * Creates a new database query table object.
     *
     * @param string     $table_name
     * @param string     $query
     * @param Connection $databaseConnection
     * @param mixed      $tableName
     */
    public function __construct($tableName, $query, Connection $databaseConnection)
    {
        $this->query              = $query;
        $this->databaseConnection = $databaseConnection;
        $this->tableName          = $tableName;
    }

    /**
     * Returns the table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData()
    {
        $this->createTableMetaData();

        return parent::getTableMetaData();
    }

    /**
     * Checks if a given row is in the table
     *
     * @param array $row
     *
     * @return bool
     */
    public function assertContainsRow(array $row)
    {
        $this->loadData();

        return parent::assertContainsRow($row);
    }

    /**
     * Returns the number of rows in this table.
     *
     * @return int
     */
    public function getRowCount()
    {
        $this->loadData();

        return parent::getRowCount();
    }

    /**
     * Returns the value for the given column on the given row.
     *
     * @param int $row
     * @param int $column
     */
    public function getValue($row, $column)
    {
        $this->loadData();

        return parent::getValue($row, $column);
    }

    /**
     * Returns the an associative array keyed by columns for the given row.
     *
     * @param int $row
     *
     * @return array
     */
    public function getRow($row)
    {
        $this->loadData();

        return parent::getRow($row);
    }

    /**
     * Asserts that the given table matches this table.
     *
     * @param ITable $other
     */
    public function matches(ITable $other)
    {
        $this->loadData();

        return parent::matches($other);
    }

    protected function loadData(): void
    {
        if ($this->data === null) {
            $pdoStatement = $this->databaseConnection->getConnection()->query($this->query);
            $this->data   = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
        }
    }

    protected function createTableMetaData(): void
    {
        if ($this->tableMetaData === null) {
            $this->loadData();

            // if some rows are in the table
            $columns = [];

            if (isset($this->data[0])) {
                // get column names from data
                $columns = \array_keys($this->data[0]);
            } else {
                $columns = $this->databaseConnection->getMetaData()->getTableColumns($this->tableName);
            }
            // create metadata
            $this->tableMetaData = new DefaultTableMetadata($this->tableName, $columns);
        }
    }
}


================================================
FILE: src/DataSet/ReplacementDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * Allows for replacing arbitrary values or portions of values with new data.
 *
 * A usage for this is replacing all values == '[NULL'] with a true NULL value
 */
class ReplacementDataSet extends AbstractDataSet
{
    /**
     * @var IDataSet
     */
    protected $dataSet;

    /**
     * @var array
     */
    protected $fullReplacements;

    /**
     * @var array
     */
    protected $subStrReplacements;

    /**
     * Creates a new replacement dataset
     *
     * You can pass in any data set that implements PHPUnit_Extensions_Database_DataSet_IDataSet
     *
     * @param string $delimiter
     * @param string $enclosure
     * @param string $escape
     */
    public function __construct(IDataSet $dataSet, array $fullReplacements = [], array $subStrReplacements = [])
    {
        $this->dataSet            = $dataSet;
        $this->fullReplacements   = $fullReplacements;
        $this->subStrReplacements = $subStrReplacements;
    }

    /**
     * Adds a new full replacement
     *
     * Full replacements will only replace values if the FULL value is a match
     *
     * @param string $value
     * @param string $replacement
     */
    public function addFullReplacement($value, $replacement): void
    {
        $this->fullReplacements[$value] = $replacement;
    }

    /**
     * Adds a new substr replacement
     *
     * Substr replacements will replace all occurances of the substr in every column
     *
     * @param string $value
     * @param string $replacement
     */
    public function addSubStrReplacement($value, $replacement): void
    {
        $this->subStrReplacements[$value] = $replacement;
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    protected function createIterator($reverse = false)
    {
        $innerIterator = $reverse ? $this->dataSet->getReverseIterator() : $this->dataSet->getIterator();

        return new ReplacementTableIterator($innerIterator, $this->fullReplacements, $this->subStrReplacements);
    }
}


================================================
FILE: src/DataSet/ReplacementTable.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * Allows for replacing arbitrary strings in your data sets with other values.
 *
 * @todo When setTableMetaData() is taken out of the AbstractTable this class should extend AbstractTable.
 */
class ReplacementTable implements ITable
{
    /**
     * @var ITable
     */
    protected $table;

    /**
     * @var array
     */
    protected $fullReplacements;

    /**
     * @var array
     */
    protected $subStrReplacements;

    /**
     * Creates a new replacement table
     *
     * @param ITable $table
     * @param array  $fullReplacements
     * @param array  $subStrReplacements
     */
    public function __construct(ITable $table, array $fullReplacements = [], array $subStrReplacements = [])
    {
        $this->table              = $table;
        $this->fullReplacements   = $fullReplacements;
        $this->subStrReplacements = $subStrReplacements;
    }

    public function __toString()
    {
        $columns = $this->getTableMetaData()->getColumns();

        $lineSeperator = \str_repeat('+----------------------', \count($columns)) . "+\n";
        $lineLength    = \strlen($lineSeperator) - 1;

        $tableString = $lineSeperator;
        $tableString .= '| ' . \str_pad($this->getTableMetaData()->getTableName(), $lineLength - 4, ' ', STR_PAD_RIGHT) . " |\n";
        $tableString .= $lineSeperator;
        $tableString .= $this->rowToString($columns);
        $tableString .= $lineSeperator;

        $rowCount = $this->getRowCount();

        for ($i = 0; $i < $rowCount; $i++) {
            $values = [];

            foreach ($columns as $columnName) {
                $values[] = $this->getValue($i, $columnName);
            }

            $tableString .= $this->rowToString($values);
            $tableString .= $lineSeperator;
        }

        return "\n" . $tableString . "\n";
    }

    /**
     * Adds a new full replacement
     *
     * Full replacements will only replace values if the FULL value is a match
     *
     * @param string $value
     * @param string $replacement
     */
    public function addFullReplacement($value, $replacement): void
    {
        $this->fullReplacements[$value] = $replacement;
    }

    /**
     * Adds a new substr replacement
     *
     * Substr replacements will replace all occurances of the substr in every column
     *
     * @param string $value
     * @param string $replacement
     */
    public function addSubStrReplacement($value, $replacement): void
    {
        $this->subStrReplacements[$value] = $replacement;
    }

    /**
     * Returns the table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData()
    {
        return $this->table->getTableMetaData();
    }

    /**
     * Returns the number of rows in this table.
     *
     * @return int
     */
    public function getRowCount()
    {
        return $this->table->getRowCount();
    }

    /**
     * Returns the value for the given column on the given row.
     *
     * @param int $row
     * @param int $column
     */
    public function getValue($row, $column)
    {
        return $this->getReplacedValue($this->table->getValue($row, $column));
    }

    /**
     * Returns the an associative array keyed by columns for the given row.
     *
     * @param int $row
     *
     * @return array
     */
    public function getRow($row)
    {
        $row = $this->table->getRow($row);

        return \array_map([$this, 'getReplacedValue'], $row);
    }

    /**
     * Asserts that the given table matches this table.
     *
     * @param ITable $other
     */
    public function matches(ITable $other)
    {
        $thisMetaData  = $this->getTableMetaData();
        $otherMetaData = $other->getTableMetaData();

        if (!$thisMetaData->matches($otherMetaData) ||
            $this->getRowCount() != $other->getRowCount()
        ) {
            return false;
        }

        $columns  = $thisMetaData->getColumns();
        $rowCount = $this->getRowCount();

        for ($i = 0; $i < $rowCount; $i++) {
            foreach ($columns as $columnName) {
                $thisValue  = $this->getValue($i, $columnName);
                $otherValue = $other->getValue($i, $columnName);

                if (\is_numeric($thisValue) && \is_numeric($otherValue)) {
                    if ($thisValue != $otherValue) {
                        return false;
                    }
                } elseif ($thisValue !== $otherValue) {
                    return false;
                }
            }
        }

        return true;
    }

    protected function rowToString(array $row)
    {
        $rowString = '';

        foreach ($row as $value) {
            if (\is_null($value)) {
                $value = 'NULL';
            }

            $rowString .= '| ' . \str_pad(\substr($value, 0, 20), 20, ' ', STR_PAD_BOTH) . ' ';
        }

        return $rowString . "|\n";
    }

    protected function getReplacedValue($value)
    {
        if (\is_scalar($value) && \array_key_exists((string) $value, $this->fullReplacements)) {
            return $this->fullReplacements[$value];
        }

        if (\count($this->subStrReplacements) && isset($value)) {
            return \str_replace(\array_keys($this->subStrReplacements), \array_values($this->subStrReplacements), $value);
        }

        return $value;
    }
}


================================================
FILE: src/DataSet/ReplacementTableIterator.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use OuterIterator;

/**
 * The default table iterator
 */
class ReplacementTableIterator implements OuterIterator, ITableIterator
{
    /**
     * @var ITableIterator
     */
    protected $innerIterator;

    /**
     * @var array
     */
    protected $fullReplacements;

    /**
     * @var array
     */
    protected $subStrReplacements;

    /**
     * Creates a new replacement table iterator object.
     *
     * @param ITableIterator $innerIterator
     * @param array          $fullReplacements
     * @param array          $subStrReplacements
     */
    public function __construct(ITableIterator $innerIterator, array $fullReplacements = [], array $subStrReplacements = [])
    {
        $this->innerIterator      = $innerIterator;
        $this->fullReplacements   = $fullReplacements;
        $this->subStrReplacements = $subStrReplacements;
    }

    /**
     * Adds a new full replacement
     *
     * Full replacements will only replace values if the FULL value is a match
     *
     * @param string $value
     * @param string $replacement
     */
    public function addFullReplacement($value, $replacement): void
    {
        $this->fullReplacements[$value] = $replacement;
    }

    /**
     * Adds a new substr replacement
     *
     * Substr replacements will replace all occurances of the substr in every column
     *
     * @param string $value
     * @param string $replacement
     */
    public function addSubStrReplacement($value, $replacement): void
    {
        $this->subStrReplacements[$value] = $replacement;
    }

    /**
     * Returns the current table.
     *
     * @return ITable
     */
    public function getTable()
    {
        return $this->current();
    }

    /**
     * Returns the current table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData()
    {
        $this->current()->getTableMetaData();
    }

    /**
     * Returns the current table.
     *
     * @return ITable
     */
    public function current()
    {
        return new ReplacementTable($this->innerIterator->current(), $this->fullReplacements, $this->subStrReplacements);
    }

    /**
     * Returns the name of the current table.
     *
     * @return string
     */
    public function key()
    {
        return $this->current()->getTableMetaData()->getTableName();
    }

    /**
     * advances to the next element.
     */
    public function next(): void
    {
        $this->innerIterator->next();
    }

    /**
     * Rewinds to the first element
     */
    public function rewind(): void
    {
        $this->innerIterator->rewind();
    }

    /**
     * Returns true if the current index is valid
     *
     * @return bool
     */
    public function valid()
    {
        return $this->innerIterator->valid();
    }

    public function getInnerIterator()
    {
        return $this->innerIterator;
    }
}


================================================
FILE: src/DataSet/Specification/Csv.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\DataSet\CsvDataSet;
use ReflectionClass;

/**
 * Creates CsvDataSets based off of a spec string.
 *
 * The format of the spec string is as follows:
 *
 * <csv options>|table1:filename.csv,table2:filename2.csv
 *
 * The first portion of the spec including the pipe symbol '|' is optional.
 * If the pipe option is included than it may be preceded by up to four
 * characters specifying values for the following arguments in order:
 * delimiter (defaults to ',',) enclosure (defaults to '"',) escape (defaults to '"',).
 *
 * Any additional characters in the csv options will be discarded.
 */
class Csv implements Specification
{
    /**
     * Creates CSV Data Set from a data set spec.
     *
     * @param string $dataSetSpec
     *
     * @return CsvDataSet
     */
    public function getDataSet($dataSetSpec)
    {
        $csvDataSetArgs = $this->getCsvOptions($dataSetSpec);
        $csvDataSetRfl  = new ReflectionClass(CsvDataSet::class);
        $csvDataSet     = $csvDataSetRfl->newInstanceArgs($csvDataSetArgs);

        foreach ($this->getTableFileMap($dataSetSpec) as $tableName => $file) {
            $csvDataSet->addTable($tableName, $file);
        }

        return $csvDataSet;
    }

    /**
     * Returns CSV options.
     *
     * Returns an array containing the options that will be passed to the
     * PHPUnit_Extensions_Database_DataSet_CsvDataSet constructor. The options
     * are determined by the given $dataSetSpec.
     *
     * @param string $dataSetSpec
     *
     * @return array
     */
    protected function getCsvOptions($dataSetSpec)
    {
        [$csvOptStr] = \explode('|', $dataSetSpec, 2);

        return \str_split($csvOptStr);
    }

    /**
     * Returns map of tables to files.
     *
     * Returns an associative array containing a mapping of tables (the key)
     * to files (the values.) The tables and files are determined by the given
     * $dataSetSpec
     *
     * @param string $dataSetSpec
     *
     * @return array
     */
    protected function getTableFileMap($dataSetSpec)
    {
        $tables = [];

        foreach (\explode(',', $dataSetSpec) as $csvfile) {
            [$tableName, $file]     = \explode(':', $csvfile, 2);
            $tables[$tableName]     = $file;
        }

        return $tables;
    }
}


================================================
FILE: src/DataSet/Specification/Factory.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\RuntimeException;

/**
 * Creates the appropriate DataSet Spec based on a given type.
 */
class Factory implements IFactory
{
    /**
     * Returns the data set
     *
     * @param string $type
     *
     * @return Specification
     */
    public function getDataSetSpecByType($type)
    {
        switch ($type) {
            case 'xml':
                return new Xml();

            case 'flatxml':
                return new FlatXml();

            case 'csv':
                return new Csv();

            case 'yaml':
                return new Yaml();

            case 'dbtable':
                return new Table();

            case 'dbquery':
                return new Query();

            default:
                throw new RuntimeException("I don't know what you want from me.");
        }
    }
}


================================================
FILE: src/DataSet/Specification/FlatXml.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\DataSet\FlatXmlDataSet;

/**
 * Creates a FlatXML dataset based off of a spec string.
 *
 * The format of the spec string is as follows:
 *
 * <filename>
 *
 * The filename should be the location of a flat xml file relative to the
 * current working directory.
 */
class FlatXml implements Specification
{
    /**
     * Creates Flat XML Data Set from a data set spec.
     *
     * @param string $dataSetSpec
     *
     * @return FlatXmlDataSet
     */
    public function getDataSet($dataSetSpec)
    {
        return new FlatXmlDataSet($dataSetSpec);
    }
}


================================================
FILE: src/DataSet/Specification/IFactory.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

/**
 * An interface for data set spec factories.
 */
interface IFactory
{
    /**
     * Returns the data set
     *
     * @param string $type
     *
     * @return Specification
     */
    public function getDataSetSpecByType($type);
}


================================================
FILE: src/DataSet/Specification/Query.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\Database\DefaultConnection;
use PHPUnit\DbUnit\DatabaseListConsumer;
use PHPUnit\DbUnit\DataSet\DefaultDataSet;
use ReflectionClass;

/**
 * Creates DefaultDataSets based off of a spec string.
 *
 * This spec class requires a list of databases to be set to the object before
 * it can return a list of databases.
 *
 * The format of the spec string is as follows:
 *
 * <db label>:<schema>:<table name>:<sql>
 *
 * The db label should be equal to one of the keys in the array of databases
 * passed to setDatabases().
 *
 * The schema should be the primary schema you will be running the sql query
 * against.
 *
 * The table name should be set to what you would like the table name in the
 * dataset to be.
 *
 * The sql is the query you want to use to generate the table columns and data.
 * The column names in the table will be identical to the column aliases in the
 * query.
 */
class Query implements Specification, DatabaseListConsumer
{
    /**
     * @var array
     */
    protected $databases = [];

    /**
     * Sets the database for the spec
     *
     * @param array $databases
     */
    public function setDatabases(array $databases): void
    {
        $this->databases = $databases;
    }

    /**
     * Creates a Default Data Set with a query table from a data set spec.
     *
     * @param string $dataSetSpec
     *
     * @return DefaultDataSet
     */
    public function getDataSet($dataSetSpec)
    {
        [$dbLabel, $schema, $table, $sql]     = \explode(':', $dataSetSpec, 4);
        $databaseInfo                         = $this->databases[$dbLabel];

        $pdoRflc      = new ReflectionClass('PDO');
        $pdo          = $pdoRflc->newInstanceArgs(\explode('|', $databaseInfo));
        $dbConnection = new DefaultConnection($pdo, $schema);
        $table        = $dbConnection->createQueryTable($table, $sql);

        return new DefaultDataSet([$table]);
    }
}


================================================
FILE: src/DataSet/Specification/Specification.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\DataSet\IDataSet;

/**
 * Provides an interface for creating data sets from data set spec strings.
 */
interface Specification
{
    /**
     * Creates a data set from a data set spec string.
     *
     * @param string $dataSetSpec
     *
     * @return IDataSet
     */
    public function getDataSet($dataSetSpec);
}


================================================
FILE: src/DataSet/Specification/Table.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\Database\DefaultConnection;
use PHPUnit\DbUnit\DatabaseListConsumer;
use PHPUnit\DbUnit\DataSet\IDataSet;
use ReflectionClass;

/**
 * Creates a database dataset based off of a spec string.
 *
 * This spec class requires a list of databases to be set to the object before
 * it can return a list of databases.
 *
 * The format of the spec string is as follows:
 *
 * <db label>:<schema>:<tables>
 *
 * The db label should be equal to one of the keys in the array of databases
 * passed to setDatabases().
 *
 * The schema should be the primary schema you will be choosing tables from.
 *
 * The tables should be a comma delimited list of all tables you would like to
 * pull data from.
 *
 * The sql is the query you want to use to generate the table columns and data.
 * The column names in the table will be identical to the column aliases in the
 * query.
 */
class Table implements Specification, DatabaseListConsumer
{
    /**
     * @var array
     */
    protected $databases = [];

    /**
     * Sets the database for the spec
     *
     * @param array $databases
     */
    public function setDatabases(array $databases): void
    {
        $this->databases = $databases;
    }

    /**
     * Creates a DB Data Set from a data set spec.
     *
     * @param string $dataSetSpec
     *
     * @return IDataSet
     */
    public function getDataSet($dataSetSpec)
    {
        [$dbLabel, $schema, $tables]     = \explode(':', $dataSetSpec, 3);
        $databaseInfo                    = $this->databases[$dbLabel];

        $pdoRflc      = new ReflectionClass('PDO');
        $pdo          = $pdoRflc->newInstanceArgs(\explode('|', $databaseInfo));
        $dbConnection = new DefaultConnection($pdo, $schema);

        return !empty($tables) ? $dbConnection->createDataSet(\explode(',', $tables)) : $dbConnection->createDataSet();
    }
}


================================================
FILE: src/DataSet/Specification/Xml.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\DataSet\XmlDataSet;

/**
 * Creates a XML dataset based off of a spec string.
 *
 * The format of the spec string is as follows:
 *
 * <filename>
 *
 * The filename should be the location of a xml file relative to the
 * current working directory.
 */
class Xml implements Specification
{
    /**
     * Creates XML Data Set from a data set spec.
     *
     * @param string $dataSetSpec
     *
     * @return XmlDataSet
     */
    public function getDataSet($dataSetSpec)
    {
        return new XmlDataSet($dataSetSpec);
    }
}


================================================
FILE: src/DataSet/Specification/Yaml.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet\Specification;

use PHPUnit\DbUnit\DataSet\YamlDataSet;

/**
 * Creates a YAML dataset based off of a spec string.
 *
 * The format of the spec string is as follows:
 *
 * <filename>
 *
 * The filename should be the location of a yaml file relative to the
 * current working directory.
 */
class Yaml implements Specification
{
    /**
     * Creates YAML Data Set from a data set spec.
     *
     * @param string $dataSetSpec
     *
     * @return YamlDataSet
     */
    public function getDataSet($dataSetSpec)
    {
        return new YamlDataSet($dataSetSpec);
    }
}


================================================
FILE: src/DataSet/SymfonyYamlParser.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use Symfony;

/**
 * The default YAML parser, using Symfony/Yaml.
 */
class SymfonyYamlParser implements IYamlParser
{
    public function parseYaml($yamlFile)
    {
        return Symfony\Component\Yaml\Yaml::parse(\file_get_contents($yamlFile));
    }
}


================================================
FILE: src/DataSet/TableFilter.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * A table decorator that allows filtering out table columns from results.
 */
class TableFilter extends AbstractTable
{
    /**
     * The table meta data being decorated.
     *
     * @var ITable
     */
    protected $originalTable;

    /**
     * Creates a new table filter using the original table
     *
     * @param $originalTable ITable
     * @param $excludeColumns array @deprecated, use the set* methods instead
     */
    public function __construct(ITable $originalTable, array $excludeColumns = [])
    {
        $this->originalTable = $originalTable;
        $this->setTableMetaData(new TableMetadataFilter($originalTable->getTableMetaData()));
        $this->addExcludeColumns($excludeColumns);
    }

    /**
     * Returns the an associative array keyed by columns for the given row.
     *
     * @param int $row
     *
     * @return array
     */
    public function getRow($row)
    {
        $this->loadData();

        return parent::getRow($row);
    }

    /**
     * Returns the number of rows in this table.
     *
     * @return int
     */
    public function getRowCount()
    {
        $this->loadData();

        return parent::getRowCount();
    }

    /**
     * Returns the value for the given column on the given row.
     *
     * @param int $row
     * @param int $column
     */
    public function getValue($row, $column)
    {
        if (\in_array($column, $this->getTableMetaData()->getColumns())) {
            return $this->originalTable->getValue($row, $column);
        }

        throw new InvalidArgumentException("The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}");
    }

    /**
     * Sets the columns to include in the table.
     *
     * @param array $includeColumns
     */
    public function addIncludeColumns(array $includeColumns): void
    {
        $this->tableMetaData->addIncludeColumns($includeColumns);
    }

    /**
     * Clears the included columns.
     */
    public function clearIncludeColumns(): void
    {
        $this->tableMetaData->clearIncludeColumns();
    }

    /**
     * Sets the columns to exclude from the table.
     *
     * @param array $excludeColumns
     */
    public function addExcludeColumns(array $excludeColumns): void
    {
        $this->tableMetaData->addExcludeColumns($excludeColumns);
    }

    /**
     * Clears the included columns.
     */
    public function clearExcludeColumns(): void
    {
        $this->tableMetaData->clearExcludeColumns();
    }

    /**
     * Checks if a given row is in the table
     *
     * @param array $row
     *
     * @return bool
     */
    public function assertContainsRow(array $row)
    {
        $this->loadData();

        return parent::assertContainsRow($row);
    }

    /**
     * Loads data into local data table if it's not already loaded
     */
    protected function loadData(): void
    {
        if ($this->data === null) {
            $data = [];

            for ($row = 0; $row < $this->originalTable->getRowCount(); $row++) {
                $tRow = [];

                foreach ($this->getTableMetaData()->getColumns() as $col) {
                    $tRow[$col] = $this->getValue($row, $col);
                }
                $data[$row] = $tRow;
            }
            $this->data = $data;
        }
    }
}


================================================
FILE: src/DataSet/TableMetadataFilter.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * A TableMetaData decorator that allows filtering columns from another
 * metaData object.
 *
 * The if a whitelist (include) filter is specified, then only those columns
 * will be included.
 */
class TableMetadataFilter extends AbstractTableMetadata
{
    /**
     * The table meta data being decorated.
     *
     * @var ITableMetadata
     */
    protected $originalMetaData;

    /**
     * The columns to exclude from the meta data.
     *
     * @var array
     */
    protected $excludeColumns = [];

    /**
     * The columns to include from the meta data.
     *
     * @var array
     */
    protected $includeColumns = [];

    /**
     * Creates a new filtered table meta data object filtering out
     * $excludeColumns.
     *
     * @param ITableMetadata $originalMetaData
     * @param array          $excludeColumns   - Deprecated. Use the set* methods instead.
     */
    public function __construct(ITableMetadata $originalMetaData, array $excludeColumns = [])
    {
        $this->originalMetaData = $originalMetaData;
        $this->addExcludeColumns($excludeColumns);
    }

    /**
     * Returns the names of the columns in the table.
     *
     * @return array
     */
    public function getColumns()
    {
        if (!empty($this->includeColumns)) {
            return \array_values(\array_intersect($this->originalMetaData->getColumns(), $this->includeColumns));
        }

        if (!empty($this->excludeColumns)) {
            return \array_values(\array_diff($this->originalMetaData->getColumns(), $this->excludeColumns));
        }

        return $this->originalMetaData->getColumns();
    }

    /**
     * Returns the names of the primary key columns in the table.
     *
     * @return array
     */
    public function getPrimaryKeys()
    {
        return $this->originalMetaData->getPrimaryKeys();
    }

    /**
     * Returns the name of the table.
     *
     * @return string
     */
    public function getTableName()
    {
        return $this->originalMetaData->getTableName();
    }

    /**
     * Sets the columns to include in the table.
     *
     * @param array $includeColumns
     */
    public function addIncludeColumns(array $includeColumns): void
    {
        $this->includeColumns = \array_unique(\array_merge($this->includeColumns, $includeColumns));
    }

    /**
     * Clears the included columns.
     */
    public function clearIncludeColumns(): void
    {
        $this->includeColumns = [];
    }

    /**
     * Sets the columns to exclude from the table.
     *
     * @param array $excludeColumns
     */
    public function addExcludeColumns(array $excludeColumns): void
    {
        $this->excludeColumns = \array_unique(\array_merge($this->excludeColumns, $excludeColumns));
    }

    /**
     * Clears the excluded columns.
     */
    public function clearExcludeColumns(): void
    {
        $this->excludeColumns = [];
    }
}


================================================
FILE: src/DataSet/XmlDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

use PHPUnit\DbUnit\RuntimeException;

/**
 * The default implementation of a data set.
 */
class XmlDataSet extends AbstractXmlDataSet
{
    protected function getTableInfo(array &$tableColumns, array &$tableValues): void
    {
        if ($this->xmlFileContents->getName() != 'dataset') {
            throw new RuntimeException('The root element of an xml data set file must be called <dataset>');
        }

        foreach ($this->xmlFileContents->xpath('/dataset/table') as $tableElement) {
            if (empty($tableElement['name'])) {
                throw new RuntimeException('Table elements must include a name attribute specifying the table name.');
            }

            $tableName = (string) $tableElement['name'];

            if (!isset($tableColumns[$tableName])) {
                $tableColumns[$tableName] = [];
            }

            if (!isset($tableValues[$tableName])) {
                $tableValues[$tableName] = [];
            }

            $tableInstanceColumns = [];

            foreach ($tableElement->xpath('./column') as $columnElement) {
                $columnName = (string) $columnElement;

                if (empty($columnName)) {
                    throw new RuntimeException("Missing <column> elements for table $tableName. Add one or more <column> elements to the <table> element.");
                }

                if (!\in_array($columnName, $tableColumns[$tableName])) {
                    $tableColumns[$tableName][] = $columnName;
                }

                $tableInstanceColumns[] = $columnName;
            }

            foreach ($tableElement->xpath('./row') as $rowElement) {
                $rowValues                 = [];
                $index                     = 0;
                $numOfTableInstanceColumns = \count($tableInstanceColumns);

                foreach ($rowElement->children() as $columnValue) {
                    if ($index >= $numOfTableInstanceColumns) {
                        throw new RuntimeException("Row contains more values than the number of columns defined for table $tableName.");
                    }

                    switch ($columnValue->getName()) {
                        case 'value':
                            $rowValues[$tableInstanceColumns[$index]] = (string) $columnValue;
                            $index++;

                            break;
                        case 'null':
                            $rowValues[$tableInstanceColumns[$index]] = null;
                            $index++;

                            break;
                        default:
                            throw new RuntimeException('Unknown element ' . $columnValue->getName() . ' in a row element.');
                    }
                }

                $tableValues[$tableName][] = $rowValues;
            }
        }
    }
}


================================================
FILE: src/DataSet/YamlDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\DataSet;

/**
 * Creates YamlDataSets.
 *
 * You can incrementally add YAML files as tables to your datasets
 */
class YamlDataSet extends AbstractDataSet
{
    /**
     * @var array
     */
    protected $tables = [];

    /**
     * @var IYamlParser
     */
    protected $parser;

    /**
     * Creates a new YAML dataset
     *
     * @param string      $yamlFile
     * @param IYamlParser $parser
     */
    public function __construct($yamlFile, $parser = null)
    {
        if ($parser == null) {
            $parser = new SymfonyYamlParser();
        }
        $this->parser = $parser;
        $this->addYamlFile($yamlFile);
    }

    /**
     * Adds a new yaml file to the dataset.
     *
     * @param string $yamlFile
     */
    public function addYamlFile($yamlFile): void
    {
        $data = $this->parser->parseYaml($yamlFile);

        foreach ($data as $tableName => $rows) {
            if (!isset($rows)) {
                $rows = [];
            }

            if (!\is_array($rows)) {
                continue;
            }

            if (!\array_key_exists($tableName, $this->tables)) {
                $columns = $this->getColumns($rows);

                $tableMetaData = new DefaultTableMetadata(
                    $tableName,
                    $columns
                );

                $this->tables[$tableName] = new DefaultTable(
                    $tableMetaData
                );
            }

            foreach ($rows as $row) {
                $this->tables[$tableName]->addRow($row);
            }
        }
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return ITableIterator
     */
    protected function createIterator($reverse = false)
    {
        return new DefaultTableIterator(
            $this->tables,
            $reverse
        );
    }

    /**
     * Creates a unique list of columns from all the rows in a table.
     * If the table is defined another time in the Yaml, and if the Yaml
     * parser could return the multiple occerrences, then this would be
     * insufficient unless we grouped all the occurences of the table
     * into onwe row set.  sfYaml, however, does not provide multiple tables
     * with the same name, it only supplies the last table.
     *
     * @params all the rows in a table.
     *
     * @param mixed $rows
     */
    private function getColumns($rows)
    {
        $columns = [];

        foreach ($rows as $row) {
            $columns = \array_merge($columns, \array_keys($row));
        }

        return \array_values(\array_unique($columns));
    }
}


================================================
FILE: src/Database/Connection.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database;

use PDO;
use PHPUnit\DbUnit\Database\Metadata\Metadata;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\DataSet\ITable;

/**
 * Provides a basic interface for communicating with a database.
 */
interface Connection
{
    /**
     * Close this connection.
     */
    public function close();

    /**
     * Creates a dataset containing the specified table names. If no table
     * names are specified then it will created a dataset over the entire
     * database.
     *
     * @param array $tableNames
     *
     * @return IDataSet
     */
    public function createDataSet(array $tableNames = null);

    /**
     * Creates a table with the result of the specified SQL statement.
     *
     * @param string $resultName
     * @param string $sql
     *
     * @return ITable
     */
    public function createQueryTable($resultName, $sql);

    /**
     * Returns a PDO Connection
     *
     * @return PDO
     */
    public function getConnection();

    /**
     * Returns a database metadata object that can be used to retrieve table
     * meta data from the database.
     *
     * @return Metadata
     */
    public function getMetaData();

    /**
     * Returns the number of rows in the given table. You can specify an
     * optional where clause to return a subset of the table.
     *
     * @param string $tableName
     * @param string $whereClause
     * @param int
     */
    public function getRowCount($tableName, $whereClause = null);

    /**
     * Returns the schema for the connection.
     *
     * @return string
     */
    public function getSchema();

    /**
     * Returns a quoted schema object. (table name, column name, etc)
     *
     * @param string $object
     *
     * @return string
     */
    public function quoteSchemaObject($object);

    /**
     * Returns the command used to truncate a table.
     *
     * @return string
     */
    public function getTruncateCommand();

    /**
     * Returns true if the connection allows cascading
     *
     * @return bool
     */
    public function allowsCascading();

    /**
     * Disables primary keys if connection does not allow setting them otherwise
     *
     * @param string $tableName
     */
    public function disablePrimaryKeys($tableName);

    /**
     * Reenables primary keys after they have been disabled
     *
     * @param string $tableName
     */
    public function enablePrimaryKeys($tableName);
}


================================================
FILE: src/Database/DataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database;

use PHPUnit\DbUnit\DataSet\AbstractDataSet;
use PHPUnit\DbUnit\DataSet\DefaultTableMetadata;
use PHPUnit\DbUnit\DataSet\ITableMetadata;
use PHPUnit\DbUnit\InvalidArgumentException;
use PHPUnit\DbUnit\RuntimeException;

/**
 * Provides access to a database instance as a data set.
 */
class DataSet extends AbstractDataSet
{
    /**
     * An array of ITable objects.
     *
     * @var array
     */
    protected $tables = [];

    /**
     * The database connection this dataset is using.
     *
     * @var Connection
     */
    protected $databaseConnection;

    /**
     * Creates the query necessary to pull all of the data from a table.
     *
     * @param ITableMetadata $tableMetaData
     *
     * @return string
     */
    public static function buildTableSelect(ITableMetadata $tableMetaData, Connection $databaseConnection = null)
    {
        if ($tableMetaData->getTableName() == '') {
            $e = new RuntimeException('Empty Table Name');
            print $e->getTraceAsString();

            throw $e;
        }

        $columns = $tableMetaData->getColumns();

        if ($databaseConnection) {
            $columns = \array_map([$databaseConnection, 'quoteSchemaObject'], $columns);
        }
        $columnList = \implode(', ', $columns);

        if ($databaseConnection) {
            $tableName = $databaseConnection->quoteSchemaObject($tableMetaData->getTableName());
        } else {
            $tableName = $tableMetaData->getTableName();
        }

        $primaryKeys = $tableMetaData->getPrimaryKeys();

        if ($databaseConnection) {
            $primaryKeys = \array_map([$databaseConnection, 'quoteSchemaObject'], $primaryKeys);
        }

        if (\count($primaryKeys)) {
            $orderBy = 'ORDER BY ' . \implode(' ASC, ', $primaryKeys) . ' ASC';
        } else {
            $orderBy = '';
        }

        return "SELECT {$columnList} FROM {$tableName} {$orderBy}";
    }

    /**
     * Creates a new dataset using the given database connection.
     *
     * @param Connection $databaseConnection
     */
    public function __construct(Connection $databaseConnection)
    {
        $this->databaseConnection = $databaseConnection;
    }

    /**
     * Returns a table object for the given table.
     *
     * @param string $tableName
     *
     * @return Table
     */
    public function getTable($tableName)
    {
        if (!\in_array($tableName, $this->getTableNames())) {
            throw new InvalidArgumentException("$tableName is not a table in the current database.");
        }

        if (empty($this->tables[$tableName])) {
            $this->tables[$tableName] = new Table($this->getTableMetaData($tableName), $this->databaseConnection);
        }

        return $this->tables[$tableName];
    }

    /**
     * Returns a table meta data object for the given table.
     *
     * @param string $tableName
     *
     * @return DefaultTableMetadata
     */
    public function getTableMetaData($tableName)
    {
        return new DefaultTableMetadata($tableName, $this->databaseConnection->getMetaData()->getTableColumns($tableName), $this->databaseConnection->getMetaData()->getTablePrimaryKeys($tableName));
    }

    /**
     * Returns a list of table names for the database
     *
     * @return array
     */
    public function getTableNames()
    {
        return $this->databaseConnection->getMetaData()->getTableNames();
    }

    /**
     * Creates an iterator over the tables in the data set. If $reverse is
     * true a reverse iterator will be returned.
     *
     * @param bool $reverse
     *
     * @return TableIterator
     */
    protected function createIterator($reverse = false)
    {
        return new TableIterator($this->getTableNames(), $this, $reverse);
    }
}


================================================
FILE: src/Database/DefaultConnection.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database;

use PDO;
use PHPUnit\DbUnit\Database\Metadata\AbstractMetadata;
use PHPUnit\DbUnit\Database\Metadata\Metadata;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\DataSet\QueryTable;

/**
 * Provides a basic interface for communicating with a database.
 */
class DefaultConnection implements Connection
{
    /**
     * @var PDO
     */
    protected $connection;

    /**
     * The metadata object used to retrieve table meta data from the database.
     *
     * @var Metadata
     */
    protected $metaData;

    /**
     * Creates a new database connection
     *
     * @param PDO    $connection
     * @param string $schema     - The name of the database schema you will be testing against
     */
    public function __construct(PDO $connection, $schema = '')
    {
        $this->connection = $connection;
        $this->metaData   = AbstractMetadata::createMetaData($connection, $schema);
        $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }

    /**
     * Close this connection.
     */
    public function close(): void
    {
        unset($this->connection, $this->metaData);
    }

    /**
     * Returns a database metadata object that can be used to retrieve table
     * meta data from the database.
     *
     * @return Metadata
     */
    public function getMetaData()
    {
        return $this->metaData;
    }

    /**
     * Returns the schema for the connection.
     *
     * @return string
     */
    public function getSchema()
    {
        return $this->getMetaData()->getSchema();
    }

    /**
     * Creates a dataset containing the specified table names. If no table
     * names are specified then it will created a dataset over the entire
     * database.
     *
     * @param array $tableNames
     *
     * @return IDataSet
     *
     * @todo Implement the filtered data set.
     */
    public function createDataSet(array $tableNames = null)
    {
        if (empty($tableNames)) {
            return new DataSet($this);
        }

        return new FilteredDataSet($this, $tableNames);
    }

    /**
     * Creates a table with the result of the specified SQL statement.
     *
     * @param string $resultName
     * @param string $sql
     *
     * @return Table
     */
    public function createQueryTable($resultName, $sql)
    {
        return new QueryTable($resultName, $sql, $this);
    }

    /**
     * Returns this connection database configuration
     */
    public function getConfig(): void
    {
    }

    /**
     * Returns a PDO Connection
     *
     * @return PDO
     */
    public function getConnection()
    {
        return $this->connection;
    }

    /**
     * Returns the number of rows in the given table. You can specify an
     * optional where clause to return a subset of the table.
     *
     * @param string $tableName
     * @param string $whereClause
     *
     * @return int
     */
    public function getRowCount($tableName, $whereClause = null)
    {
        $query = 'SELECT COUNT(*) FROM ' . $this->quoteSchemaObject($tableName);

        if (isset($whereClause)) {
            $query .= " WHERE {$whereClause}";
        }

        return (int) $this->connection->query($query)->fetchColumn();
    }

    /**
     * Returns a quoted schema object. (table name, column name, etc)
     *
     * @param string $object
     *
     * @return string
     */
    public function quoteSchemaObject($object)
    {
        return $this->getMetaData()->quoteSchemaObject($object);
    }

    /**
     * Returns the command used to truncate a table.
     *
     * @return string
     */
    public function getTruncateCommand()
    {
        return $this->getMetaData()->getTruncateCommand();
    }

    /**
     * Returns true if the connection allows cascading
     *
     * @return bool
     */
    public function allowsCascading()
    {
        return $this->getMetaData()->allowsCascading();
    }

    /**
     * Disables primary keys if connection does not allow setting them otherwise
     *
     * @param string $tableName
     */
    public function disablePrimaryKeys($tableName): void
    {
        $this->getMetaData()->disablePrimaryKeys($tableName);
    }

    /**
     * Reenables primary keys after they have been disabled
     *
     * @param string $tableName
     */
    public function enablePrimaryKeys($tableName): void
    {
        $this->getMetaData()->enablePrimaryKeys($tableName);
    }
}


================================================
FILE: src/Database/FilteredDataSet.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database;

/**
 * Provides access to a database instance as a data set.
 */
class FilteredDataSet extends DataSet
{
    /**
     * @var array
     */
    protected $tableNames;

    /**
     * Creates a new dataset using the given database connection.
     *
     * @param Connection $databaseConnection
     */
    public function __construct(Connection $databaseConnection, array $tableNames)
    {
        parent::__construct($databaseConnection);
        $this->tableNames = $tableNames;
    }

    /**
     * Returns a list of table names for the database
     *
     * @return array
     */
    public function getTableNames()
    {
        return $this->tableNames;
    }
}


================================================
FILE: src/Database/Metadata/AbstractMetadata.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

use PDO;
use PHPUnit\DbUnit\RuntimeException;
use ReflectionClass;

/**
 * Provides a basic constructor for all meta data classes and a factory for
 * generating the appropriate meta data class.
 */
abstract class AbstractMetadata implements Metadata
{
    protected static $metaDataClassMap = [
        'pgsql'    => PgSQL::class,
        'mysql'    => MySQL::class,
        'oci'      => Oci::class,
        'sqlite'   => Sqlite::class,
        'sqlite2'  => Sqlite::class,
        'sqlsrv'   => SqlSrv::class,
        'firebird' => Firebird::class,
        'dblib'    => Dblib::class
    ];

    /**
     * The PDO connection used to retreive database meta data
     *
     * @var PDO
     */
    protected $pdo;

    /**
     * The default schema name for the meta data object.
     *
     * @var string
     */
    protected $schema;

    /**
     * The character used to quote schema objects.
     */
    protected $schemaObjectQuoteChar = '"';

    /**
     * The command used to perform a TRUNCATE operation.
     */
    protected $truncateCommand = 'TRUNCATE';

    /**
     * Creates a meta data object based on the driver of given $pdo object and
     * $schema name.
     *
     * @param PDO    $pdo
     * @param string $schema
     *
     * @return AbstractMetadata
     */
    public static function createMetaData(PDO $pdo, $schema = '')
    {
        $driverName = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);

        if (isset(self::$metaDataClassMap[$driverName])) {
            $className = self::$metaDataClassMap[$driverName];

            if ($className instanceof ReflectionClass) {
                return $className->newInstance($pdo, $schema);
            }

            return self::registerClassWithDriver($className, $driverName)->newInstance($pdo, $schema);
        }

        throw new RuntimeException("Could not find a meta data driver for {$driverName} pdo driver.");
    }

    /**
     * Validates and registers the given $className with the given $pdoDriver.
     * It should be noted that this function will not attempt to include /
     * require the file. The $pdoDriver can be determined by the value of the
     * PDO::ATTR_DRIVER_NAME attribute for a pdo object.
     *
     * A reflection of the $className is returned.
     *
     * @param string $className
     * @param string $pdoDriver
     *
     * @return ReflectionClass
     */
    public static function registerClassWithDriver($className, $pdoDriver)
    {
        if (!\class_exists($className)) {
            throw new RuntimeException("Specified class for {$pdoDriver} driver ({$className}) does not exist.");
        }

        $reflection = new ReflectionClass($className);

        if ($reflection->isSubclassOf(self::class)) {
            return self::$metaDataClassMap[$pdoDriver] = $reflection;
        }

        throw new RuntimeException("Specified class for {$pdoDriver} driver ({$className}) does not extend PHPUnit_Extensions_Database_DB_MetaData.");
    }

    /**
     * Creates a new database meta data object using the given pdo connection
     * and schema name.
     *
     * @param PDO    $pdo
     * @param string $schema
     */
    final public function __construct(PDO $pdo, $schema = '')
    {
        $this->pdo    = $pdo;
        $this->schema = $schema;
    }

    /**
     * Returns the schema for the connection.
     *
     * @return string
     */
    public function getSchema()
    {
        return $this->schema;
    }

    /**
     * Returns a quoted schema object. (table name, column name, etc)
     *
     * @param string $object
     *
     * @return string
     */
    public function quoteSchemaObject($object)
    {
        $parts       = \explode('.', $object);
        $quotedParts = [];

        foreach ($parts as $part) {
            $quotedParts[] = $this->schemaObjectQuoteChar .
                \str_replace($this->schemaObjectQuoteChar, $this->schemaObjectQuoteChar . $this->schemaObjectQuoteChar, $part) .
                $this->schemaObjectQuoteChar;
        }

        return \implode('.', $quotedParts);
    }

    /**
     * Seperates the schema and the table from a fully qualified table name.
     *
     * Returns an associative array containing the 'schema' and the 'table'.
     *
     * @param string $fullTableName
     *
     * @return array
     */
    public function splitTableName($fullTableName)
    {
        if (($dot = \strpos($fullTableName, '.')) !== false) {
            return [
                'schema' => \substr($fullTableName, 0, $dot),
                'table'  => \substr($fullTableName, $dot + 1)
            ];
        }

        return [
                'schema' => null,
                'table'  => $fullTableName
            ];
    }

    /**
     * Returns the command for the database to truncate a table.
     *
     * @return string
     */
    public function getTruncateCommand()
    {
        return $this->truncateCommand;
    }

    /**
     * Returns true if the rdbms allows cascading
     *
     * @return bool
     */
    public function allowsCascading()
    {
        return false;
    }

    /**
     * Disables primary keys if the rdbms does not allow setting them otherwise
     *
     * @param string $tableName
     */
    public function disablePrimaryKeys($tableName): void
    {
        return;
    }

    /**
     * Reenables primary keys after they have been disabled
     *
     * @param string $tableName
     */
    public function enablePrimaryKeys($tableName): void
    {
        return;
    }
}


================================================
FILE: src/Database/Metadata/Dblib.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

/**
 * Provides functionality to retrieve meta data from an Dblib (SQL Server) database.
 */
class Dblib extends AbstractMetadata
{
    /**
     * No character used to quote schema objects.
     *
     * @var string
     */
    protected $schemaObjectQuoteChar = '';

    /**
     * The command used to perform a TRUNCATE operation.
     *
     * @var string
     */
    protected $truncateCommand = 'TRUNCATE TABLE';

    /**
     * @var array
     */
    protected $columns = [];

    /**
     * @var array
     */
    protected $keys = [];

    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $tableNames = [];

        $query = 'SELECT name
                    FROM sys.tables
                   ORDER BY name';

        $result = $this->pdo->query($query);

        while ($tableName = $result->fetchColumn(0)) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        if (!isset($this->columns[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->columns[$tableName];
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        if (!isset($this->keys[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->keys[$tableName];
    }

    /**
     * Loads column info from a sql server database.
     *
     * @param string $tableName
     */
    protected function loadColumnInfo($tableName): void
    {
        $query = "SELECT name
			FROM sys.columns
		   WHERE object_id = OBJECT_ID('" . $tableName . "')
		   ORDER BY column_id";

        $result = $this->pdo->query($query);

        while ($columnName = $result->fetchColumn(0)) {
            $this->columns[$tableName][] = $columnName;
        }

        $keyQuery = "SELECT COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName
			FROM    sys.indexes AS i INNER JOIN 
				sys.index_columns AS ic ON  i.OBJECT_ID = ic.OBJECT_ID
						        AND i.index_id = ic.index_id
			WHERE   i.is_primary_key = 1 AND OBJECT_NAME(ic.OBJECT_ID) = '" . $tableName . "'";

        $result = $this->pdo->query($keyQuery);

        while ($columnName = $result->fetchColumn(0)) {
            $this->keys[$tableName][] = $columnName;
        }
    }
}


================================================
FILE: src/Database/Metadata/Firebird.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

/**
 * Provides functionality to retrieve meta data from a Firebird database.
 */
class Firebird extends AbstractMetadata
{
    /**
     * The command used to perform a TRUNCATE operation.
     *
     * @var string
     */
    protected $truncateCommand = 'DELETE FROM';

    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $query = "
            SELECT DISTINCT
                TABLE_NAME
            FROM INFORMATION_SCHEMA.TABLES
            WHERE
                TABLE_TYPE='BASE TABLE' AND
                TABLE_SCHEMA = ?
            ORDER BY TABLE_NAME
        ";

        $query = "
            select
              RDB$RELATION_NAME as TABLE_NAME
            from RDB$RELATIONS
            where
              ((RDB$RELATION_TYPE = 0) or
               (RDB$RELATION_TYPE is null)) and
              (RDB$SYSTEM_FLAG = 0)
            order by (RDB$RELATION_NAME)
        ";

        $statement = $this->pdo->prepare($query);
        $statement->execute([$this->getSchema()]);

        $tableNames = [];

        while ($tableName = $statement->fetchColumn(0)) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        if (!isset($this->columns[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->columns[$tableName];
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        if (!isset($this->keys[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->keys[$tableName];
    }

    /**
     * Returns the schema for the connection.
     *
     * @return string
     */
    public function getSchema()
    {
        if (empty($this->schema)) {
            return 'public';
        }

        return $this->schema;
    }

    /**
     * Returns true if the rdbms allows cascading
     *
     * @return bool
     */
    public function allowsCascading()
    {
        return false;
    }

    /**
     * Returns a quoted schema object. (table name, column name, etc)
     *
     * @param string $object
     *
     * @return string
     */
    public function quoteSchemaObject($object)
    {
        return $object; //firebird does not allow object quoting
    }

    /**
     * Loads column info from a database table.
     *
     * @param string $tableName
     */
    protected function loadColumnInfo($tableName): void
    {
        $this->columns[$tableName] = [];
        $this->keys[$tableName]    = [];

        $columnQuery = '
            SELECT DISTINCT
                COLUMN_NAME, ORDINAL_POSITION
            FROM INFORMATION_SCHEMA.COLUMNS
            WHERE
                TABLE_NAME = ? AND
                TABLE_SCHEMA = ?
            ORDER BY ORDINAL_POSITION
        ';

        $columnQuery = '
            select
              rf.RDB$FIELD_NAME as COLUMN_NAME,
              rf.RDB$FIELD_POSITION as ORDINAL_POSITION
            from RDB$RELATION_FIELDS as rf
            where
              upper(RDB$RELATION_NAME) = upper(?)
            order by
              ORDINAL_POSITION

        ';

        $columnStatement = $this->pdo->prepare($columnQuery);
        $columnStatement->execute([$tableName]);

        while ($columName = $columnStatement->fetchColumn(0)) {
            $this->columns[$tableName][] = $columName;
        }

        $keyQuery = "
            SELECT
                KCU.COLUMN_NAME,
                KCU.ORDINAL_POSITION
            FROM
                INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU
            LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC
                ON TC.TABLE_NAME = KCU.TABLE_NAME
            WHERE
                TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND
                TC.TABLE_NAME = ? AND
                TC.TABLE_SCHEMA = ?
            ORDER BY
                KCU.ORDINAL_POSITION ASC
        ";

        $keyQuery = "
            select
              idseg.rdb\$field_name as COLUMN_NAME,
              idseg.rdb\$field_position as ORDINAL_POSITION,
              rc.rdb\$relation_name as tablename,
              rc.rdb\$constraint_name as pk_name
            from
              RDB\$RELATION_CONSTRAINTS AS rc
                left join
              rdb\$index_segments as idseg on
                (rc.rdb\$index_name = idseg.rdb\$index_name)
            where
              rc.RDB\$CONSTRAINT_TYPE = 'PRIMARY KEY'
              and upper(rc.RDB\$RELATION_NAME) = upper(?)
            order by
              rc.rdb\$constraint_name, idseg.rdb\$field_position
        ";

        $keyStatement = $this->pdo->prepare($keyQuery);
        $keyStatement->execute([$tableName]);

        while ($columName = $keyStatement->fetchColumn(0)) {
            $this->keys[$tableName][] = $columName;
        }
    }
}


================================================
FILE: src/Database/Metadata/InformationSchema.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

/**
 * Provides functionality to retrieve meta data from a database with information_schema support.
 */
class InformationSchema extends AbstractMetadata
{
    protected $columns = [];

    protected $keys = [];

    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $query = "
            SELECT DISTINCT
                TABLE_NAME
            FROM INFORMATION_SCHEMA.TABLES
            WHERE
                TABLE_TYPE='BASE TABLE' AND
                TABLE_SCHEMA = ?
            ORDER BY TABLE_NAME
        ";

        $statement = $this->pdo->prepare($query);
        $statement->execute([$this->getSchema()]);

        $tableNames = [];

        while ($tableName = $statement->fetchColumn(0)) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        if (!isset($this->columns[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->columns[$tableName];
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        if (!isset($this->keys[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->keys[$tableName];
    }

    /**
     * Loads column info from a sqlite database.
     *
     * @param string $tableName
     */
    protected function loadColumnInfo($tableName): void
    {
        $this->columns[$tableName] = [];
        $this->keys[$tableName]    = [];

        $columnQuery = '
            SELECT DISTINCT
                COLUMN_NAME
            FROM INFORMATION_SCHEMA.COLUMNS
            WHERE
                TABLE_NAME = ? AND
                TABLE_SCHEMA = ?
            ORDER BY ORDINAL_POSITION
        ';

        $columnStatement = $this->pdo->prepare($columnQuery);
        $columnStatement->execute([$tableName, $this->getSchema()]);

        while ($columName = $columnStatement->fetchColumn(0)) {
            $this->columns[$tableName][] = $columName;
        }

        $keyQuery = "
            SELECT
                KCU.COLUMN_NAME
            FROM
                INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC,
                INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU
            WHERE
                TC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND
                TC.TABLE_NAME = KCU.TABLE_NAME AND
                TC.TABLE_SCHEMA = KCU.TABLE_SCHEMA AND
                TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND
                TC.TABLE_NAME = ? AND
                TC.TABLE_SCHEMA = ?
            ORDER BY
                KCU.ORDINAL_POSITION ASC
        ";

        $keyStatement = $this->pdo->prepare($keyQuery);
        $keyStatement->execute([$tableName, $this->getSchema()]);

        while ($columName = $keyStatement->fetchColumn(0)) {
            $this->keys[$tableName][] = $columName;
        }
    }
}


================================================
FILE: src/Database/Metadata/Metadata.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

/**
 * Provides a basic interface for retreiving metadata from a database.
 */
interface Metadata
{
    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames();

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName);

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName);

    /**
     * Returns the name of the default schema.
     *
     * @return string
     */
    public function getSchema();

    /**
     * Returns a quoted schema object. (table name, column name, etc)
     *
     * @param string $object
     *
     * @return string
     */
    public function quoteSchemaObject($object);

    /**
     * Returns true if the rdbms allows cascading
     *
     * @return bool
     */
    public function allowsCascading();

    /**
     * Disables primary keys if rdbms does not allow setting them otherwise
     *
     * @param string $tableName
     */
    public function disablePrimaryKeys($tableName);

    /**
     * Reenables primary keys after they have been disabled
     *
     * @param string $tableName
     */
    public function enablePrimaryKeys($tableName);
}


================================================
FILE: src/Database/Metadata/MySQL.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

use PDO;

/**
 * Provides functionality to retrieve meta data from a MySQL database.
 */
class MySQL extends AbstractMetadata
{
    protected $schemaObjectQuoteChar = '`';

    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $query     = 'SHOW TABLES';
        $statement = $this->pdo->prepare($query);
        $statement->execute();

        $tableNames = [];

        while (($tableName = $statement->fetchColumn(0))) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        $query     = 'SHOW COLUMNS FROM ' . $this->quoteSchemaObject($tableName);
        $statement = $this->pdo->prepare($query);
        $statement->execute();

        $columnNames = [];

        while (($columnName = $statement->fetchColumn(0))) {
            $columnNames[] = $columnName;
        }

        return $columnNames;
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        $query     = 'SHOW INDEX FROM ' . $this->quoteSchemaObject($tableName);
        $statement = $this->pdo->prepare($query);
        $statement->execute();
        $statement->setFetchMode(PDO::FETCH_ASSOC);

        $columnNames = [];

        while (($column = $statement->fetch())) {
            if ($column['Key_name'] == 'PRIMARY') {
                $columnNames[] = $column['Column_name'];
            }
        }

        return $columnNames;
    }
}


================================================
FILE: src/Database/Metadata/Oci.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

/**
 * Provides functionality to retrieve meta data from an Oracle database.
 */
class Oci extends AbstractMetadata
{
    /**
     * No character used to quote schema objects.
     *
     * @var string
     */
    protected $schemaObjectQuoteChar = '';

    /**
     * The command used to perform a TRUNCATE operation.
     *
     * @var string
     */
    protected $truncateCommand = 'TRUNCATE TABLE';

    /**
     * @var array
     */
    protected $columns = [];

    /**
     * @var array
     */
    protected $keys = [];

    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $tableNames = [];

        $query = "SELECT table_name
                    FROM cat
                   WHERE table_type='TABLE'
                   ORDER BY table_name";

        $result = $this->pdo->query($query);

        while ($tableName = $result->fetchColumn(0)) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        if (!isset($this->columns[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->columns[$tableName];
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        if (!isset($this->keys[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->keys[$tableName];
    }

    /**
     * Loads column info from a oracle database.
     *
     * @param string $tableName
     */
    protected function loadColumnInfo($tableName): void
    {
        $ownerQuery    = '';
        $conOwnerQuery = '';
        $tableParts    = $this->splitTableName($tableName);

        $this->columns[$tableName] = [];
        $this->keys[$tableName]    = [];

        if (!empty($tableParts['schema'])) {
            $ownerQuery    = " AND OWNER = '{$tableParts['schema']}'";
            $conOwnerQuery = " AND a.owner = '{$tableParts['schema']}'";
        }

        $query = "SELECT DISTINCT COLUMN_NAME
                    FROM USER_TAB_COLUMNS
                   WHERE TABLE_NAME='" . $tableParts['table'] . "'
                    $ownerQuery
                   ORDER BY COLUMN_NAME";

        $result = $this->pdo->query($query);

        while ($columnName = $result->fetchColumn(0)) {
            $this->columns[$tableName][] = $columnName;
        }

        $keyQuery = "SELECT b.column_name
                       FROM user_constraints a, user_cons_columns b
                      WHERE a.constraint_type='P'
                        AND a.constraint_name=b.constraint_name
                        $conOwnerQuery
                        AND a.table_name = '" . $tableParts['table'] . "' ";

        $result = $this->pdo->query($keyQuery);

        while ($columnName = $result->fetchColumn(0)) {
            $this->keys[$tableName][] = $columnName;
        }
    }
}


================================================
FILE: src/Database/Metadata/PgSQL.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

/**
 * Provides functionality to retrieve meta data from a PostgreSQL database.
 */
class PgSQL extends AbstractMetadata
{
    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $query = "
            SELECT DISTINCT
                TABLE_NAME
            FROM INFORMATION_SCHEMA.TABLES
            WHERE
                TABLE_TYPE='BASE TABLE' AND
                TABLE_SCHEMA = ?
            ORDER BY TABLE_NAME
        ";

        $statement = $this->pdo->prepare($query);
        $statement->execute([$this->getSchema()]);

        $tableNames = [];

        while ($tableName = $statement->fetchColumn(0)) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        if (!isset($this->columns[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->columns[$tableName];
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        if (!isset($this->keys[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->keys[$tableName];
    }

    /**
     * Returns the schema for the connection.
     *
     * @return string
     */
    public function getSchema()
    {
        if (empty($this->schema)) {
            return 'public';
        }

        return $this->schema;
    }

    /**
     * Returns true if the rdbms allows cascading
     *
     * @return bool
     */
    public function allowsCascading()
    {
        return true;
    }

    /**
     * Loads column info from a database table.
     *
     * @param string $tableName
     */
    protected function loadColumnInfo($tableName): void
    {
        $this->columns[$tableName] = [];
        $this->keys[$tableName]    = [];

        $columnQuery = '
            SELECT DISTINCT
                COLUMN_NAME, ORDINAL_POSITION
            FROM INFORMATION_SCHEMA.COLUMNS
            WHERE
                TABLE_NAME = ? AND
                TABLE_SCHEMA = ?
            ORDER BY ORDINAL_POSITION
        ';

        $columnStatement = $this->pdo->prepare($columnQuery);
        $columnStatement->execute([$tableName, $this->getSchema()]);

        while ($columName = $columnStatement->fetchColumn(0)) {
            $this->columns[$tableName][] = $columName;
        }

        $keyQuery = "
            SELECT
                KCU.COLUMN_NAME,
                KCU.ORDINAL_POSITION
            FROM
                INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU
            LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS as TC
                ON TC.TABLE_NAME = KCU.TABLE_NAME AND
                TC.CONSTRAINT_NAME = KCU.CONSTRAINT_NAME
            WHERE
                TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND
                TC.TABLE_NAME = ? AND
                TC.TABLE_SCHEMA = ?
            ORDER BY
                KCU.ORDINAL_POSITION ASC
        ";

        $keyStatement = $this->pdo->prepare($keyQuery);
        $keyStatement->execute([$tableName, $this->getSchema()]);

        while ($columName = $keyStatement->fetchColumn(0)) {
            $this->keys[$tableName][] = $columName;
        }
    }
}


================================================
FILE: src/Database/Metadata/SqlSrv.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

use PDO;
use PDOException;

/**
 * Provides functionality to retrieve meta data from a Microsoft SQL Server database.
 */
class SqlSrv extends AbstractMetadata
{
    /**
     * No character used to quote schema objects.
     *
     * @var string
     */
    protected $schemaObjectQuoteChar = '';

    /**
     * The command used to perform a TRUNCATE operation.
     *
     * @var string
     */
    protected $truncateCommand = 'TRUNCATE TABLE';

    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $query = "SELECT name
                    FROM sysobjects
                   WHERE type='U'";

        $statement = $this->pdo->prepare($query);
        $statement->execute();

        $tableNames = [];

        while (($tableName = $statement->fetchColumn(0))) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        $query = "SELECT c.name
                    FROM syscolumns c
               LEFT JOIN sysobjects o ON c.id = o.id
                   WHERE o.name = '$tableName'";

        $statement = $this->pdo->prepare($query);
        $statement->execute();

        $columnNames = [];

        while (($columnName = $statement->fetchColumn(0))) {
            $columnNames[] = $columnName;
        }

        return $columnNames;
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        $query     = "EXEC sp_statistics '$tableName'";
        $statement = $this->pdo->prepare($query);
        $statement->execute();
        $statement->setFetchMode(PDO::FETCH_ASSOC);

        $columnNames = [];

        while (($column = $statement->fetch())) {
            if ($column['TYPE'] == 1) {
                $columnNames[] = $column['COLUMN_NAME'];
            }
        }

        return $columnNames;
    }

    /**
     * Allow overwriting identities for the given table.
     *
     * @param string $tableName
     */
    public function disablePrimaryKeys($tableName): void
    {
        try {
            $query = "SET IDENTITY_INSERT $tableName ON";
            $this->pdo->exec($query);
        } catch (PDOException $e) {
            // ignore the error here - can happen if primary key is not an identity
        }
    }

    /**
     * Reenable auto creation of identities for the given table.
     *
     * @param string $tableName
     */
    public function enablePrimaryKeys($tableName): void
    {
        try {
            $query = "SET IDENTITY_INSERT $tableName OFF";
            $this->pdo->exec($query);
        } catch (PDOException $e) {
            // ignore the error here - can happen if primary key is not an identity
        }
    }
}


================================================
FILE: src/Database/Metadata/Sqlite.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

use PDO;
use PDOStatement;

/**
 * Provides functionality to retrieve meta data from an Sqlite database.
 */
class Sqlite extends AbstractMetadata
{
    protected $columns = [];

    protected $keys = [];

    protected $truncateCommand = 'DELETE FROM';

    /**
     * Returns an array containing the names of all the tables in the database.
     *
     * @return array
     */
    public function getTableNames()
    {
        $query = "
            SELECT name
            FROM sqlite_master
            WHERE
                type='table' AND
                name <> 'sqlite_sequence'
            ORDER BY name
        ";

        $result = $this->pdo->query($query);

        $tableNames = [];

        while ($tableName = $result->fetchColumn(0)) {
            $tableNames[] = $tableName;
        }

        return $tableNames;
    }

    /**
     * Returns an array containing the names of all the columns in the
     * $tableName table,
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTableColumns($tableName)
    {
        if (!isset($this->columns[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->columns[$tableName];
    }

    /**
     * Returns an array containing the names of all the primary key columns in
     * the $tableName table.
     *
     * @param string $tableName
     *
     * @return array
     */
    public function getTablePrimaryKeys($tableName)
    {
        if (!isset($this->keys[$tableName])) {
            $this->loadColumnInfo($tableName);
        }

        return $this->keys[$tableName];
    }

    /**
     * Loads column info from a sqlite database.
     *
     * @param string $tableName
     */
    protected function loadColumnInfo($tableName): void
    {
        $query     = "PRAGMA table_info('{$tableName}')";
        $statement = $this->pdo->query($query);

        /* @var $statement PDOStatement */
        $this->columns[$tableName] = [];
        $this->keys[$tableName]    = [];

        while ($columnData = $statement->fetch(PDO::FETCH_NUM)) {
            $this->columns[$tableName][] = $columnData[1];

            if ((int) $columnData[5] !== 0) {
                $this->keys[$tableName][] = $columnData[1];
            }
        }
    }
}


================================================
FILE: src/Database/Metadata/Table.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database\Metadata;

use PHPUnit\DbUnit\DataSet\DefaultTableMetadata;

/**
 * This class loads a table metadata object with database metadata.
 */
class Table extends DefaultTableMetadata
{
    public function __construct($tableName, Metadata $databaseMetaData)
    {
        $this->tableName   = $tableName;
        $this->columns     = $databaseMetaData->getTableColumns($tableName);
        $this->primaryKeys = $databaseMetaData->getTablePrimaryKeys($tableName);
    }
}


================================================
FILE: src/Database/ResultSetTable.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database;

use PDO;
use PDOStatement;
use PHPUnit\DbUnit\DataSet\AbstractTable;
use PHPUnit\DbUnit\DataSet\DefaultTableMetadata;

/**
 * Provides the functionality to represent a database result set as a DBUnit
 * table.
 *
 * @deprecated The PHPUnit_Extension_Database_DataSet_QueryTable should be used instead
 * @see        PHPUnit_Extension_Database_DataSet_QueryTable
 * @see        PHPUnit_Extension_Database_DataSet_QueryDataSet
 */
class ResultSetTable extends AbstractTable
{
    /**
     * Creates a new result set table.
     *
     * @param string       $tableName
     * @param PDOStatement $pdoStatement
     */
    public function __construct($tableName, PDOStatement $pdoStatement)
    {
        $this->data = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);

        if (\count($this->data)) {
            $columns = \array_keys($this->data[0]);
        } else {
            $columns = [];
        }

        $this->setTableMetaData(new DefaultTableMetadata($tableName, $columns));
    }
}


================================================
FILE: src/Database/Table.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database;

use PDO;
use PHPUnit\DbUnit\DataSet\AbstractTable;
use PHPUnit\DbUnit\DataSet\ITableMetadata;

/**
 * Provides the functionality to represent a database table.
 */
class Table extends AbstractTable
{
    /**
     * Creates a new database table object.
     *
     * @param ITableMetadata $tableMetaData
     * @param Connection     $databaseConnection
     */
    public function __construct(ITableMetadata $tableMetaData, Connection $databaseConnection)
    {
        $this->setTableMetaData($tableMetaData);

        $pdoStatement = $databaseConnection->getConnection()->prepare(DataSet::buildTableSelect($tableMetaData, $databaseConnection));
        $pdoStatement->execute();
        $this->data = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
    }
}


================================================
FILE: src/Database/TableIterator.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Database;

use PHPUnit\DbUnit\DataSet\ITable;
use PHPUnit\DbUnit\DataSet\ITableIterator;
use PHPUnit\DbUnit\DataSet\ITableMetadata;

/**
 * Provides iterative access to tables from a database instance.
 */
class TableIterator implements ITableIterator
{
    /**
     * An array of tablenames.
     *
     * @var array
     */
    protected $tableNames;

    /**
     * If this property is true then the tables will be iterated in reverse
     * order.
     *
     * @var bool
     */
    protected $reverse;

    /**
     * The database dataset that this iterator iterates over.
     *
     * @var DataSet
     */
    protected $dataSet;

    public function __construct($tableNames, DataSet $dataSet, $reverse = false)
    {
        $this->tableNames = $tableNames;
        $this->dataSet    = $dataSet;
        $this->reverse    = $reverse;

        $this->rewind();
    }

    /**
     * Returns the current table.
     *
     * @return ITable
     */
    public function getTable()
    {
        return $this->current();
    }

    /**
     * Returns the current table's meta data.
     *
     * @return ITableMetadata
     */
    public function getTableMetaData()
    {
        return $this->current()->getTableMetaData();
    }

    /**
     * Returns the current table.
     *
     * @return ITable
     */
    public function current()
    {
        $tableName = \current($this->tableNames);

        return $this->dataSet->getTable($tableName);
    }

    /**
     * Returns the name of the current table.
     *
     * @return string
     */
    public function key()
    {
        return $this->current()->getTableMetaData()->getTableName();
    }

    /**
     * advances to the next element.
     */
    public function next(): void
    {
        if ($this->reverse) {
            \prev($this->tableNames);
        } else {
            \next($this->tableNames);
        }
    }

    /**
     * Rewinds to the first element
     */
    public function rewind(): void
    {
        if ($this->reverse) {
            \end($this->tableNames);
        } else {
            \reset($this->tableNames);
        }
    }

    /**
     * Returns true if the current index is valid
     *
     * @return bool
     */
    public function valid()
    {
        return \current($this->tableNames) !== false;
    }
}


================================================
FILE: src/DatabaseListConsumer.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit;

/**
 * An interface for classes that require a list of databases to operate.
 */
interface DatabaseListConsumer
{
    /**
     * Sets the database for the spec
     *
     * @param array $databases
     */
    public function setDatabases(array $databases);
}


================================================
FILE: src/DefaultTester.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit;

use PHPUnit\DbUnit\Database\Connection;

/**
 * This is the default implementation of the database tester. It receives its
 * connection object from the constructor.
 */
class DefaultTester extends AbstractTester
{
    /**
     * @var Connection
     */
    protected $connection;

    /**
     * Creates a new default database tester using the given connection.
     *
     * @param Connection $connection
     */
    public function __construct(Connection $connection)
    {
        parent::__construct();

        $this->connection = $connection;
    }

    /**
     * Returns the test database connection.
     *
     * @return Connection
     */
    public function getConnection()
    {
        return $this->connection;
    }
}


================================================
FILE: src/Exception/Exception.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit;

interface Exception
{
}


================================================
FILE: src/Exception/InvalidArgumentException.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit;

class InvalidArgumentException extends \InvalidArgumentException implements Exception
{
}


================================================
FILE: src/Exception/RuntimeException.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit;

class RuntimeException extends \RuntimeException implements Exception
{
}


================================================
FILE: src/Operation/Composite.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\InvalidArgumentException;

/**
 * This class facilitates combining database operations. To create a composite
 * operation pass an array of classes that implement
 * PHPUnit_Extensions_Database_Operation_IDatabaseOperation and they will be
 * executed in that order against all data sets.
 */
class Composite implements Operation
{
    /**
     * @var array
     */
    protected $operations = [];

    /**
     * Creates a composite operation.
     *
     * @param array $operations
     */
    public function __construct(array $operations)
    {
        foreach ($operations as $operation) {
            if ($operation instanceof Operation) {
                $this->operations[] = $operation;
            } else {
                throw new InvalidArgumentException('Only database operation instances can be passed to a composite database operation.');
            }
        }
    }

    public function execute(Connection $connection, IDataSet $dataSet): void
    {
        try {
            foreach ($this->operations as $operation) {
                /* @var $operation Operation */
                $operation->execute($connection, $dataSet);
            }
        } catch (Exception $e) {
            throw new Exception("COMPOSITE[{$e->getOperation()}]", $e->getQuery(), $e->getArgs(), $e->getTable(), $e->getError());
        }
    }
}


================================================
FILE: src/Operation/Delete.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\ITable;
use PHPUnit\DbUnit\DataSet\ITableMetadata;

/**
 * Deletes the rows in a given dataset using primary key columns.
 */
class Delete extends RowBased
{
    protected $operationName = 'DELETE';

    protected $iteratorDirection = self::ITERATOR_TYPE_REVERSE;

    protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)
    {
        $keys = $databaseTableMetaData->getPrimaryKeys();

        $whereStatement = 'WHERE ' . \implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));

        $query = "
            DELETE FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
            {$whereStatement}
        ";

        return $query;
    }

    protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row)
    {
        $args = [];

        foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {
            $args[] = $table->getValue($row, $columnName);
        }

        return $args;
    }
}


================================================
FILE: src/Operation/DeleteAll.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PDOException;
use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\DataSet\ITable;

/**
 * Deletes all rows from all tables in a dataset.
 */
class DeleteAll implements Operation
{
    public function execute(Connection $connection, IDataSet $dataSet): void
    {
        foreach ($dataSet->getReverseIterator() as $table) {
            /* @var $table ITable */

            $query = "
                DELETE FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
            ";

            try {
                $connection->getConnection()->query($query);
            } catch (PDOException $e) {
                throw new Exception('DELETE_ALL', $query, [], $table, $e->getMessage());
            }
        }
    }
}


================================================
FILE: src/Operation/Exception.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\DataSet\ITable;
use PHPUnit\DbUnit\RuntimeException;

/**
 * Thrown for exceptions encountered with database operations. Provides
 * information regarding which operations failed and the query (if any) it
 * failed on.
 */
class Exception extends RuntimeException
{
    /**
     * @var string
     */
    protected $operation;

    /**
     * @var string
     */
    protected $preparedQuery;

    /**
     * @var array
     */
    protected $preparedArgs;

    /**
     * @var ITable
     */
    protected $table;

    /**
     * @var string
     */
    protected $error;

    /**
     * Creates a new dbunit operation exception
     *
     * @param string $operation
     * @param string $current_query
     * @param ITable $current_table
     * @param string $error
     * @param mixed  $current_args
     */
    public function __construct($operation, $current_query, $current_args, $current_table, $error)
    {
        parent::__construct("{$operation} operation failed on query: {$current_query} using args: " . \print_r($current_args, true) . " [{$error}]");

        $this->operation     = $operation;
        $this->preparedQuery = $current_query;
        $this->preparedArgs  = $current_args;
        $this->table         = $current_table;
        $this->error         = $error;
    }

    public function getOperation()
    {
        return $this->operation;
    }

    public function getQuery()
    {
        return $this->preparedQuery;
    }

    public function getTable()
    {
        return $this->table;
    }

    public function getArgs()
    {
        return $this->preparedArgs;
    }

    public function getError()
    {
        return $this->error;
    }
}


================================================
FILE: src/Operation/Factory.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

/**
 * A class factory to easily return database operations.
 */
class Factory
{
    /**
     * Returns a null database operation
     *
     * @return Operation
     */
    public static function NONE()
    {
        return new None();
    }

    /**
     * Returns a clean insert database operation. It will remove all contents
     * from the table prior to re-inserting rows.
     *
     * @param bool $cascadeTruncates set to true to force truncates to cascade on databases that support this
     *
     * @return Operation
     */
    public static function CLEAN_INSERT($cascadeTruncates = false)
    {
        return new Composite([
            self::TRUNCATE($cascadeTruncates),
            self::INSERT()
        ]);
    }

    /**
     * Returns an insert database operation.
     *
     * @return Operation
     */
    public static function INSERT()
    {
        return new Insert();
    }

    /**
     * Returns a truncate database operation.
     *
     * @param bool $cascadeTruncates set to true to force truncates to cascade on databases that support this
     *
     * @return Operation
     */
    public static function TRUNCATE($cascadeTruncates = false)
    {
        $truncate = new Truncate();
        $truncate->setCascade($cascadeTruncates);

        return $truncate;
    }

    /**
     * Returns a delete database operation.
     *
     * @return Operation
     */
    public static function DELETE()
    {
        return new Delete();
    }

    /**
     * Returns a delete_all database operation.
     *
     * @return Operation
     */
    public static function DELETE_ALL()
    {
        return new DeleteAll();
    }

    /**
     * Returns an update database operation.
     *
     * @return Operation
     */
    public static function UPDATE()
    {
        return new Update();
    }
}


================================================
FILE: src/Operation/Insert.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\ITable;
use PHPUnit\DbUnit\DataSet\ITableMetadata;

/**
 * This class provides functionality for inserting rows from a dataset into a database.
 */
class Insert extends RowBased
{
    protected $operationName = 'INSERT';

    protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)
    {
        $columnCount = \count($table->getTableMetaData()->getColumns());

        if ($columnCount > 0) {
            $placeHolders = \implode(', ', \array_fill(0, $columnCount, '?'));

            $columns = '';

            foreach ($table->getTableMetaData()->getColumns() as $column) {
                $columns .= $connection->quoteSchemaObject($column) . ', ';
            }

            $columns = \substr($columns, 0, -2);

            $query = "
                INSERT INTO {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
                ({$columns})
                VALUES
                ({$placeHolders})
            ";

            return $query;
        }

        return false;
    }

    protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row)
    {
        $args = [];

        foreach ($table->getTableMetaData()->getColumns() as $columnName) {
            $args[] = $table->getValue($row, $columnName);
        }

        return $args;
    }

    protected function disablePrimaryKeys(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)
    {
        if (\count($databaseTableMetaData->getPrimaryKeys())) {
            return true;
        }

        return false;
    }
}


================================================
FILE: src/Operation/None.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\IDataSet;

/**
 * This class represents a null database operation.
 */
class None implements Operation
{
    public function execute(Connection $connection, IDataSet $dataSet): void
    {
        /* do nothing */
    }
}


================================================
FILE: src/Operation/Operation.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\IDataSet;

/**
 * Provides a basic interface and functionality for executing database
 * operations against a connection using a specific dataSet.
 */
interface Operation
{
    /**
     * Executes the database operation against the given $connection for the
     * given $dataSet.
     *
     * @param Connection $connection
     * @param IDataSet   $dataSet
     *
     * @throws Exception
     */
    public function execute(Connection $connection, IDataSet $dataSet);
}


================================================
FILE: src/Operation/Replace.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\DataSet\ITable;
use PHPUnit\DbUnit\DataSet\ITableMetadata;

/**
 * Updates the rows in a given dataset using primary key columns.
 */
class Replace extends RowBased
{
    protected $operationName = 'REPLACE';

    /**
     * @param Connection $connection
     * @param IDataSet   $dataSet
     */
    public function execute(Connection $connection, IDataSet $dataSet): void
    {
        $insertOperation = new Insert;
        $updateOperation = new Update;
        $databaseDataSet = $connection->createDataSet();

        foreach ($dataSet as $table) {
            /* @var $table ITable */
            $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());

            $insertQuery = $insertOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);
            $updateQuery = $updateOperation->buildOperationQuery($databaseTableMetaData, $table, $connection);
            $selectQuery = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);

            $insertStatement = $connection->getConnection()->prepare($insertQuery);
            $updateStatement = $connection->getConnection()->prepare($updateQuery);
            $selectStatement = $connection->getConnection()->prepare($selectQuery);

            $rowCount = $table->getRowCount();

            for ($i = 0; $i < $rowCount; $i++) {
                $selectArgs = $this->buildOperationArguments($databaseTableMetaData, $table, $i);
                $query      = $selectQuery;
                $args       = $selectArgs;

                try {
                    $selectStatement->execute($selectArgs);

                    if ($selectStatement->fetchColumn(0) > 0) {
                        $updateArgs = $updateOperation->buildOperationArguments($databaseTableMetaData, $table, $i);
                        $query      = $updateQuery;
                        $args       = $updateArgs;

                        $updateStatement->execute($updateArgs);
                    } else {
                        $insertArgs = $insertOperation->buildOperationArguments($databaseTableMetaData, $table, $i);
                        $query      = $insertQuery;
                        $args       = $insertArgs;

                        $insertStatement->execute($insertArgs);
                    }
                } catch (\Exception $e) {
                    throw new Exception(
                        $this->operationName,
                        $query,
                        $args,
                        $table,
                        $e->getMessage()
                    );
                }
            }
        }
    }

    protected function buildOperationQuery(ITableMetadata $databaseTableMetaData, ITable $table, Connection $connection)
    {
        $keys = $databaseTableMetaData->getPrimaryKeys();

        $whereStatement = 'WHERE ' . \implode(' AND ', $this->buildPreparedColumnArray($keys, $connection));

        $query = "
            SELECT COUNT(*)
            FROM {$connection->quoteSchemaObject($table->getTableMetaData()->getTableName())}
            {$whereStatement}
        ";

        return $query;
    }

    protected function buildOperationArguments(ITableMetadata $databaseTableMetaData, ITable $table, $row)
    {
        $args = [];

        foreach ($databaseTableMetaData->getPrimaryKeys() as $columnName) {
            $args[] = $table->getValue($row, $columnName);
        }

        return $args;
    }
}


================================================
FILE: src/Operation/RowBased.php
================================================
<?php
/*
 * This file is part of DbUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PHPUnit\DbUnit\Operation;

use PHPUnit\DbUnit\Database\Connection;
use PHPUnit\DbUnit\DataSet\IDataSet;
use PHPUnit\DbUnit\DataSet\ITable;
use PHPUnit\DbUnit\DataSet\ITableMetadata;

/**
 * Provides basic functionality for row based operations.
 *
 * To create a row based operation you must create two functions. The first
 * one, buildOperationQuery(), must return a query that will be used to create
 * a prepared statement. The second one, buildOperationArguments(), should
 * return an array containing arguments for each row.
 */
abstract class RowBased implements Operation
{
    const ITERATOR_TYPE_FORWARD = 0;
    const ITERATOR_TYPE_REVERSE = 1;

    protected $operationName;

    protected $iteratorDirection = self::ITERATOR_TYPE_FORWARD;

    /**
     * @param Connection $connection
     * @param IDataSet   $dataSet
     */
    public function execute(Connection $connection, IDataSet $dataSet): void
    {
        $databaseDataSet = $connection->createDataSet();

        $dsIterator = $this->iteratorDirection == self::ITERATOR_TYPE_REVERSE ? $dataSet->getReverseIterator() : $dataSet->getIterator();

        foreach ($dsIterator as $table) {
            $rowCount = $table->getRowCount();

            if ($rowCount == 0) {
                continue;
            }

            /* @var $table ITable */
            $databaseTableMetaData = $databaseDataSet->getTableMetaData($table->getTableMetaData()->getTableName());
            $query                 = $this->buildOperationQuery($databaseTableMetaData, $table, $connection);
            $disablePrimaryKeys    = $this->disablePrimaryKeys($databaseTableMetaData, $table, $connection);

            if ($query === false) {
                if ($table->getRowCount() > 0) {
                    throw new Exception($this->operationName, '', [], $table, 'Rows requested for insert, but no columns provided!');
                }

                continue;
            }

            if ($disablePrimaryKeys) {
                $connection->disablePrimaryKeys($databaseTableMetaData->getTableName());
            }

            $statement = $connection->getConnection()->prepare($query);

            for ($i = 0; $i < $rowCount; $i++) {
                $args = $this->buildOperationArguments($databaseTableMetaData, $table, $i);

                try {
                    $statement->execute($args);
                } catch (\Exception $e) {
                    throw new Exception(
                        $this->operationName,
                        $query,
                        $args,
                        $table,
                        $e->getMessage()
                    );
                }
            }

            if ($disablePrimaryKeys) {
                $connection->enablePrimaryKeys($databaseTableMetaData->getTableName());
            }
        }
    }

    /**
     * @return bool|string String containing the query or FALSE if a valid query cannot be construct
Download .txt
gitextract_j8io8xmv/

├── .gitattributes
├── .gitignore
├── .php_cs.dist
├── .travis.yml
├── ChangeLog.md
├── LICENSE
├── README.md
├── build.xml
├── composer.json
├── manifest.xml
├── phive.xml
├── phpunit-travis.xml
├── phpunit.xml
├── src/
│   ├── AbstractTester.php
│   ├── Constraint/
│   │   ├── DataSetIsEqual.php
│   │   ├── TableIsEqual.php
│   │   └── TableRowCount.php
│   ├── DataSet/
│   │   ├── AbstractDataSet.php
│   │   ├── AbstractTable.php
│   │   ├── AbstractTableMetadata.php
│   │   ├── AbstractXmlDataSet.php
│   │   ├── ArrayDataSet.php
│   │   ├── CompositeDataSet.php
│   │   ├── CsvDataSet.php
│   │   ├── DefaultDataSet.php
│   │   ├── DefaultTable.php
│   │   ├── DefaultTableIterator.php
│   │   ├── DefaultTableMetadata.php
│   │   ├── Filter.php
│   │   ├── FlatXmlDataSet.php
│   │   ├── IDataSet.php
│   │   ├── ITable.php
│   │   ├── ITableIterator.php
│   │   ├── ITableMetadata.php
│   │   ├── IYamlParser.php
│   │   ├── MysqlXmlDataSet.php
│   │   ├── QueryDataSet.php
│   │   ├── QueryTable.php
│   │   ├── ReplacementDataSet.php
│   │   ├── ReplacementTable.php
│   │   ├── ReplacementTableIterator.php
│   │   ├── Specification/
│   │   │   ├── Csv.php
│   │   │   ├── Factory.php
│   │   │   ├── FlatXml.php
│   │   │   ├── IFactory.php
│   │   │   ├── Query.php
│   │   │   ├── Specification.php
│   │   │   ├── Table.php
│   │   │   ├── Xml.php
│   │   │   └── Yaml.php
│   │   ├── SymfonyYamlParser.php
│   │   ├── TableFilter.php
│   │   ├── TableMetadataFilter.php
│   │   ├── XmlDataSet.php
│   │   └── YamlDataSet.php
│   ├── Database/
│   │   ├── Connection.php
│   │   ├── DataSet.php
│   │   ├── DefaultConnection.php
│   │   ├── FilteredDataSet.php
│   │   ├── Metadata/
│   │   │   ├── AbstractMetadata.php
│   │   │   ├── Dblib.php
│   │   │   ├── Firebird.php
│   │   │   ├── InformationSchema.php
│   │   │   ├── Metadata.php
│   │   │   ├── MySQL.php
│   │   │   ├── Oci.php
│   │   │   ├── PgSQL.php
│   │   │   ├── SqlSrv.php
│   │   │   ├── Sqlite.php
│   │   │   └── Table.php
│   │   ├── ResultSetTable.php
│   │   ├── Table.php
│   │   └── TableIterator.php
│   ├── DatabaseListConsumer.php
│   ├── DefaultTester.php
│   ├── Exception/
│   │   ├── Exception.php
│   │   ├── InvalidArgumentException.php
│   │   └── RuntimeException.php
│   ├── Operation/
│   │   ├── Composite.php
│   │   ├── Delete.php
│   │   ├── DeleteAll.php
│   │   ├── Exception.php
│   │   ├── Factory.php
│   │   ├── Insert.php
│   │   ├── None.php
│   │   ├── Operation.php
│   │   ├── Replace.php
│   │   ├── RowBased.php
│   │   ├── Truncate.php
│   │   └── Update.php
│   ├── TestCase.php
│   ├── TestCaseTrait.php
│   └── Tester.php
└── tests/
    ├── Constraint/
    │   └── TableRowCountTest.php
    ├── DB/
    │   └── DefaultDatabaseConnectionTest.php
    ├── DataSet/
    │   ├── AbstractTableTest.php
    │   ├── CompositeDataSetTest.php
    │   ├── CsvDataSetTest.php
    │   ├── FilterTest.php
    │   ├── QueryDataSetTest.php
    │   ├── QueryTableTest.php
    │   ├── ReplacementDataSetTest.php
    │   ├── ReplacementTableTest.php
    │   └── XmlDataSetsTest.php
    ├── Operation/
    │   ├── OperationsMySQLTest.php
    │   ├── OperationsTest.php
    │   └── RowBasedTest.php
    └── _files/
        ├── CsvDataSets/
        │   ├── table1.csv
        │   └── table2.csv
        ├── DatabaseTestUtility.php
        ├── XmlDataSets/
        │   ├── AllEmptyTableInsertResult.xml
        │   ├── AllEmptyTableInsertTest.xml
        │   ├── DeleteAllOperationTest.xml
        │   ├── DeleteOperationResult.xml
        │   ├── DeleteOperationTest.xml
        │   ├── EmptyTableInsertResult.xml
        │   ├── EmptyTableInsertTest.xml
        │   ├── FilteredTestComparison.xml
        │   ├── FilteredTestFixture.xml
        │   ├── FlatXmlDataSet.xml
        │   ├── FlatXmlWriter.xml
        │   ├── FlatXmlWriterEntities.xml
        │   ├── InsertOperationResult.xml
        │   ├── InsertOperationTest.xml
        │   ├── MysqlXmlDataSet.xml
        │   ├── OperationsMySQLTestFixture.xml
        │   ├── OperationsTestFixture.xml
        │   ├── QueryDataSetTest.xml
        │   ├── ReplaceOperationResult.xml
        │   ├── ReplaceOperationTest.xml
        │   ├── RowBasedExecute.xml
        │   ├── TruncateCompositeTest.xml
        │   ├── UpdateOperationResult.xml
        │   ├── UpdateOperationTest.xml
        │   ├── XmlDataSet.xml
        │   ├── XmlWriter.xml
        │   └── XmlWriterEntities.xml
        └── YamlDataSets/
            └── testDataSet.yaml
Download .txt
SYMBOL INDEX (527 symbols across 95 files)

FILE: src/AbstractTester.php
  class AbstractTester (line 21) | abstract class AbstractTester implements Tester
    method __construct (line 46) | public function __construct()
    method closeConnection (line 57) | public function closeConnection(Connection $connection): void
    method getDataSet (line 67) | public function getDataSet()
    method onSetUp (line 75) | public function onSetUp(): void
    method onTearDown (line 83) | public function onTearDown(): void
    method setDataSet (line 93) | public function setDataSet(IDataSet $dataSet): void
    method setSchema (line 103) | public function setSchema($schema): void
    method setSetUpOperation (line 113) | public function setSetUpOperation(Operation $setUpOperation): void
    method setTearDownOperation (line 123) | public function setTearDownOperation(Operation $tearDownOperation): void
    method getSchema (line 133) | protected function getSchema()
    method getSetUpOperation (line 143) | protected function getSetUpOperation()
    method getTearDownOperation (line 153) | protected function getTearDownOperation()

FILE: src/Constraint/DataSetIsEqual.php
  class DataSetIsEqual (line 20) | class DataSetIsEqual extends Constraint
    method __construct (line 37) | public function __construct(IDataSet $value)
    method toString (line 48) | public function toString(): string
    method matches (line 66) | protected function matches($other): bool
    method failureDescription (line 87) | protected function failureDescription($other): string

FILE: src/Constraint/TableIsEqual.php
  class TableIsEqual (line 20) | class TableIsEqual extends Constraint
    method __construct (line 37) | public function __construct(ITable $value)
    method toString (line 48) | public function toString(): string
    method matches (line 66) | protected function matches($other): bool
    method failureDescription (line 87) | protected function failureDescription($other): string

FILE: src/Constraint/TableRowCount.php
  class TableRowCount (line 18) | class TableRowCount extends Constraint
    method __construct (line 36) | public function __construct($tableName, $value)
    method toString (line 48) | public function toString(): string
    method matches (line 63) | protected function matches($other): bool

FILE: src/DataSet/AbstractDataSet.php
  class AbstractDataSet (line 16) | abstract class AbstractDataSet implements IDataSet
    method __toString (line 18) | public function __toString()
    method getTableNames (line 36) | public function getTableNames()
    method getTableMetaData (line 55) | public function getTableMetaData($tableName)
    method getTable (line 67) | public function getTable($tableName)
    method getIterator (line 82) | public function getIterator()
    method getReverseIterator (line 92) | public function getReverseIterator()
    method matches (line 102) | public function matches(IDataSet $other)
    method createIterator (line 133) | abstract protected function createIterator($reverse = false);

FILE: src/DataSet/AbstractTable.php
  class AbstractTable (line 19) | class AbstractTable implements ITable
    method __toString (line 38) | public function __toString()
    method getTableMetaData (line 96) | public function getTableMetaData()
    method getRowCount (line 106) | public function getRowCount()
    method getValue (line 119) | public function getValue($row, $column)
    method getRow (line 141) | public function getRow($row)
    method matches (line 159) | public function matches(ITable $other)
    method assertContainsRow (line 202) | public function assertContainsRow(array $row)
    method setTableMetaData (line 214) | protected function setTableMetaData(ITableMetadata $tableMetaData): void
    method rowToString (line 219) | protected function rowToString(array $row)

FILE: src/DataSet/AbstractTableMetadata.php
  class AbstractTableMetadata (line 16) | abstract class AbstractTableMetadata implements ITableMetadata
    method getColumns (line 42) | public function getColumns()
    method getPrimaryKeys (line 52) | public function getPrimaryKeys()
    method getTableName (line 62) | public function getTableName()
    method matches (line 72) | public function matches(ITableMetadata $other)

FILE: src/DataSet/AbstractXmlDataSet.php
  class AbstractXmlDataSet (line 20) | abstract class AbstractXmlDataSet extends AbstractDataSet
    method __construct (line 38) | public function __construct($xmlFile)
    method getTableInfo (line 75) | abstract protected function getTableInfo(array &$tableColumns, array &...
    method createTables (line 77) | protected function createTables(array &$tableColumns, array &$tableVal...
    method getOrCreateTable (line 97) | protected function getOrCreateTable($tableName, $tableColumns)
    method createIterator (line 115) | protected function createIterator($reverse = false)

FILE: src/DataSet/ArrayDataSet.php
  class ArrayDataSet (line 18) | class ArrayDataSet extends AbstractDataSet
    method __construct (line 41) | public function __construct(array $data)
    method getTable (line 60) | public function getTable($tableName)
    method createIterator (line 69) | protected function createIterator($reverse = false)

FILE: src/DataSet/CompositeDataSet.php
  class CompositeDataSet (line 20) | class CompositeDataSet extends AbstractDataSet
    method __construct (line 33) | public function __construct(array $dataSets = [])
    method addDataSet (line 49) | public function addDataSet(IDataSet $dataSet): void
    method createIterator (line 75) | protected function createIterator($reverse = false)

FILE: src/DataSet/CsvDataSet.php
  class CsvDataSet (line 20) | class CsvDataSet extends AbstractDataSet
    method __construct (line 51) | public function __construct($delimiter = ',', $enclosure = '"', $escap...
    method addTable (line 67) | public function addTable($tableName, $csvFile): void
    method createIterator (line 109) | protected function createIterator($reverse = false)
    method getCsvRow (line 121) | protected function getCsvRow($fh)

FILE: src/DataSet/DefaultDataSet.php
  class DefaultDataSet (line 16) | class DefaultDataSet extends AbstractDataSet
    method __construct (line 30) | public function __construct(array $tables = [])
    method addTable (line 40) | public function addTable(ITable $table): void
    method createIterator (line 53) | protected function createIterator($reverse = false)

FILE: src/DataSet/DefaultTable.php
  class DefaultTable (line 18) | class DefaultTable extends AbstractTable
    method __construct (line 25) | public function __construct(ITableMetadata $tableMetaData)
    method addRow (line 36) | public function addRow($values = []): void
    method addTableRows (line 49) | public function addTableRows(ITable $table): void
    method setValue (line 71) | public function setValue($row, $column, $value): void

FILE: src/DataSet/DefaultTableIterator.php
  class DefaultTableIterator (line 16) | class DefaultTableIterator implements ITableIterator
    method __construct (line 39) | public function __construct(array $tables, $reverse = false)
    method getTable (line 52) | public function getTable()
    method getTableMetaData (line 62) | public function getTableMetaData()
    method current (line 72) | public function current()
    method key (line 82) | public function key()
    method next (line 90) | public function next(): void
    method rewind (line 102) | public function rewind(): void
    method valid (line 116) | public function valid()

FILE: src/DataSet/DefaultTableMetadata.php
  class DefaultTableMetadata (line 18) | class DefaultTableMetadata extends AbstractTableMetadata
    method __construct (line 27) | public function __construct($tableName, array $columns, array $primary...

FILE: src/DataSet/Filter.php
  class Filter (line 17) | class Filter extends AbstractDataSet
    method __construct (line 65) | public function __construct(IDataSet $originalDataSet, array $excludeT...
    method addIncludeTables (line 89) | public function addIncludeTables(array $tables): void
    method addExcludeTables (line 99) | public function addExcludeTables(array $tables): void
    method setIncludeColumnsForTable (line 110) | public function setIncludeColumnsForTable($table, array $columns): void
    method setExcludeColumnsForTable (line 121) | public function setExcludeColumnsForTable($table, array $columns): void
    method createIterator (line 134) | protected function createIterator($reverse = false)

FILE: src/DataSet/FlatXmlDataSet.php
  class FlatXmlDataSet (line 18) | class FlatXmlDataSet extends AbstractXmlDataSet
    method getTableInfo (line 20) | protected function getTableInfo(array &$tableColumns, array &$tableVal...

FILE: src/DataSet/IDataSet.php
  type IDataSet (line 18) | interface IDataSet extends IteratorAggregate
    method getTableNames (line 25) | public function getTableNames();
    method getTableMetaData (line 34) | public function getTableMetaData($tableName);
    method getTable (line 43) | public function getTable($tableName);
    method getReverseIterator (line 50) | public function getReverseIterator();
    method matches (line 57) | public function matches(self $other);

FILE: src/DataSet/ITable.php
  type ITable (line 16) | interface ITable
    method getTableMetaData (line 23) | public function getTableMetaData();
    method getRowCount (line 30) | public function getRowCount();
    method getValue (line 38) | public function getValue($row, $column);
    method getRow (line 47) | public function getRow($row);
    method matches (line 54) | public function matches(self $other);

FILE: src/DataSet/ITableIterator.php
  type ITableIterator (line 18) | interface ITableIterator extends Iterator
    method getTable (line 25) | public function getTable();
    method getTableMetaData (line 32) | public function getTableMetaData();

FILE: src/DataSet/ITableMetadata.php
  type ITableMetadata (line 16) | interface ITableMetadata
    method getColumns (line 23) | public function getColumns();
    method getPrimaryKeys (line 30) | public function getPrimaryKeys();
    method getTableName (line 37) | public function getTableName();
    method matches (line 44) | public function matches(self $other);

FILE: src/DataSet/IYamlParser.php
  type IYamlParser (line 16) | interface IYamlParser
    method parseYaml (line 23) | public function parseYaml($yamlFile);

FILE: src/DataSet/MysqlXmlDataSet.php
  class MysqlXmlDataSet (line 18) | class MysqlXmlDataSet extends AbstractXmlDataSet
    method getTableInfo (line 20) | protected function getTableInfo(array &$tableColumns, array &$tableVal...

FILE: src/DataSet/QueryDataSet.php
  class QueryDataSet (line 21) | class QueryDataSet extends AbstractDataSet
    method __construct (line 42) | public function __construct(Connection $databaseConnection)
    method addTable (line 47) | public function addTable($tableName, $query = null): void
    method getTable (line 63) | public function getTable($tableName)
    method getTableNames (line 77) | public function getTableNames()
    method createIterator (line 90) | protected function createIterator($reverse = false)

FILE: src/DataSet/QueryTable.php
  class QueryTable (line 19) | class QueryTable extends AbstractTable
    method __construct (line 44) | public function __construct($tableName, $query, Connection $databaseCo...
    method getTableMetaData (line 56) | public function getTableMetaData()
    method assertContainsRow (line 70) | public function assertContainsRow(array $row)
    method getRowCount (line 82) | public function getRowCount()
    method getValue (line 95) | public function getValue($row, $column)
    method getRow (line 109) | public function getRow($row)
    method matches (line 121) | public function matches(ITable $other)
    method loadData (line 128) | protected function loadData(): void
    method createTableMetaData (line 136) | protected function createTableMetaData(): void

FILE: src/DataSet/ReplacementDataSet.php
  class ReplacementDataSet (line 18) | class ReplacementDataSet extends AbstractDataSet
    method __construct (line 44) | public function __construct(IDataSet $dataSet, array $fullReplacements...
    method addFullReplacement (line 59) | public function addFullReplacement($value, $replacement): void
    method addSubStrReplacement (line 72) | public function addSubStrReplacement($value, $replacement): void
    method createIterator (line 85) | protected function createIterator($reverse = false)

FILE: src/DataSet/ReplacementTable.php
  class ReplacementTable (line 18) | class ReplacementTable implements ITable
    method __construct (line 42) | public function __construct(ITable $table, array $fullReplacements = [...
    method __toString (line 49) | public function __toString()
    method addFullReplacement (line 86) | public function addFullReplacement($value, $replacement): void
    method addSubStrReplacement (line 99) | public function addSubStrReplacement($value, $replacement): void
    method getTableMetaData (line 109) | public function getTableMetaData()
    method getRowCount (line 119) | public function getRowCount()
    method getValue (line 130) | public function getValue($row, $column)
    method getRow (line 142) | public function getRow($row)
    method matches (line 154) | public function matches(ITable $other)
    method rowToString (line 186) | protected function rowToString(array $row)
    method getReplacedValue (line 201) | protected function getReplacedValue($value)

FILE: src/DataSet/ReplacementTableIterator.php
  class ReplacementTableIterator (line 18) | class ReplacementTableIterator implements OuterIterator, ITableIterator
    method __construct (line 42) | public function __construct(ITableIterator $innerIterator, array $full...
    method addFullReplacement (line 57) | public function addFullReplacement($value, $replacement): void
    method addSubStrReplacement (line 70) | public function addSubStrReplacement($value, $replacement): void
    method getTable (line 80) | public function getTable()
    method getTableMetaData (line 90) | public function getTableMetaData()
    method current (line 100) | public function current()
    method key (line 110) | public function key()
    method next (line 118) | public function next(): void
    method rewind (line 126) | public function rewind(): void
    method valid (line 136) | public function valid()
    method getInnerIterator (line 141) | public function getInnerIterator()

FILE: src/DataSet/Specification/Csv.php
  class Csv (line 30) | class Csv implements Specification
    method getDataSet (line 39) | public function getDataSet($dataSetSpec)
    method getCsvOptions (line 63) | protected function getCsvOptions($dataSetSpec)
    method getTableFileMap (line 81) | protected function getTableFileMap($dataSetSpec)

FILE: src/DataSet/Specification/Factory.php
  class Factory (line 18) | class Factory implements IFactory
    method getDataSetSpecByType (line 27) | public function getDataSetSpecByType($type)

FILE: src/DataSet/Specification/FlatXml.php
  class FlatXml (line 25) | class FlatXml implements Specification
    method getDataSet (line 34) | public function getDataSet($dataSetSpec)

FILE: src/DataSet/Specification/IFactory.php
  type IFactory (line 16) | interface IFactory
    method getDataSetSpecByType (line 25) | public function getDataSetSpecByType($type);

FILE: src/DataSet/Specification/Query.php
  class Query (line 41) | class Query implements Specification, DatabaseListConsumer
    method setDatabases (line 53) | public function setDatabases(array $databases): void
    method getDataSet (line 65) | public function getDataSet($dataSetSpec)

FILE: src/DataSet/Specification/Specification.php
  type Specification (line 18) | interface Specification
    method getDataSet (line 27) | public function getDataSet($dataSetSpec);

FILE: src/DataSet/Specification/Table.php
  class Table (line 40) | class Table implements Specification, DatabaseListConsumer
    method setDatabases (line 52) | public function setDatabases(array $databases): void
    method getDataSet (line 64) | public function getDataSet($dataSetSpec)

FILE: src/DataSet/Specification/Xml.php
  class Xml (line 25) | class Xml implements Specification
    method getDataSet (line 34) | public function getDataSet($dataSetSpec)

FILE: src/DataSet/Specification/Yaml.php
  class Yaml (line 25) | class Yaml implements Specification
    method getDataSet (line 34) | public function getDataSet($dataSetSpec)

FILE: src/DataSet/SymfonyYamlParser.php
  class SymfonyYamlParser (line 18) | class SymfonyYamlParser implements IYamlParser
    method parseYaml (line 20) | public function parseYaml($yamlFile)

FILE: src/DataSet/TableFilter.php
  class TableFilter (line 18) | class TableFilter extends AbstractTable
    method __construct (line 33) | public function __construct(ITable $originalTable, array $excludeColum...
    method getRow (line 47) | public function getRow($row)
    method getRowCount (line 59) | public function getRowCount()
    method getValue (line 72) | public function getValue($row, $column)
    method addIncludeColumns (line 86) | public function addIncludeColumns(array $includeColumns): void
    method clearIncludeColumns (line 94) | public function clearIncludeColumns(): void
    method addExcludeColumns (line 104) | public function addExcludeColumns(array $excludeColumns): void
    method clearExcludeColumns (line 112) | public function clearExcludeColumns(): void
    method assertContainsRow (line 124) | public function assertContainsRow(array $row)
    method loadData (line 134) | protected function loadData(): void

FILE: src/DataSet/TableMetadataFilter.php
  class TableMetadataFilter (line 20) | class TableMetadataFilter extends AbstractTableMetadata
    method __construct (line 50) | public function __construct(ITableMetadata $originalMetaData, array $e...
    method getColumns (line 61) | public function getColumns()
    method getPrimaryKeys (line 79) | public function getPrimaryKeys()
    method getTableName (line 89) | public function getTableName()
    method addIncludeColumns (line 99) | public function addIncludeColumns(array $includeColumns): void
    method clearIncludeColumns (line 107) | public function clearIncludeColumns(): void
    method addExcludeColumns (line 117) | public function addExcludeColumns(array $excludeColumns): void
    method clearExcludeColumns (line 125) | public function clearExcludeColumns(): void

FILE: src/DataSet/XmlDataSet.php
  class XmlDataSet (line 18) | class XmlDataSet extends AbstractXmlDataSet
    method getTableInfo (line 20) | protected function getTableInfo(array &$tableColumns, array &$tableVal...

FILE: src/DataSet/YamlDataSet.php
  class YamlDataSet (line 18) | class YamlDataSet extends AbstractDataSet
    method __construct (line 36) | public function __construct($yamlFile, $parser = null)
    method addYamlFile (line 50) | public function addYamlFile($yamlFile): void
    method createIterator (line 90) | protected function createIterator($reverse = false)
    method getColumns (line 110) | private function getColumns($rows)

FILE: src/Database/Connection.php
  type Connection (line 21) | interface Connection
    method close (line 26) | public function close();
    method createDataSet (line 37) | public function createDataSet(array $tableNames = null);
    method createQueryTable (line 47) | public function createQueryTable($resultName, $sql);
    method getConnection (line 54) | public function getConnection();
    method getMetaData (line 62) | public function getMetaData();
    method getRowCount (line 72) | public function getRowCount($tableName, $whereClause = null);
    method getSchema (line 79) | public function getSchema();
    method quoteSchemaObject (line 88) | public function quoteSchemaObject($object);
    method getTruncateCommand (line 95) | public function getTruncateCommand();
    method allowsCascading (line 102) | public function allowsCascading();
    method disablePrimaryKeys (line 109) | public function disablePrimaryKeys($tableName);
    method enablePrimaryKeys (line 116) | public function enablePrimaryKeys($tableName);

FILE: src/Database/DataSet.php
  class DataSet (line 22) | class DataSet extends AbstractDataSet
    method buildTableSelect (line 45) | public static function buildTableSelect(ITableMetadata $tableMetaData,...
    method __construct (line 87) | public function __construct(Connection $databaseConnection)
    method getTable (line 99) | public function getTable($tableName)
    method getTableMetaData (line 119) | public function getTableMetaData($tableName)
    method getTableNames (line 129) | public function getTableNames()
    method createIterator (line 142) | protected function createIterator($reverse = false)

FILE: src/Database/DefaultConnection.php
  class DefaultConnection (line 22) | class DefaultConnection implements Connection
    method __construct (line 42) | public function __construct(PDO $connection, $schema = '')
    method close (line 52) | public function close(): void
    method getMetaData (line 63) | public function getMetaData()
    method getSchema (line 73) | public function getSchema()
    method createDataSet (line 89) | public function createDataSet(array $tableNames = null)
    method createQueryTable (line 106) | public function createQueryTable($resultName, $sql)
    method getConfig (line 114) | public function getConfig(): void
    method getConnection (line 123) | public function getConnection()
    method getRowCount (line 137) | public function getRowCount($tableName, $whereClause = null)
    method quoteSchemaObject (line 155) | public function quoteSchemaObject($object)
    method getTruncateCommand (line 165) | public function getTruncateCommand()
    method allowsCascading (line 175) | public function allowsCascading()
    method disablePrimaryKeys (line 185) | public function disablePrimaryKeys($tableName): void
    method enablePrimaryKeys (line 195) | public function enablePrimaryKeys($tableName): void

FILE: src/Database/FilteredDataSet.php
  class FilteredDataSet (line 16) | class FilteredDataSet extends DataSet
    method __construct (line 28) | public function __construct(Connection $databaseConnection, array $tab...
    method getTableNames (line 39) | public function getTableNames()

FILE: src/Database/Metadata/AbstractMetadata.php
  class AbstractMetadata (line 21) | abstract class AbstractMetadata implements Metadata
    method createMetaData (line 67) | public static function createMetaData(PDO $pdo, $schema = '')
    method registerClassWithDriver (line 97) | public static function registerClassWithDriver($className, $pdoDriver)
    method __construct (line 119) | final public function __construct(PDO $pdo, $schema = '')
    method getSchema (line 130) | public function getSchema()
    method quoteSchemaObject (line 142) | public function quoteSchemaObject($object)
    method splitTableName (line 165) | public function splitTableName($fullTableName)
    method getTruncateCommand (line 185) | public function getTruncateCommand()
    method allowsCascading (line 195) | public function allowsCascading()
    method disablePrimaryKeys (line 205) | public function disablePrimaryKeys($tableName): void
    method enablePrimaryKeys (line 215) | public function enablePrimaryKeys($tableName): void

FILE: src/Database/Metadata/Dblib.php
  class Dblib (line 16) | class Dblib extends AbstractMetadata
    method getTableNames (line 47) | public function getTableNames()
    method getTableColumns (line 72) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 89) | public function getTablePrimaryKeys($tableName)
    method loadColumnInfo (line 103) | protected function loadColumnInfo($tableName): void

FILE: src/Database/Metadata/Firebird.php
  class Firebird (line 16) | class Firebird extends AbstractMetadata
    method getTableNames (line 30) | public function getTableNames()
    method getTableColumns (line 73) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 90) | public function getTablePrimaryKeys($tableName)
    method getSchema (line 104) | public function getSchema()
    method allowsCascading (line 118) | public function allowsCascading()
    method quoteSchemaObject (line 130) | public function quoteSchemaObject($object)
    method loadColumnInfo (line 140) | protected function loadColumnInfo($tableName): void

FILE: src/Database/Metadata/InformationSchema.php
  class InformationSchema (line 16) | class InformationSchema extends AbstractMetadata
    method getTableNames (line 27) | public function getTableNames()
    method getTableColumns (line 59) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 76) | public function getTablePrimaryKeys($tableName)
    method loadColumnInfo (line 90) | protected function loadColumnInfo($tableName): void

FILE: src/Database/Metadata/Metadata.php
  type Metadata (line 16) | interface Metadata
    method getTableNames (line 23) | public function getTableNames();
    method getTableColumns (line 33) | public function getTableColumns($tableName);
    method getTablePrimaryKeys (line 43) | public function getTablePrimaryKeys($tableName);
    method getSchema (line 50) | public function getSchema();
    method quoteSchemaObject (line 59) | public function quoteSchemaObject($object);
    method allowsCascading (line 66) | public function allowsCascading();
    method disablePrimaryKeys (line 73) | public function disablePrimaryKeys($tableName);
    method enablePrimaryKeys (line 80) | public function enablePrimaryKeys($tableName);

FILE: src/Database/Metadata/MySQL.php
  class MySQL (line 18) | class MySQL extends AbstractMetadata
    method getTableNames (line 27) | public function getTableNames()
    method getTableColumns (line 50) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 73) | public function getTablePrimaryKeys($tableName)

FILE: src/Database/Metadata/Oci.php
  class Oci (line 16) | class Oci extends AbstractMetadata
    method getTableNames (line 47) | public function getTableNames()
    method getTableColumns (line 73) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 90) | public function getTablePrimaryKeys($tableName)
    method loadColumnInfo (line 104) | protected function loadColumnInfo($tableName): void

FILE: src/Database/Metadata/PgSQL.php
  class PgSQL (line 16) | class PgSQL extends AbstractMetadata
    method getTableNames (line 23) | public function getTableNames()
    method getTableColumns (line 55) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 72) | public function getTablePrimaryKeys($tableName)
    method getSchema (line 86) | public function getSchema()
    method allowsCascading (line 100) | public function allowsCascading()
    method loadColumnInfo (line 110) | protected function loadColumnInfo($tableName): void

FILE: src/Database/Metadata/SqlSrv.php
  class SqlSrv (line 19) | class SqlSrv extends AbstractMetadata
    method getTableNames (line 40) | public function getTableNames()
    method getTableColumns (line 66) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 93) | public function getTablePrimaryKeys($tableName)
    method disablePrimaryKeys (line 116) | public function disablePrimaryKeys($tableName): void
    method enablePrimaryKeys (line 131) | public function enablePrimaryKeys($tableName): void

FILE: src/Database/Metadata/Sqlite.php
  class Sqlite (line 19) | class Sqlite extends AbstractMetadata
    method getTableNames (line 32) | public function getTableNames()
    method getTableColumns (line 62) | public function getTableColumns($tableName)
    method getTablePrimaryKeys (line 79) | public function getTablePrimaryKeys($tableName)
    method loadColumnInfo (line 93) | protected function loadColumnInfo($tableName): void

FILE: src/Database/Metadata/Table.php
  class Table (line 18) | class Table extends DefaultTableMetadata
    method __construct (line 20) | public function __construct($tableName, Metadata $databaseMetaData)

FILE: src/Database/ResultSetTable.php
  class ResultSetTable (line 26) | class ResultSetTable extends AbstractTable
    method __construct (line 34) | public function __construct($tableName, PDOStatement $pdoStatement)

FILE: src/Database/Table.php
  class Table (line 20) | class Table extends AbstractTable
    method __construct (line 28) | public function __construct(ITableMetadata $tableMetaData, Connection ...

FILE: src/Database/TableIterator.php
  class TableIterator (line 20) | class TableIterator implements ITableIterator
    method __construct (line 44) | public function __construct($tableNames, DataSet $dataSet, $reverse = ...
    method getTable (line 58) | public function getTable()
    method getTableMetaData (line 68) | public function getTableMetaData()
    method current (line 78) | public function current()
    method key (line 90) | public function key()
    method next (line 98) | public function next(): void
    method rewind (line 110) | public function rewind(): void
    method valid (line 124) | public function valid()

FILE: src/DatabaseListConsumer.php
  type DatabaseListConsumer (line 16) | interface DatabaseListConsumer
    method setDatabases (line 23) | public function setDatabases(array $databases);

FILE: src/DefaultTester.php
  class DefaultTester (line 19) | class DefaultTester extends AbstractTester
    method __construct (line 31) | public function __construct(Connection $connection)
    method getConnection (line 43) | public function getConnection()

FILE: src/Exception/Exception.php
  type Exception (line 13) | interface Exception

FILE: src/Exception/InvalidArgumentException.php
  class InvalidArgumentException (line 13) | class InvalidArgumentException extends \InvalidArgumentException impleme...

FILE: src/Exception/RuntimeException.php
  class RuntimeException (line 13) | class RuntimeException extends \RuntimeException implements Exception

FILE: src/Operation/Composite.php
  class Composite (line 23) | class Composite implements Operation
    method __construct (line 35) | public function __construct(array $operations)
    method execute (line 46) | public function execute(Connection $connection, IDataSet $dataSet): void

FILE: src/Operation/Delete.php
  class Delete (line 20) | class Delete extends RowBased
    method buildOperationQuery (line 26) | protected function buildOperationQuery(ITableMetadata $databaseTableMe...
    method buildOperationArguments (line 40) | protected function buildOperationArguments(ITableMetadata $databaseTab...

FILE: src/Operation/DeleteAll.php
  class DeleteAll (line 21) | class DeleteAll implements Operation
    method execute (line 23) | public function execute(Connection $connection, IDataSet $dataSet): void

FILE: src/Operation/Exception.php
  class Exception (line 21) | class Exception extends RuntimeException
    method __construct (line 57) | public function __construct($operation, $current_query, $current_args,...
    method getOperation (line 68) | public function getOperation()
    method getQuery (line 73) | public function getQuery()
    method getTable (line 78) | public function getTable()
    method getArgs (line 83) | public function getArgs()
    method getError (line 88) | public function getError()

FILE: src/Operation/Factory.php
  class Factory (line 16) | class Factory
    method NONE (line 23) | public static function NONE()
    method CLEAN_INSERT (line 36) | public static function CLEAN_INSERT($cascadeTruncates = false)
    method INSERT (line 49) | public static function INSERT()
    method TRUNCATE (line 61) | public static function TRUNCATE($cascadeTruncates = false)
    method DELETE (line 74) | public static function DELETE()
    method DELETE_ALL (line 84) | public static function DELETE_ALL()
    method UPDATE (line 94) | public static function UPDATE()

FILE: src/Operation/Insert.php
  class Insert (line 20) | class Insert extends RowBased
    method buildOperationQuery (line 24) | protected function buildOperationQuery(ITableMetadata $databaseTableMe...
    method buildOperationArguments (line 52) | protected function buildOperationArguments(ITableMetadata $databaseTab...
    method disablePrimaryKeys (line 63) | protected function disablePrimaryKeys(ITableMetadata $databaseTableMet...

FILE: src/Operation/None.php
  class None (line 19) | class None implements Operation
    method execute (line 21) | public function execute(Connection $connection, IDataSet $dataSet): void

FILE: src/Operation/Operation.php
  type Operation (line 20) | interface Operation
    method execute (line 31) | public function execute(Connection $connection, IDataSet $dataSet);

FILE: src/Operation/Replace.php
  class Replace (line 21) | class Replace extends RowBased
    method execute (line 29) | public function execute(Connection $connection, IDataSet $dataSet): void
    method buildOperationQuery (line 83) | protected function buildOperationQuery(ITableMetadata $databaseTableMe...
    method buildOperationArguments (line 98) | protected function buildOperationArguments(ITableMetadata $databaseTab...

FILE: src/Operation/RowBased.php
  class RowBased (line 26) | abstract class RowBased implements Operation
    method execute (line 39) | public function execute(Connection $connection, IDataSet $dataSet): void
    method buildOperationQuery (line 96) | abstract protected function buildOperationQuery(ITableMetadata $databa...
    method buildOperationArguments (line 98) | abstract protected function buildOperationArguments(ITableMetadata $da...
    method disablePrimaryKeys (line 107) | protected function disablePrimaryKeys(ITableMetadata $databaseTableMet...
    method buildPreparedColumnArray (line 112) | protected function buildPreparedColumnArray($columns, Connection $conn...

FILE: src/Operation/Truncate.php
  class Truncate (line 22) | class Truncate implements Operation
    method setCascade (line 26) | public function setCascade($cascade = true): void
    method execute (line 31) | public function execute(Connection $connection, IDataSet $dataSet): void
    method disableForeignKeyChecksForMysql (line 59) | private function disableForeignKeyChecksForMysql(Connection $connectio...
    method enableForeignKeyChecksForMysql (line 67) | private function enableForeignKeyChecksForMysql(Connection $connection...
    method isMysql (line 74) | private function isMysql(Connection $connection)

FILE: src/Operation/Update.php
  class Update (line 20) | class Update extends RowBased
    method buildOperationQuery (line 24) | protected function buildOperationQuery(ITableMetadata $databaseTableMe...
    method buildOperationArguments (line 40) | protected function buildOperationArguments(ITableMetadata $databaseTab...
    method disablePrimaryKeys (line 55) | protected function disablePrimaryKeys(ITableMetadata $databaseTableMet...

FILE: src/TestCase.php
  class TestCase (line 17) | abstract class TestCase extends \PHPUnit\Framework\TestCase

FILE: src/TestCaseTrait.php
  type TestCaseTrait (line 28) | trait TestCaseTrait
    method assertTablesEqual (line 42) | public static function assertTablesEqual(ITable $expected, ITable $act...
    method assertDataSetsEqual (line 56) | public static function assertDataSetsEqual(IDataSet $expected, IDataSe...
    method setUp (line 66) | protected function setUp(): void
    method tearDown (line 80) | protected function tearDown(): void
    method assertTableRowCount (line 102) | public function assertTableRowCount($tableName, $expected, $message = ...
    method assertTableContains (line 117) | public function assertTableContains(array $expectedRow, ITable $table,...
    method closeConnection (line 127) | protected function closeConnection(Connection $connection): void
    method getConnection (line 137) | abstract protected function getConnection();
    method getDatabaseTester (line 146) | protected function getDatabaseTester()
    method getDataSet (line 160) | abstract protected function getDataSet();
    method getSetUpOperation (line 167) | protected function getSetUpOperation()
    method getTearDownOperation (line 177) | protected function getTearDownOperation()
    method newDatabaseTester (line 187) | protected function newDatabaseTester()
    method createDefaultDBConnection (line 201) | protected function createDefaultDBConnection(PDO $connection, $schema ...
    method createArrayDataSet (line 224) | protected function createArrayDataSet(array $data)
    method createFlatXMLDataSet (line 236) | protected function createFlatXMLDataSet($xmlFile)
    method createXMLDataSet (line 248) | protected function createXMLDataSet($xmlFile)
    method createMySQLXMLDataSet (line 260) | protected function createMySQLXMLDataSet($xmlFile)
    method getOperations (line 271) | protected function getOperations()

FILE: src/Tester.php
  type Tester (line 22) | interface Tester
    method closeConnection (line 29) | public function closeConnection(Connection $connection);
    method getConnection (line 36) | public function getConnection();
    method getDataSet (line 43) | public function getDataSet();
    method onSetUp (line 48) | public function onSetUp();
    method onTearDown (line 53) | public function onTearDown();
    method setDataSet (line 60) | public function setDataSet(IDataSet $dataSet);
    method setSchema (line 67) | public function setSchema($schema);
    method setSetUpOperation (line 74) | public function setSetUpOperation(Operation $setUpOperation);
    method setTearDownOperation (line 81) | public function setTearDownOperation(Operation $tearDownOperation);

FILE: tests/Constraint/TableRowCountTest.php
  class Extensions_Database_Constraint_TableRowCountTest (line 15) | class Extensions_Database_Constraint_TableRowCountTest extends TestCase
    method testConstraint (line 17) | public function testConstraint(): void

FILE: tests/DB/DefaultDatabaseConnectionTest.php
  class DefaultDatabaseConnectionTest (line 13) | class DefaultDatabaseConnectionTest extends TestCase
    method setUp (line 17) | protected function setUp(): void
    method testRowCountForEmptyTableReturnsZero (line 24) | public function testRowCountForEmptyTableReturnsZero(): void
    method testRowCountForTableWithTwoRowsReturnsTwo (line 30) | public function testRowCountForTableWithTwoRowsReturnsTwo(): void

FILE: tests/DataSet/AbstractTableTest.php
  class Extensions_Database_DataSet_AbstractTableTest (line 18) | class Extensions_Database_DataSet_AbstractTableTest extends TestCase
    method setUp (line 25) | public function setUp(): void
    method testTableContainsRow (line 45) | public function testTableContainsRow($row, $exists): void
    method providerTableContainsRow (line 51) | public function providerTableContainsRow()
    method testMatchesWithNonMatchingMetaData (line 59) | public function testMatchesWithNonMatchingMetaData(): void
    method testMatchesWithNonMatchingRowCount (line 78) | public function testMatchesWithNonMatchingRowCount(): void
    method testMatchesWithColumnValueComparisons (line 113) | public function testMatchesWithColumnValueComparisons($tableColumnValu...
    method providerMatchesWithColumnValueComparisons (line 162) | public function providerMatchesWithColumnValueComparisons()

FILE: tests/DataSet/CompositeDataSetTest.php
  class Extensions_Database_DataSet_CompositeDataSetTest (line 17) | class Extensions_Database_DataSet_CompositeDataSetTest extends \PHPUnit\...
    method setUp (line 23) | public function setUp(): void
    method testCompositeDataSet (line 115) | public function testCompositeDataSet(): void
    method testCompatibleTablesInDifferentDataSetsNonDuplicateRows (line 122) | public function testCompatibleTablesInDifferentDataSetsNonDuplicateRow...
    method testExceptionOnIncompatibleTablesSameTableNames (line 148) | public function testExceptionOnIncompatibleTablesSameTableNames(): void
    method testExceptionOnIncompatibleTablesSameTableNames2 (line 173) | public function testExceptionOnIncompatibleTablesSameTableNames2(): void

FILE: tests/DataSet/CsvDataSetTest.php
  class Extensions_Database_DataSet_CsvDataSetTest (line 17) | class Extensions_Database_DataSet_CsvDataSetTest extends \PHPUnit\Framew...
    method testCSVDataSet (line 21) | public function testCSVDataSet(): void

FILE: tests/DataSet/FilterTest.php
  class Extensions_Database_DataSet_FilterTest (line 16) | class Extensions_Database_DataSet_FilterTest extends TestCase
    method setUp (line 20) | public function setUp(): void
    method testDeprecatedFilteredDataSetConstructor (line 27) | public function testDeprecatedFilteredDataSetConstructor(): void
    method testExcludeFilteredDataSet (line 43) | public function testExcludeFilteredDataSet(): void
    method testIncludeFilteredDataSet (line 59) | public function testIncludeFilteredDataSet(): void
    method testIncludeExcludeMixedDataSet (line 75) | public function testIncludeExcludeMixedDataSet(): void

FILE: tests/DataSet/QueryDataSetTest.php
  class Extensions_Database_DataSet_QueryDataSetTest (line 18) | class Extensions_Database_DataSet_QueryDataSetTest extends TestCase
    method setUp (line 27) | public function setUp(): void
    method testGetTable (line 42) | public function testGetTable(): void
    method testGetTableNames (line 56) | public function testGetTableNames(): void
    method testCreateIterator (line 61) | public function testCreateIterator(): void
    method getConnection (line 91) | protected function getConnection()
    method getDataSet (line 96) | protected function getDataSet()

FILE: tests/DataSet/QueryTableTest.php
  class Extensions_Database_DataSet_QueryTableTest (line 17) | class Extensions_Database_DataSet_QueryTableTest extends TestCase
    method providerTestGetValue (line 24) | public static function providerTestGetValue()
    method setUp (line 36) | public function setUp(): void
    method testGetEmptyTableMetaData (line 55) | public function testGetEmptyTableMetaData(): void
    method testGetTableMetaData (line 84) | public function testGetTableMetaData(): void
    method testGetRowCount (line 91) | public function testGetRowCount(): void
    method testGetValue (line 103) | public function testGetValue($row, $column, $value): void
    method testGetRow (line 108) | public function testGetRow(): void
    method testAssertEquals (line 113) | public function testAssertEquals(): void
    method testAssertEqualsFails (line 121) | public function testAssertEqualsFails(): void
    method testAssertRowContains (line 130) | public function testAssertRowContains(): void

FILE: tests/DataSet/ReplacementDataSetTest.php
  class Extensions_Database_DataSet_ReplacementDataSetTest (line 17) | class Extensions_Database_DataSet_ReplacementDataSetTest extends \PHPUni...
    method setUp (line 24) | public function setUp(): void
    method testNoReplacement (line 85) | public function testNoReplacement(): void
    method testFullReplacement (line 93) | public function testFullReplacement(): void
    method testSubStrReplacement (line 158) | public function testSubStrReplacement(): void
    method testConstructorReplacements (line 223) | public function testConstructorReplacements(): void

FILE: tests/DataSet/ReplacementTableTest.php
  class Extensions_Database_DataSet_ReplacementTableTest (line 18) | class Extensions_Database_DataSet_ReplacementTableTest extends \PHPUnit\...
    method setUp (line 25) | public function setUp(): void
    method testNoReplacement (line 59) | public function testNoReplacement(): void
    method testFullReplacement (line 67) | public function testFullReplacement(): void
    method testSubStrReplacement (line 104) | public function testSubStrReplacement(): void
    method testConstructorReplacements (line 141) | public function testConstructorReplacements(): void
    method testGetRow (line 181) | public function testGetRow(): void
    method testGetValue (line 212) | public function testGetValue(): void
    method testMatchesWithNonMatchingMetaData (line 224) | public function testMatchesWithNonMatchingMetaData(): void
    method testMatchesWithNonMatchingRowCount (line 248) | public function testMatchesWithNonMatchingRowCount(): void
    method testMatchesWithColumnValueComparisons (line 288) | public function testMatchesWithColumnValueComparisons($tableColumnValu...
    method providerMatchesWithColumnValueComparisons (line 342) | public function providerMatchesWithColumnValueComparisons()

FILE: tests/DataSet/XmlDataSetsTest.php
  class Extensions_Database_DataSet_XmlDataSetsTest (line 20) | class Extensions_Database_DataSet_XmlDataSetsTest extends TestCase
    method setUp (line 24) | public function setUp(): void
    method testFlatXmlDataSet (line 85) | public function testFlatXmlDataSet(): void
    method testXmlDataSet (line 93) | public function testXmlDataSet(): void
    method testMysqlXmlDataSet (line 101) | public function testMysqlXmlDataSet(): void

FILE: tests/Operation/OperationsMySQLTest.php
  class Extensions_Database_Operation_OperationsMySQLTest (line 22) | class Extensions_Database_Operation_OperationsMySQLTest extends TestCase
    method setUp (line 24) | protected function setUp(): void
    method getConnection (line 37) | public function getConnection()
    method getDataSet (line 42) | public function getDataSet()
    method testTruncate (line 50) | public function testTruncate(): void
    method getCompositeDataSet (line 79) | public function getCompositeDataSet()
    method testTruncateComposite (line 89) | public function testTruncateComposite(): void

FILE: tests/Operation/OperationsTest.php
  class Extensions_Database_Operation_OperationsTest (line 26) | class Extensions_Database_Operation_OperationsTest extends TestCase
    method setUp (line 28) | protected function setUp(): void
    method getConnection (line 37) | public function getConnection()
    method getDataSet (line 42) | public function getDataSet()
    method testDelete (line 47) | public function testDelete(): void
    method testDeleteAll (line 56) | public function testDeleteAll(): void
    method testTruncate (line 86) | public function testTruncate(): void
    method testInsert (line 116) | public function testInsert(): void
    method testUpdate (line 125) | public function testUpdate(): void
    method testReplace (line 134) | public function testReplace(): void
    method testInsertEmptyTable (line 143) | public function testInsertEmptyTable(): void
    method testInsertAllEmptyTables (line 152) | public function testInsertAllEmptyTables(): void

FILE: tests/Operation/RowBasedTest.php
  class Extensions_Database_Operation_RowBasedTest (line 25) | class Extensions_Database_Operation_RowBasedTest extends TestCase
    method setUp (line 27) | protected function setUp(): void
    method getConnection (line 36) | public function getConnection()
    method getDataSet (line 41) | public function getDataSet()
    method testExecute (line 67) | public function testExecute(): void
    method testExecuteWithBadQuery (line 152) | public function testExecuteWithBadQuery(): void
    method testExecuteHandlesException (line 183) | public function testExecuteHandlesException(): void

FILE: tests/_files/DatabaseTestUtility.php
  class DBUnitTestUtility (line 11) | class DBUnitTestUtility
    method getSQLiteMemoryDB (line 16) | public static function getSQLiteMemoryDB()
    method getMySQLDB (line 36) | public static function getMySQLDB()
    method setUpDatabase (line 47) | protected static function setUpDatabase(PDO $connection): void
    method setUpMySqlDatabase (line 92) | protected static function setUpMySqlDatabase(PDO $connection): void
Condensed preview — 138 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (323K chars).
[
  {
    "path": ".gitattributes",
    "chars": 15,
    "preview": "*.php diff=php\n"
  },
  {
    "path": ".gitignore",
    "chars": 59,
    "preview": "/.idea\n/.php_cs.cache\n/composer.lock\n/build\n/vendor\n/tools\n"
  },
  {
    "path": ".php_cs.dist",
    "chars": 6617,
    "preview": "<?php\n$header = <<<'EOF'\nThis file is part of DbUnit.\n\n(c) Sebastian Bergmann <sebastian@phpunit.de>\n\nFor the full copyr"
  },
  {
    "path": ".travis.yml",
    "chars": 691,
    "preview": "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=\"hig"
  },
  {
    "path": "ChangeLog.md",
    "chars": 1876,
    "preview": "# Changes in DbUnit\n\nAll notable changes to DbUnit are documented in this file using the [Keep a CHANGELOG](http://keepa"
  },
  {
    "path": "LICENSE",
    "chars": 1541,
    "preview": "DbUnit\n\nCopyright (c) 2002-2018, Sebastian Bergmann <sebastian@phpunit.de>.\nAll rights reserved.\n\nRedistribution and use"
  },
  {
    "path": "README.md",
    "chars": 938,
    "preview": "[This extension is no longer maintained](https://github.com/sebastianbergmann/dbunit/issues/217)\n\n# DbUnit\n\n[PHPUnit](ht"
  },
  {
    "path": "build.xml",
    "chars": 3295,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project name=\"dbunit\" default=\"setup\">\n    <target name=\"setup\" depends=\"clean,i"
  },
  {
    "path": "composer.json",
    "chars": 902,
    "preview": "{\n    \"name\": \"phpunit/dbunit\",\n    \"description\": \"PHPUnit extension for database interaction testing\",\n    \"type\": \"li"
  },
  {
    "path": "manifest.xml",
    "chars": 521,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<phar xmlns=\"https://phar.io/xml/manifest/1.0\">\n    <contains name=\"phpunit/dbun"
  },
  {
    "path": "phive.xml",
    "chars": 171,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phive xmlns=\"https://phar.io/phive\">\n  <phar name=\"phpab\" version=\"^1.24.1\" inst"
  },
  {
    "path": "phpunit-travis.xml",
    "chars": 1227,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNam"
  },
  {
    "path": "phpunit.xml",
    "chars": 1255,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNam"
  },
  {
    "path": "src/AbstractTester.php",
    "chars": 3311,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Constraint/DataSetIsEqual.php",
    "chars": 2148,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Constraint/TableIsEqual.php",
    "chars": 2132,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Constraint/TableRowCount.php",
    "chars": 1420,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/AbstractDataSet.php",
    "chars": 3094,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/AbstractTable.php",
    "chars": 6705,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/AbstractTableMetadata.php",
    "chars": 1607,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/AbstractXmlDataSet.php",
    "chars": 3276,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/ArrayDataSet.php",
    "chars": 2006,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/CompositeDataSet.php",
    "chars": 2340,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/CsvDataSet.php",
    "chars": 3407,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/DefaultDataSet.php",
    "chars": 1197,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/DefaultTable.php",
    "chars": 2000,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/DefaultTableIterator.php",
    "chars": 2272,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/DefaultTableMetadata.php",
    "chars": 1102,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Filter.php",
    "chars": 4608,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/FlatXmlDataSet.php",
    "chars": 1361,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/IDataSet.php",
    "chars": 1280,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/ITable.php",
    "chars": 1143,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/ITableIterator.php",
    "chars": 659,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/ITableMetadata.php",
    "chars": 936,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/IYamlParser.php",
    "chars": 466,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/MysqlXmlDataSet.php",
    "chars": 3991,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/QueryDataSet.php",
    "chars": 2243,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/QueryTable.php",
    "chars": 3426,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/ReplacementDataSet.php",
    "chars": 2425,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/ReplacementTable.php",
    "chars": 5623,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/ReplacementTableIterator.php",
    "chars": 3167,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/Csv.php",
    "chars": 2585,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/Factory.php",
    "chars": 1113,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/FlatXml.php",
    "chars": 859,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/IFactory.php",
    "chars": 516,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/Query.php",
    "chars": 2206,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/Specification.php",
    "chars": 616,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/Table.php",
    "chars": 2148,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/Xml.php",
    "chars": 829,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/Specification/Yaml.php",
    "chars": 836,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/SymfonyYamlParser.php",
    "chars": 519,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/TableFilter.php",
    "chars": 3664,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/TableMetadataFilter.php",
    "chars": 3186,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/XmlDataSet.php",
    "chars": 3118,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DataSet/YamlDataSet.php",
    "chars": 2964,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Connection.php",
    "chars": 2697,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/DataSet.php",
    "chars": 4046,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/DefaultConnection.php",
    "chars": 4704,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/FilteredDataSet.php",
    "chars": 934,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/AbstractMetadata.php",
    "chars": 5792,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/Dblib.php",
    "chars": 3046,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/Firebird.php",
    "chars": 5555,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/InformationSchema.php",
    "chars": 3596,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/Metadata.php",
    "chars": 1820,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/MySQL.php",
    "chars": 2190,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/Oci.php",
    "chars": 3610,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/PgSQL.php",
    "chars": 3917,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/SqlSrv.php",
    "chars": 3440,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/Sqlite.php",
    "chars": 2568,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Metadata/Table.php",
    "chars": 727,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/ResultSetTable.php",
    "chars": 1254,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/Table.php",
    "chars": 1017,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Database/TableIterator.php",
    "chars": 2568,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DatabaseListConsumer.php",
    "chars": 515,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/DefaultTester.php",
    "chars": 990,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Exception/Exception.php",
    "chars": 279,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Exception/InvalidArgumentException.php",
    "chars": 345,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Exception/RuntimeException.php",
    "chars": 329,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Composite.php",
    "chars": 1704,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Delete.php",
    "chars": 1395,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/DeleteAll.php",
    "chars": 1059,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Exception.php",
    "chars": 1969,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Factory.php",
    "chars": 2093,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Insert.php",
    "chars": 1974,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/None.php",
    "chars": 553,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Operation.php",
    "chars": 805,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Replace.php",
    "chars": 3854,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/RowBased.php",
    "chars": 4115,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Truncate.php",
    "chars": 2415,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Operation/Update.php",
    "chars": 1938,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/TestCase.php",
    "chars": 456,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/TestCaseTrait.php",
    "chars": 7323,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "src/Tester.php",
    "chars": 1859,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/Constraint/TableRowCountTest.php",
    "chars": 1048,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DB/DefaultDatabaseConnectionTest.php",
    "chars": 1158,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/AbstractTableTest.php",
    "chars": 8819,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/CompositeDataSetTest.php",
    "chars": 6216,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/CsvDataSetTest.php",
    "chars": 2728,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/FilterTest.php",
    "chars": 3034,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/QueryDataSetTest.php",
    "chars": 2965,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/QueryTableTest.php",
    "chars": 4087,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/ReplacementDataSetTest.php",
    "chars": 8843,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/ReplacementTableTest.php",
    "chars": 14501,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/DataSet/XmlDataSetsTest.php",
    "chars": 3328,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/Operation/OperationsMySQLTest.php",
    "chars": 3790,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/Operation/OperationsTest.php",
    "chars": 5878,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/Operation/RowBasedTest.php",
    "chars": 9173,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/_files/CsvDataSets/table1.csv",
    "chars": 146,
    "preview": "table1_id,column1,column2,column3,column4\n1,tgfahgasdf,200,34.64,\"yghkf;a  hahfg8ja h;\"\n2,hk;afg,654,46.54,24rwehhads\n3,"
  },
  {
    "path": "tests/_files/CsvDataSets/table2.csv",
    "chars": 206,
    "preview": "table2_id,column5,column6,column7,column8\n1,fhah,456,46.5,\"fsdb, ghfdas\"\n2,asdhfoih,654,blah,\"43asd \"\"fhgj\"\" sfadh\"\n3,aj"
  },
  {
    "path": "tests/_files/DatabaseTestUtility.php",
    "chars": 3882,
    "preview": "<?php\n/*\n * This file is part of DbUnit.\n *\n * (c) Sebastian Bergmann <sebastian@phpunit.de>\n *\n * For the full copyrigh"
  },
  {
    "path": "tests/_files/XmlDataSets/AllEmptyTableInsertResult.xml",
    "chars": 658,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/AllEmptyTableInsertTest.xml",
    "chars": 74,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1/>\n</dataset>\n"
  },
  {
    "path": "tests/_files/XmlDataSets/DeleteAllOperationTest.xml",
    "chars": 147,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" />\n    <table2 table2_id=\"1\" />\n    <table3 t"
  },
  {
    "path": "tests/_files/XmlDataSets/DeleteOperationResult.xml",
    "chars": 459,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/DeleteOperationTest.xml",
    "chars": 118,
    "preview": "<?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",
    "chars": 910,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/EmptyTableInsertTest.xml",
    "chars": 326,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1/>\n    <table2 table2_id=\"2\" column5=\"gfdsagfpwah\" column6=\""
  },
  {
    "path": "tests/_files/XmlDataSets/FilteredTestComparison.xml",
    "chars": 658,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/FilteredTestFixture.xml",
    "chars": 493,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 column1=\"foo\" column2=\"42\" column3=\"4.2\" column4=\"bar\" />\n "
  },
  {
    "path": "tests/_files/XmlDataSets/FlatXmlDataSet.xml",
    "chars": 606,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"tgfahgasdf\" column2=\"200\" column3=\"3"
  },
  {
    "path": "tests/_files/XmlDataSets/FlatXmlWriter.xml",
    "chars": 520,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1\n        col1=\"val1\"\n        col2=\"val2\"\n        col3=\"val3\""
  },
  {
    "path": "tests/_files/XmlDataSets/FlatXmlWriterEntities.xml",
    "chars": 181,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<dataset>\n    <table1\n        col1=\"1\"\n        col2=\"&lt;?xml version=&quot;1.0&"
  },
  {
    "path": "tests/_files/XmlDataSets/InsertOperationResult.xml",
    "chars": 1017,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/InsertOperationTest.xml",
    "chars": 419,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"3\" column1=\"ggfdsa\" column2=\"4654\" column3=\"45.6"
  },
  {
    "path": "tests/_files/XmlDataSets/MysqlXmlDataSet.xml",
    "chars": 1742,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<mysqldump xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n<database name="
  },
  {
    "path": "tests/_files/XmlDataSets/OperationsMySQLTestFixture.xml",
    "chars": 702,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n  <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" column"
  },
  {
    "path": "tests/_files/XmlDataSets/OperationsTestFixture.xml",
    "chars": 658,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/QueryDataSetTest.xml",
    "chars": 500,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n<table1\n    table1_id=\"1\"\n    column1=\"test\"\n    column2=\"10\"\n    colum"
  },
  {
    "path": "tests/_files/XmlDataSets/ReplaceOperationResult.xml",
    "chars": 1024,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/ReplaceOperationTest.xml",
    "chars": 720,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"2\" column1=\"jgfdasg\" column2=\"4654\" column3=\"45."
  },
  {
    "path": "tests/_files/XmlDataSets/RowBasedExecute.xml",
    "chars": 329,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/TruncateCompositeTest.xml",
    "chars": 1218,
    "preview": "<?xml version=\"1.0\" ?>\n<dataset>\n    <table name=\"table1\">\n        <column>table1_id</column>\n        <column>column1</c"
  },
  {
    "path": "tests/_files/XmlDataSets/UpdateOperationResult.xml",
    "chars": 723,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"1\" column1=\"foo\" column2=\"42\" column3=\"4.2\" colu"
  },
  {
    "path": "tests/_files/XmlDataSets/UpdateOperationTest.xml",
    "chars": 419,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table1 table1_id=\"2\" column1=\"ggfdsa\" column2=\"4654\" column3=\"45.6"
  },
  {
    "path": "tests/_files/XmlDataSets/XmlDataSet.xml",
    "chars": 2158,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table name=\"table1\">\n        <column>table1_id</column>\n        <c"
  },
  {
    "path": "tests/_files/XmlDataSets/XmlWriter.xml",
    "chars": 678,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dataset>\n    <table name=\"table1\">\n        <column>col1</column>\n        <column"
  },
  {
    "path": "tests/_files/XmlDataSets/XmlWriterEntities.xml",
    "chars": 314,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<dataset>\n    <table name=\"table1\">\n        <column>col1</column>\n        <colum"
  },
  {
    "path": "tests/_files/YamlDataSets/testDataSet.yaml",
    "chars": 776,
    "preview": "table1:\n  -\n    table1_id: 1\n    column1: \"tgfahgasdf\"\n    column2: 200\n    column3: 34.64\n    column4: \"yghkf;a  hahfg8"
  }
]

About this extraction

This page contains the full source code of the sebastianbergmann/dbunit GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 138 files (294.3 KB), approximately 77.5k tokens, and a symbol index with 527 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!