本文整理汇总了PHP中PHPUnit_Extensions_Database_DataSet_IDataSet::getTableNames方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Extensions_Database_DataSet_IDataSet::getTableNames方法的具体用法?PHP PHPUnit_Extensions_Database_DataSet_IDataSet::getTableNames怎么用?PHP PHPUnit_Extensions_Database_DataSet_IDataSet::getTableNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Extensions_Database_DataSet_IDataSet
的用法示例。
在下文中一共展示了PHPUnit_Extensions_Database_DataSet_IDataSet::getTableNames方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(\PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, \PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
{
foreach ($dataSet->getTableNames() as $tableName) {
$connection->getConnection()->query("Alter Table {$tableName} NOCHECK Constraint All");
}
foreach ($dataSet->getTableNames() as $tableName) {
$connection->getConnection()->query("Delete From {$tableName}");
}
foreach ($dataSet->getTableNames() as $tableName) {
$connection->getConnection()->query("DBCC CHECKIDENT ({$tableName}, RESEED, 0)");
}
foreach ($dataSet->getTableNames() as $tableName) {
$connection->getConnection()->query("Alter Table {$tableName} CHECK Constraint All");
}
}
示例2: addDataSet
/**
* 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())) {
throw new InvalidArgumentException("DataSet contains a table that already exists: {$tableName}");
}
}
$this->dataSets[] = $dataSet;
}
示例3: execute
public function execute(\PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection, \PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
{
foreach ($dataSet->getTableNames() as $tableName) {
$connection->getConnection()->query("Alter Table {$tableName} NOCHECK Constraint All");
}
parent::execute($connection, $dataSet);
foreach ($dataSet->getTableNames() as $tableName) {
$connection->getConnection()->query("Alter Table {$tableName} CHECK Constraint All");
}
}
示例4: addDataSet
/**
* 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));
}
}
}
示例5: matches
/**
* 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;
}
示例6: assertEquals
/**
* Asserts that the given data set matches this data set.
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $other
*/
public function assertEquals(PHPUnit_Extensions_Database_DataSet_IDataSet $other)
{
$thisTableNames = $this->getTableNames();
$otherTableNames = $other->getTableNames();
sort($thisTableNames);
sort($otherTableNames);
if ($thisTableNames != $otherTableNames) {
throw new Exception("Expected following tables: " . implode(', ', $thisTableNames) . "; has columns: " . implode(', ', $otherTableNames));
}
foreach ($thisTableNames as $tableName) {
$this->getTable($tableName)->assertEquals($other->getTable($tableName));
}
return TRUE;
}
示例7: loadDataSet
/**
* Load date into moodle database tables from standard PHPUnit data set.
*
* Note: it is usually better to use data generators
*
* @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataset
* @return void
*/
protected function loadDataSet(PHPUnit_Extensions_Database_DataSet_IDataSet $dataset) {
global $DB;
$structure = phpunit_util::get_tablestructure();
foreach($dataset->getTableNames() as $tablename) {
$table = $dataset->getTable($tablename);
$metadata = $dataset->getTableMetaData($tablename);
$columns = $metadata->getColumns();
$doimport = false;
if (isset($structure[$tablename]['id']) and $structure[$tablename]['id']->auto_increment) {
$doimport = in_array('id', $columns);
}
for($r=0; $r<$table->getRowCount(); $r++) {
$record = $table->getRow($r);
if ($doimport) {
$DB->import_record($tablename, $record);
} else {
$DB->insert_record($tablename, $record);
}
}
if ($doimport) {
$DB->get_manager()->reset_sequence(new xmldb_table($tablename));
}
}
}