PK PCJsJ Vagrantfilenu W+A VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
if Vagrant.has_plugin?("vagrant-cachier")
end
config.vm.provision "shell", inline: "source /vagrant/build/vagrant.sh"
end
PK PCJ .travis.ymlnu W+A language: php
before_script: ./build/travis-ci.sh
php:
- 5.6
- 7.0
- hhvm
script: ./vendor/bin/phpunit --configuration ./build/phpunit.xml
notifications:
email: false
irc:
channels:
- "irc.freenode.org#phpunit"
use_notice: true
PK PCJ& 8 8 build/vagrant.shnu W+A #!/bin/bash
COMPOSER="/usr/local/bin/composer"
DEBIAN_FRONTEND="noninteractive"
MYSQL_USER="root"
MYSQL_PASSWORD="password"
MYSQL_DATABASE="phpunit_tests"
sed -i "/mirror:\\/\\//d" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise main restricted universe multiverse" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-updates main restricted universe multiverse" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-backports main restricted universe multiverse" /etc/apt/sources.list
sed -i "1ideb mirror://mirrors.ubuntu.com/mirrors.txt precise-security main restricted universe multiverse" /etc/apt/sources.list
apt-get update
debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQL_PASSWORD"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQL_PASSWORD"
apt-get install git php5-cli php5-xdebug php5-sqlite php5-mysql mysql-server-5.5 -y --no-install-recommends
mysql -u root -p"$MYSQL_PASSWORD" -e "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;"
if [ ! -f "$COMPOSER" ]; then
php -r "readfile('https://getcomposer.org/installer');" | sudo php -d apc.enable_cli=0 -- --install-dir=$(dirname "$COMPOSER") --filename=$(basename "$COMPOSER")
else
sudo "$COMPOSER" self-update
fi
cd /vagrant
cp phpunit.xml.dist phpunit.xml
sed -i 's///g' phpunit.xml
if [ ! -d vendor ] || [ ! -f vendor/autoload.php ]; then
${COMPOSER} install --no-interaction --prefer-source --dev
fi
PK PCJ:" build/phpunit.xmlnu W+A
../tests/Constraint
../tests/DataSet
../tests/Operation
../tests/DB
../src
PK PCJFq q build/travis-ci.shnu W+A #!/bin/bash
COMPOSER="/usr/local/bin/composer"
COMPOSER_PATH=$(dirname ${COMPOSER})
MYSQL_USER="root"
MYSQL_DATABASE="phpunit_tests"
if [ ! -x "${COMPOSER}" ]; then
echo "Installing Composer"
curl -sS https://getcomposer.org/installer | sudo php -d apc.enable_cli=0 -- --install-dir=${COMPOSER_PATH} --filename=$(basename ${COMPOSER})
else
echo "Updating Composer"
sudo ${COMPOSER} self-update
fi
${COMPOSER} install --no-interaction --prefer-source --dev
mysql -u ${MYSQL_USER} -e "CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE;"
sed -i 's///g' build/phpunit.xml
PK PCJm{8 8
.gitignorenu W+A /.idea
/.vagrant
/composer.lock
/composer.phar
/vendor
PK PCJ, , dbunitnu W+A #!/usr/bin/env php
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
if (file_exists($file)) {
define('DBUNIT_COMPOSER_INSTALL', $file);
break;
}
}
unset($file);
if (!defined('DBUNIT_COMPOSER_INSTALL')) {
fwrite(STDERR,
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
'wget http://getcomposer.org/composer.phar' . PHP_EOL .
'php composer.phar install' . PHP_EOL
);
die(1);
}
require DBUNIT_COMPOSER_INSTALL;
$command = new PHPUnit_Extensions_Database_UI_Command(
new PHPUnit_Extensions_Database_UI_ModeFactory
);
$command->main(
new PHPUnit_Extensions_Database_UI_Mediums_Text($_SERVER['argv']),
new PHPUnit_Extensions_Database_UI_Context
);
PK PCJ4o; ; 1 src/Extensions/Database/IDatabaseListConsumer.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* An interface for classes that require a list of databases to operate.
*
* @since Class available since Release 1.0.0
*/
interface PHPUnit_Extensions_Database_IDatabaseListConsumer
{
/**
* Sets the database for the spec
*
* @param array $databases
*/
public function setDatabases(array $databases);
}
PK PCJt t 0 src/Extensions/Database/DataSet/DefaultTable.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides default table functionality.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_DefaultTable extends PHPUnit_Extensions_Database_DataSet_AbstractTable
{
/**
* Creates a new table object using the given $tableMetaData
*
* @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData
*/
public function __construct(PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData)
{
$this->setTableMetaData($tableMetaData);
$this->data = [];
}
/**
* Adds a row to the table with optional values.
*
* @param array $values
*/
public function addRow($values = [])
{
$this->data[] = array_replace(
array_fill_keys($this->getTableMetaData()->getColumns(), NULL),
$values
);
}
/**
* Adds the rows in the passed table to the current table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
public function addTableRows(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
$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)
{
if (isset($this->data[$row])) {
$this->data[$row][$column] = $value;
} else {
throw new InvalidArgumentException('The row given does not exist.');
}
}
}
PK PCJ@ۈ[ / src/Extensions/Database/DataSet/IYamlParser.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* An interface for parsing YAML files.
*
* @since Class available since Release 1.3.1
*/
interface PHPUnit_Extensions_Database_DataSet_IYamlParser {
/**
* @param string $yamlFile
* @return array parsed YAML
*/
public function parseYaml($yamlFile);
}
PK PCJ.F 8 src/Extensions/Database/DataSet/DefaultTableMetaData.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* The default implementation of table meta data
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData extends PHPUnit_Extensions_Database_DataSet_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.');
} else {
$this->primaryKeys[] = $columnName;
}
}
}
}
PK PCJDt t . src/Extensions/Database/DataSet/XmlDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* The default implementation of a data set.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_XmlDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractXmlDataSet
{
protected function getTableInfo(Array &$tableColumns, Array &$tableValues)
{
if ($this->xmlFileContents->getName() != 'dataset') {
throw new PHPUnit_Extensions_Database_Exception('The root element of an xml data set file must be called ');
}
foreach ($this->xmlFileContents->xpath('/dataset/table') as $tableElement) {
if (empty($tableElement['name'])) {
throw new PHPUnit_Extensions_Database_Exception('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 PHPUnit_Extensions_Database_Exception("Missing elements for table $tableName. Add one or more elements to the 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 PHPUnit_Extensions_Database_Exception("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 PHPUnit_Extensions_Database_Exception('Unknown element ' . $columnValue->getName() . ' in a row element.');
}
}
$tableValues[$tableName][] = $rowValues;
}
}
}
public static function write(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset, $filename)
{
$pers = new PHPUnit_Extensions_Database_DataSet_Persistors_Xml();
$pers->setFileName($filename);
try {
$pers->write($dataset);
}
catch (RuntimeException $e) {
throw new PHPUnit_Framework_Exception(__METHOD__ . ' called with an unwritable file.');
}
}
}
PK PCJ/wh h 4 src/Extensions/Database/DataSet/ReplacementTable.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Allows for replacing arbitrary strings in your data sets with other values.
*
* @since Class available since Release 1.0.0
* @todo When setTableMetaData() is taken out of the AbstractTable this class should extend AbstractTable.
*/
class PHPUnit_Extensions_Database_DataSet_ReplacementTable implements PHPUnit_Extensions_Database_DataSet_ITable
{
/**
* @var PHPUnit_Extensions_Database_DataSet_ITable
*/
protected $table;
/**
* @var array
*/
protected $fullReplacements;
/**
* @var array
*/
protected $subStrReplacements;
/**
* Creates a new replacement table
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
* @param array $fullReplacements
* @param array $subStrReplacements
*/
public function __construct(PHPUnit_Extensions_Database_DataSet_ITable $table, Array $fullReplacements = [], Array $subStrReplacements = [])
{
$this->table = $table;
$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)
{
$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)
{
$this->subStrReplacements[$value] = $replacement;
}
/**
* Returns the table's meta data.
*
* @return PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_ITable $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_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;
}
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";
}
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];
}
else if (count($this->subStrReplacements) && isset($value)) {
return str_replace(array_keys($this->subStrReplacements), array_values($this->subStrReplacements), $value);
}
else {
return $value;
}
}
}
PK PCJ;c 9 src/Extensions/Database/DataSet/AbstractTableMetaData.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides basic functionality for table meta data.
*
* @since Class available since Release 1.0.0
*/
abstract class PHPUnit_Extensions_Database_DataSet_AbstractTableMetaData implements PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_ITableMetaData $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_ITableMetaData $other)
{
if ($this->getTableName() != $other->getTableName() ||
$this->getColumns() != $other->getColumns()) {
return FALSE;
}
return TRUE;
}
}
PK PCJIK| | / src/Extensions/Database/DataSet/YamlDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Creates YamlDataSets.
*
* You can incrementally add YAML files as tables to your datasets
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_YamlDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
{
/**
* @var array
*/
protected $tables = [];
/**
* @var PHPUnit_Extensions_Database_DataSet_IYamlParser
*/
protected $parser;
/**
* Creates a new YAML dataset
*
* @param string $yamlFile
* @param PHPUnit_Extensions_Database_DataSet_IYamlParser $parser
*/
public function __construct($yamlFile, $parser = NULL)
{
if ($parser == NULL) {
$parser = new PHPUnit_Extensions_Database_DataSet_SymfonyYamlParser();
}
$this->parser = $parser;
$this->addYamlFile($yamlFile);
}
/**
* Adds a new yaml file to the dataset.
* @param string $yamlFile
*/
public function addYamlFile($yamlFile)
{
$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 PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData(
$tableName, $columns
);
$this->tables[$tableName] = new PHPUnit_Extensions_Database_DataSet_DefaultTable(
$tableMetaData
);
}
foreach ($rows as $row) {
$this->tables[$tableName]->addRow($row);
}
}
}
/**
* 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.
*/
private function getColumns($rows) {
$columns = [];
foreach ($rows as $row) {
$columns = array_merge($columns, array_keys($row));
}
return array_values(array_unique($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 PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
protected function createIterator($reverse = FALSE)
{
return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator(
$this->tables, $reverse
);
}
/**
* Saves a given $dataset to $filename in YAML format
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
* @param string $filename
*/
public static function write(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset, $filename)
{
$pers = new PHPUnit_Extensions_Database_DataSet_Persistors_Yaml();
$pers->setFileName($filename);
try {
$pers->write($dataset);
}
catch (RuntimeException $e) {
throw new PHPUnit_Framework_Exception(
__METHOD__ . ' called with an unwritable file.'
);
}
}
}
PK PCJ>Kd5
5
4 src/Extensions/Database/DataSet/CompositeDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Creates Composite Datasets
*
* Allows for creating datasets from multiple sources (csv, query, xml, etc.)
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_CompositeDataSet extends PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
*/
public function addDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
{
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 PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
protected function createIterator($reverse = FALSE)
{
if ($reverse) {
return $this->motherDataSet->getReverseIterator();
} else {
return $this->motherDataSet->getIterator();
}
}
}
PK PCJO
6 src/Extensions/Database/DataSet/ReplacementDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* 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
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_ReplacementDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
{
/**
* @var PHPUnit_Extensions_Database_DataSet_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(PHPUnit_Extensions_Database_DataSet_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)
{
$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)
{
$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 PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
protected function createIterator($reverse = FALSE)
{
$innerIterator = $reverse ? $this->dataSet->getReverseIterator() : $this->dataSet->getIterator();
return new PHPUnit_Extensions_Database_DataSet_ReplacementTableIterator($innerIterator, $this->fullReplacements, $this->subStrReplacements);
}
}
PK PCJ,+;1 1 2 src/Extensions/Database/DataSet/ITableMetaData.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides a basic interface for returning table meta data.
*
* @since Class available since Release 1.0.0
*/
interface PHPUnit_Extensions_Database_DataSet_ITableMetaData
{
/**
* Returns the names of the columns in the table.
*
* @return array
*/
public function getColumns();
/**
* Returns the names of the primary key columns in the table.
*
* @return array
*/
public function getPrimaryKeys();
/**
* Returns the name of the table.
*
* @return string
*/
public function getTableName();
/**
* Asserts that the given tableMetaData matches this tableMetaData.
*
* @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_ITableMetaData $other);
}
PK PCJlNV V . src/Extensions/Database/DataSet/QueryTable.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides the functionality to represent a database table.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_QueryTable extends PHPUnit_Extensions_Database_DataSet_AbstractTable
{
/**
* @var string
*/
protected $query;
/**
* @var PHPUnit_Extensions_Database_DB_IDatabaseConnection
*/
protected $databaseConnection;
/**
* @var string
*/
protected $tableName;
/**
* Creates a new database query table object.
*
* @param string $table_name
* @param string $query
* @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
*/
public function __construct($tableName, $query, PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection)
{
$this->query = $query;
$this->databaseConnection = $databaseConnection;
$this->tableName = $tableName;
}
/**
* Returns the table's meta data.
*
* @return PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_ITable $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_ITable $other)
{
$this->loadData();
return parent::matches($other);
}
protected function loadData()
{
if ($this->data === NULL) {
$pdoStatement = $this->databaseConnection->getConnection()->query($this->query);
$this->data = $pdoStatement->fetchAll(PDO::FETCH_ASSOC);
}
}
protected function createTableMetaData()
{
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 {
// if no rows found, get column names from database
$pdoStatement = $this->databaseConnection->getConnection()->prepare('SELECT column_name FROM information_schema.COLUMNS WHERE table_schema=:schema AND table_name=:table');
$pdoStatement->execute([
'table' => $this->tableName,
'schema' => $this->databaseConnection->getSchema()
]);
$columns = $pdoStatement->fetchAll(PDO::FETCH_COLUMN, 0);
}
// create metadata
$this->tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($this->tableName, $columns);
}
}
}
PK PCJ||o o 0 src/Extensions/Database/DataSet/ArrayDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Implements the basic functionality of data sets using a PHP array.
*
* @since Class available since Release 1.3.2
*/
class PHPUnit_Extensions_Database_DataSet_ArrayDataSet extends PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
foreach ($rows AS $row) {
$table->addRow($row);
}
$this->tables[$tableName] = $table;
}
}
protected function createIterator($reverse = FALSE)
{
return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse);
}
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];
}
}
?>PK PCJ)
/ src/Extensions/Database/DataSet/TableFilter.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A table decorator that allows filtering out table columns from results.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_TableFilter extends PHPUnit_Extensions_Database_DataSet_AbstractTable
{
/**
* The table meta data being decorated.
* @var PHPUnit_Extensions_Database_DataSet_ITable
*/
protected $originalTable;
/**
* Creates a new table filter using the original table
*
* @param $originalTable PHPUnit_Extensions_Database_DataSet_ITable
* @param $excludeColumns Array @deprecated, use the set* methods instead.
*/
public function __construct(PHPUnit_Extensions_Database_DataSet_ITable $originalTable, Array $excludeColumns = [])
{
$this->originalTable = $originalTable;
$this->setTableMetaData(new PHPUnit_Extensions_Database_DataSet_TableMetaDataFilter($originalTable->getTableMetaData()));
$this->addExcludeColumns($excludeColumns);
}
/**
* Returns the number of rows in this table.
*
* @return int
*/
public function getRowCount()
{
return $this->originalTable->getRowCount();
}
/**
* Returns the value for the given column on the given row.
*
* @param int $row
* @param int $column
*/
public function getValue($row, $column)
{
if (in_array($column, $this->getTableMetaData()->getColumns())) {
return $this->originalTable->getValue($row, $column);
} else {
throw new InvalidArgumentException("The given row ({$row}) and column ({$column}) do not exist in table {$this->getTableMetaData()->getTableName()}");
}
}
/**
* Sets the columns to include in the table.
* @param Array $includeColumns
*/
public function addIncludeColumns(Array $includeColumns)
{
$this->tableMetaData->addIncludeColumns($includeColumns);
}
/**
* Clears the included columns.
*/
public function clearIncludeColumns()
{
$this->tableMetaData->clearIncludeColumns();
}
/**
* Sets the columns to exclude from the table.
* @param Array $excludeColumns
*/
public function addExcludeColumns(Array $excludeColumns)
{
$this->tableMetaData->addExcludeColumns($excludeColumns);
}
/**
* Clears the included columns.
*/
public function clearExcludeColumns()
{
$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()
{
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;
}
}
}
PK PCJ!- 2 src/Extensions/Database/DataSet/ITableIterator.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides a basic interface for creating and reading data from data sets.
*
* @since Class available since Release 1.0.0
*/
interface PHPUnit_Extensions_Database_DataSet_ITableIterator extends Iterator
{
/**
* Returns the current table.
*
* @return PHPUnit_Extensions_Database_DataSet_ITable
*/
public function getTable();
/**
* Returns the current table's meta data.
*
* @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
*/
public function getTableMetaData();
}
PK PCJ'7u 0 src/Extensions/Database/DataSet/QueryDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides access to a database instance as a data set.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_QueryDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
{
/**
* An array of ITable objects.
*
* @var array
*/
protected $tables = [];
/**
* The database connection this dataset is using.
*
* @var PHPUnit_Extensions_Database_DB_IDatabaseConnection
*/
protected $databaseConnection;
/**
* Creates a new dataset using the given database connection.
*
* @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
*/
public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection)
{
$this->databaseConnection = $databaseConnection;
}
public function addTable($tableName, $query = NULL)
{
if ($query === NULL) {
$query = 'SELECT * FROM ' . $tableName;
}
$this->tables[$tableName] = new PHPUnit_Extensions_Database_DataSet_QueryTable($tableName, $query, $this->databaseConnection);
}
/**
* Creates an iterator over the tables in the data set. If $reverse is
* true a reverse iterator will be returned.
*
* @param bool $reverse
* @return PHPUnit_Extensions_Database_DB_TableIterator
*/
protected function createIterator($reverse = FALSE)
{
return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse);
}
/**
* Returns a table object for the given table.
*
* @param string $tableName
* @return PHPUnit_Extensions_Database_DB_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);
}
}
PK PCJF! 6 src/Extensions/Database/DataSet/AbstractXmlDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* The default implementation of a data set.
*
* @since Class available since Release 1.0.0
*/
abstract class PHPUnit_Extensions_Database_DataSet_AbstractXmlDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractDataSet
{
/**
* @var array
*/
protected $tables;
/**
* @var SimpleXmlElement
*/
protected $xmlFileContents;
/**
* Creates a new dataset using the given tables.
*
* @param array $tables
*/
public function __construct($xmlFile)
{
if (!is_file($xmlFile)) {
throw new InvalidArgumentException(
"Could not find xml file: {$xmlFile}"
);
}
$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);
$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.
*/
protected abstract function getTableInfo(Array &$tableColumns, Array &$tableValues);
protected function createTables(Array &$tableColumns, Array &$tableValues)
{
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
* @return PHPUnit_Extensions_Database_DataSet_ITable
*/
protected function getOrCreateTable($tableName, $tableColumns)
{
if (empty($this->tables[$tableName])) {
$tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $tableColumns);
$this->tables[$tableName] = new PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
protected function createIterator($reverse = FALSE)
{
return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse);
}
}
PK PCJZ , src/Extensions/Database/DataSet/IDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides a basic interface for creating and reading data from data sets.
*
* @since Class available since Release 1.0.0
*/
interface PHPUnit_Extensions_Database_DataSet_IDataSet extends IteratorAggregate
{
/**
* Returns an array of table names contained in the dataset.
*
* @return array
*/
public function getTableNames();
/**
* Returns a table meta data object for the given table.
*
* @param string $tableName
* @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
*/
public function getTableMetaData($tableName);
/**
* Returns a table object for the given table.
*
* @param string $tableName
* @return PHPUnit_Extensions_Database_DataSet_ITable
*/
public function getTable($tableName);
/**
* Returns a reverse iterator for all table objects in the given dataset.
*
* @return PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
public function getReverseIterator();
/**
* Asserts that the given data set matches this data set.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_IDataSet $other);
}
PK PCJ^ 3 src/Extensions/Database/DataSet/AbstractDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Implements the basic functionality of data sets.
*
* @since Class available since Release 1.0.0
*/
abstract class PHPUnit_Extensions_Database_DataSet_AbstractDataSet implements PHPUnit_Extensions_Database_DataSet_IDataSet
{
/**
* Creates an iterator over the tables in the data set. If $reverse is
* true a reverse iterator will be returned.
*
* @param bool $reverse
* @return PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
protected abstract function createIterator($reverse = FALSE);
/**
* Returns an array of table names contained in the dataset.
*
* @return array
*/
public function getTableNames()
{
$tableNames = [];
foreach ($this->getIterator() as $table) {
/* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
$tableNames[] = $table->getTableMetaData()->getTableName();
}
return $tableNames;
}
/**
* Returns a table meta data object for the given table.
*
* @param string $tableName
* @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
*/
public function getTableMetaData($tableName)
{
return $this->getTable($tableName)->getTableMetaData();
}
/**
* Returns a table object for the given table.
*
* @param string $tableName
* @return PHPUnit_Extensions_Database_DataSet_ITable
*/
public function getTable($tableName)
{
foreach ($this->getIterator() as $table) {
/* @var $table PHPUnit_Extensions_Database_DataSet_ITable */
if ($table->getTableMetaData()->getTableName() == $tableName) {
return $table;
}
}
}
/**
* Returns an iterator for all table objects in the given dataset.
*
* @return PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
public function getIterator()
{
return $this->createIterator();
}
/**
* Returns a reverse iterator for all table objects in the given dataset.
*
* @return PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
public function getReverseIterator()
{
return $this->createIterator(TRUE);
}
/**
* Asserts that the given data set matches this data set.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_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;
}
public function __toString()
{
$iterator = $this->getIterator();
$dataSetString = '';
foreach ($iterator as $table) {
$dataSetString .= $table->__toString();
}
return $dataSetString;
}
}
PK PCJȃN * src/Extensions/Database/DataSet/ITable.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides a basic interface for creating and reading data from data sets.
*
* @since Class available since Release 1.0.0
*/
interface PHPUnit_Extensions_Database_DataSet_ITable
{
/**
* Returns the table's meta data.
*
* @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
*/
public function getTableMetaData();
/**
* Returns the number of rows in this table.
*
* @return int
*/
public function getRowCount();
/**
* Returns the value for the given column on the given row.
*
* @param int $row
* @param int $column
*/
public function getValue($row, $column);
/**
* 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 PHPUnit_Extensions_Database_DataSet_ITable $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_ITable $other);
}
PK PCJ 0 src/Extensions/Database/DataSet/IPersistable.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* An interface for persisting datasets
*
* @since Class available since Release 1.0.0
*/
interface PHPUnit_Extensions_Database_DataSet_IPersistable
{
/**
* Writes the given dataset
*
* The previous dataset will be overwritten.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
public function write(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset);
}
PK PCJXlS S 1 src/Extensions/Database/DataSet/AbstractTable.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides a basic functionality for dbunit tables
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_AbstractTable implements PHPUnit_Extensions_Database_DataSet_ITable
{
/**
* @var PHPUnit_Extensions_Database_DataSet_ITableMetaData
*/
protected $tableMetaData;
/**
* A 2-dimensional array containing the data for this table.
*
* @var array
*/
protected $data;
/**
* @var PHPUnit_Extensions_Database_DataSet_ITable|null
*/
private $other;
/**
* Sets the metadata for this table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData
* @deprecated
*/
protected function setTableMetaData(PHPUnit_Extensions_Database_DataSet_ITableMetaData $tableMetaData)
{
$this->tableMetaData = $tableMetaData;
}
/**
* Returns the table's meta data.
*
* @return PHPUnit_Extensions_Database_DataSet_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;
} else {
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()}");
} else {
return NULL;
}
}
}
/**
* 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];
} else {
if ($this->getRowCount() <= $row) {
throw new InvalidArgumentException("The given row ({$row}) does not exist in table {$this->getTableMetaData()->getTableName()}");
} else {
return NULL;
}
}
}
/**
* Asserts that the given table matches this table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $other
*/
public function matches(PHPUnit_Extensions_Database_DataSet_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);
}
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) {
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) . $lineSeperator;
}
return ($this->other ? '(table diff enabled)' : '') . "\n" . $tableString . "\n";
}
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";
}
}
PK PCJ52P9
9
7 src/Extensions/Database/DataSet/TableMetaDataFilter.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* 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.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_TableMetaDataFilter extends PHPUnit_Extensions_Database_DataSet_AbstractTableMetaData
{
/**
* The table meta data being decorated.
* @var PHPUnit_Extensions_Database_DataSet_ITableMetaData
*/
protected $originalMetaData;
/**
* The columns to exclude from the meta data.
* @var Array
*/
protected $excludeColumns = [];
/**
* The columns to include from the meta data.
* @var Array
*/
protected $includeColumns = [];
/**
* Creates a new filtered table meta data object filtering out
* $excludeColumns.
*
* @param PHPUnit_Extensions_Database_DataSet_ITableMetaData $originalMetaData
* @param array $excludeColumns - Deprecated. Use the set* methods instead.
*/
public function __construct(PHPUnit_Extensions_Database_DataSet_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));
}
elseif (!empty($this->excludeColumns)) {
return array_values(array_diff($this->originalMetaData->getColumns(), $this->excludeColumns));
}
else {
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)
{
$this->includeColumns = array_unique(array_merge($this->includeColumns, $includeColumns));
}
/**
* Clears the included columns.
*/
public function clearIncludeColumns()
{
$this->includeColumns = [];
}
/**
* Sets the columns to exclude from the table.
* @param Array $excludeColumns
*/
public function addExcludeColumns(Array $excludeColumns)
{
$this->excludeColumns = array_unique(array_merge($this->excludeColumns, $excludeColumns));
}
/**
* Clears the excluded columns.
*/
public function clearExcludeColumns()
{
$this->excludeColumns = [];
}
}
PK PCJ\[t t 3 src/Extensions/Database/DataSet/MysqlXmlDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Data set implementation for the output of mysqldump --xml.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_MysqlXmlDataSet extends PHPUnit_Extensions_Database_DataSet_AbstractXmlDataSet
{
protected function getTableInfo(array &$tableColumns, array &$tableValues)
{
if ($this->xmlFileContents->getName() != 'mysqldump') {
throw new PHPUnit_Extensions_Database_Exception('The root element of a MySQL XML data set file must be called ');
}
foreach ($this->xmlFileContents->xpath('./database/table_data') as $tableElement) {
if (empty($tableElement['name'])) {
throw new PHPUnit_Extensions_Database_Exception(' 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 PHPUnit_Extensions_Database_Exception(' 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 . '"]');
$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 PHPUnit_Extensions_Database_Exception(' 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 PHPUnit_Extensions_Database_Exception(' elements must include a Field attribute');
}
$columnName = (string) (empty($fieldElement['Field']) ? $fieldElement['field'] : $fieldElement['Field']);
if (!in_array($columnName, $tableColumns[$tableName])) {
$tableColumns[$tableName][] = $columnName;
}
}
}
}
public static function write(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset, $filename)
{
$pers = new PHPUnit_Extensions_Database_DataSet_Persistors_MysqlXml;
$pers->setFileName($filename);
try {
$pers->write($dataset);
}
catch (RuntimeException $e) {
throw new PHPUnit_Framework_Exception(__METHOD__ . ' called with an unwritable file.');
}
}
}
PK PCJ݂ ) src/Extensions/Database/DataSet/ISpec.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Provides an interface for creating data sets from data set spec strings.
*
* @since Class available since Release 1.0.0
*/
interface PHPUnit_Extensions_Database_DataSet_ISpec
{
/**
* Creates a data set from a data set spec string.
*
* @param string $dataSetSpec
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
public function getDataSet($dataSetSpec);
}
PK PCJ4 8 src/Extensions/Database/DataSet/DefaultTableIterator.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* The default table iterator
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_DefaultTableIterator implements PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_ITable
*/
public function getTable()
{
return $this->current();
}
/**
* Returns the current table's meta data.
*
* @return PHPUnit_Extensions_Database_DataSet_ITableMetaData
*/
public function getTableMetaData()
{
return $this->current()->getTableMetaData();
}
/**
* Returns the current table.
*
* @return PHPUnit_Extensions_Database_DataSet_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()
{
if ($this->reverse) {
prev($this->tables);
} else {
next($this->tables);
}
}
/**
* Rewinds to the first element
*/
public function rewind()
{
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);
}
}
PK PCJD:
7 src/Extensions/Database/DataSet/Persistors/Abstract.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* An abstract implementation of a dataset persistor.
*
* @since Class available since Release 1.0.0
*/
abstract class PHPUnit_Extensions_Database_DataSet_Persistors_Abstract implements PHPUnit_Extensions_Database_DataSet_IPersistable
{
public function write(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
$this->saveDataSet($dataset);
}
/**
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
protected function saveDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
$this->startDataSet($dataset);
foreach ($dataset as $table) {
$this->saveTable($table);
}
$this->endDataSet($dataset);
}
/**
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function saveTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
$rowCount = $table->getRowCount();
$this->startTable($table);
for ($i = 0; $i < $rowCount; $i++) {
$this->row($table->getRow($i), $table);
}
$this->endTable($table);
}
/**
* Override to save the start of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
abstract protected function startDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset);
/**
* Override to save the end of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
abstract protected function endDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset);
/**
* Override to save the start of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
abstract protected function startTable(PHPUnit_Extensions_Database_DataSet_ITable $table);
/**
* Override to save the end of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
abstract protected function endTable(PHPUnit_Extensions_Database_DataSet_ITable $table);
/**
* Override to save a table row.
*
* @param array $row
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
abstract protected function row(Array $row, PHPUnit_Extensions_Database_DataSet_ITable $table);
}
PK PCJTZ, 6 src/Extensions/Database/DataSet/Persistors/FlatXml.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A Flat XML dataset persistor.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_Persistors_FlatXml extends PHPUnit_Extensions_Database_DataSet_Persistors_Abstract
{
/**
* @var string
*/
protected $filename;
/**
* @var resource
*/
protected $fh;
/**
* Sets the filename that this persistor will save to.
*
* @param string $filename
*/
public function setFileName($filename)
{
$this->filename = $filename;
}
/**
* Override to save the start of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
protected function startDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
$this->fh = fopen($this->filename, 'w');
if ($this->fh === FALSE) {
throw new PHPUnit_Framework_Exception(
"Could not open {$this->filename} for writing see " . __CLASS__ . '::setFileName()'
);
}
fwrite($this->fh, "\n");
fwrite($this->fh, "\n");
}
/**
* Override to save the end of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
protected function endDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
fwrite($this->fh, "\n");
}
/**
* Override to save the start of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function startTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
if ($table->getRowCount() == 0) {
fwrite($this->fh, "\t<{$table->getTableMetaData()->getTableName()} />\n");
}
}
/**
* Override to save the end of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function endTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
//do nothing
}
/**
* Override to save a table row.
*
* @param array $row
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function row(Array $row, PHPUnit_Extensions_Database_DataSet_ITable $table)
{
fwrite($this->fh, "\t<{$table->getTableMetaData()->getTableName()}\n");
foreach ($table->getTableMetaData()->getColumns() as $columnName) {
if (isset($row[$columnName])) {
fwrite($this->fh, "\t\t{$columnName}=\"" . htmlspecialchars($row[$columnName]) . "\"\n");
}
}
fwrite($this->fh, "\t/>\n");
}
}
PK PCJO
7 src/Extensions/Database/DataSet/Persistors/MysqlXml.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A MySQL XML dataset persistor.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_Persistors_MysqlXml extends PHPUnit_Extensions_Database_DataSet_Persistors_Abstract
{
/**
* @var string
*/
protected $filename;
/**
* @var string
*/
protected $database;
/**
* @var resource
*/
protected $fh;
/**
* Sets the filename that this persistor will save to.
*
* @param string $filename
*/
public function setFileName($filename)
{
$this->filename = $filename;
}
/**
* Sets the name of the database.
*
* @param string $database
*/
public function setDatabase($database)
{
$this->database = $database;
}
/**
* Override to save the start of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
protected function startDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
$this->fh = fopen($this->filename, 'w');
if ($this->fh === FALSE) {
throw new PHPUnit_Framework_Exception(
"Could not open {$this->filename} for writing see " . __CLASS__ . '::setFileName()'
);
}
fwrite($this->fh, '' . "\n");
fwrite($this->fh, '' . "\n");
fwrite($this->fh, '' . "\n");
}
/**
* Override to save the end of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
protected function endDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
fwrite($this->fh, '' . "\n");
fwrite($this->fh, '' . "\n");
}
/**
* Override to save the start of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function startTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
fwrite($this->fh, "\t" . '' . "\n");
}
/**
* Override to save the end of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function endTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
fwrite($this->fh, "\t" . '' . "\n");
}
/**
* Override to save a table row.
*
* @param array $row
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function row(Array $row, PHPUnit_Extensions_Database_DataSet_ITable $table)
{
fwrite($this->fh, "\t" . '' . "\n");
foreach ($table->getTableMetaData()->getColumns() as $columnName) {
fwrite($this->fh, "\t\t" . 'fh, '>' . htmlspecialchars($row[$columnName]) . '' . "\n");
} else {
fwrite($this->fh, ' xsi:nil="true" />' . "\n");
}
}
fwrite($this->fh, "\t" . '
' . "\n");
}
}
PK PCJ( 6 src/Extensions/Database/DataSet/Persistors/Factory.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Creates the appropriate Persistor based on a given type and spec.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_Persistors_Factory
{
/**
* Returns the persistor.
*
* @param string $type
* @param string $spec
* @return PHPUnit_Extensions_Database_DataSet_IPersistable
*/
public function getPersistorBySpec($type, $spec)
{
switch (strtolower($type)) {
case 'xml':
$xmlPersistor = new PHPUnit_Extensions_Database_DataSet_Persistors_Xml();
$xmlPersistor->setFileName($spec);
return $xmlPersistor;
case 'flatxml':
$flatXmlPersistor = new PHPUnit_Extensions_Database_DataSet_Persistors_FlatXml();
$flatXmlPersistor->setFileName($spec);
return $flatXmlPersistor;
case 'yaml':
$yamlPersistor = new PHPUnit_Extensions_Database_DataSet_Persistors_Yaml();
$yamlPersistor->setFileName($spec);
return $yamlPersistor;
case 'mysqlxml':
$mysqlXmlPersistor = new PHPUnit_Extensions_Database_DataSet_Persistors_MysqlXml();
$mysqlXmlPersistor->setFileName($spec);
return $mysqlXmlPersistor;
default:
throw new PHPUnit_Extensions_Database_Exception("I don't know what you want from me. PERSISTOR");
}
}
}
PK PCJ.5 5 2 src/Extensions/Database/DataSet/Persistors/Xml.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A XML dataset persistor.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_Persistors_Xml extends PHPUnit_Extensions_Database_DataSet_Persistors_Abstract
{
/**
* @var string
*/
protected $filename;
/**
* @var resource
*/
protected $fh;
/**
* Sets the filename that this persistor will save to.
*
* @param string $filename
*/
public function setFileName($filename)
{
$this->filename = $filename;
}
/**
* Override to save the start of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
protected function startDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
$this->fh = fopen($this->filename, 'w');
if ($this->fh === FALSE) {
throw new PHPUnit_Framework_Exception(
"Could not open {$this->filename} for writing see " . __CLASS__ . '::setFileName()'
);
}
fwrite($this->fh, "\n");
fwrite($this->fh, "\n");
}
/**
* Override to save the end of a dataset.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
protected function endDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
fwrite($this->fh, "\n");
}
/**
* Override to save the start of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function startTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
fwrite($this->fh, "\tgetTableMetaData()->getTableName()}\">\n");
foreach ($table->getTableMetaData()->getColumns() as $columnName) {
fwrite($this->fh, "\t\t{$columnName}\n");
}
}
/**
* Override to save the end of a table.
*
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function endTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
fwrite($this->fh, "\t
\n");
}
/**
* Override to save a table row.
*
* @param array $row
* @param PHPUnit_Extensions_Database_DataSet_ITable $table
*/
protected function row(Array $row, PHPUnit_Extensions_Database_DataSet_ITable $table)
{
fwrite($this->fh, "\t\t\n");
foreach ($table->getTableMetaData()->getColumns() as $columnName) {
if (isset($row[$columnName])) {
fwrite($this->fh, "\t\t\t" . htmlspecialchars($row[$columnName]) . "\n");
} else {
fwrite($this->fh, "\t\t\t\n");
}
}
fwrite($this->fh, "\t\t
\n");
}
}
PK PCJ* 3 src/Extensions/Database/DataSet/Persistors/Yaml.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A yaml dataset persistor
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_Persistors_Yaml implements PHPUnit_Extensions_Database_DataSet_IPersistable
{
/**
* @var string
*/
protected $filename;
/**
* Sets the filename that this persistor will save to.
*
* @param string $filename
*/
public function setFileName($filename)
{
$this->filename = $filename;
}
/**
* Writes the dataset to a yaml file
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
*/
public function write(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset)
{
$phpArr = [];
$emptyTables = [];
foreach ($dataset as $table) {
$tableName = $table->getTableMetaData()->getTableName();
$rowCount = $table->getRowCount();
if (!$rowCount) {
$emptyTables[] = $tableName;
continue;
}
$phpArr[$tableName] = [];
for ($i = 0; $i < $rowCount; $i++) {
$phpArr[$tableName][] = $table->getRow($i);
}
}
$emptyTablesAsString = '';
if (count($emptyTables)) {
$emptyTablesAsString = implode(":\n", $emptyTables) . ":\n\n";
}
file_put_contents(
$this->filename,
Symfony\Component\Yaml\Yaml::dump($phpArr, 3) . $emptyTablesAsString
);
}
}
PK PCJw 2 src/Extensions/Database/DataSet/DefaultDataSet.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* The default implementation of a data set.
*
* @since Class available since Release 1.0.0
*/
class PHPUnit_Extensions_Database_DataSet_DefaultDataSet extends PHPUnit_Extensions_Database_DataSet_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 PHPUnit_Extensions_Database_DataSet_ITable $table
*/
public function addTable(PHPUnit_Extensions_Database_DataSet_ITable $table)
{
$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 PHPUnit_Extensions_Database_DataSet_ITableIterator
*/
protected function createIterator($reverse = FALSE)
{
return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse);
}
}
PK PCJPWO O 5 src/Extensions/Database/DataSet/SymfonyYamlParser.phpnu W+A
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* The default YAML parser, using Symfony/Yaml.
*
* @since Class available since Release 1.3.1
*/
class PHPUnit_Extensions_Database_DataSet_SymfonyYamlParser implements PHPUnit_Extensions_Database_DataSet_IYamlParser {
public function parseYaml($yamlFile) {
return Symfony\Component\Yaml\Yaml::parse(file_get_contents($yamlFile));
}
}
PK PCJNs
<