diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/Test/PHPUnit/Db/Operation/Insert.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/Test/PHPUnit/Db/Operation/Insert.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,104 @@ +createDataSet(); + + $dsIterator = $dataSet->getIterator(); + + foreach($dsIterator as $table) { + $tableName = $table->getTableMetaData()->getTableName(); + + $db = $connection->getConnection(); + for($i = 0; $i < $table->getRowCount(); $i++) { + $values = $this->buildInsertValues($table, $i); + try { + $db->insert($tableName, $values); + } catch (Exception $e) { + throw new PHPUnit_Extensions_Database_Operation_Exception("INSERT", "INSERT INTO ".$tableName." [..]", $values, $table, $e->getMessage()); + } + } + } + } + + /** + * + * @param PHPUnit_Extensions_Database_DataSet_ITable $table + * @param int $rowNum + * @return array + */ + protected function buildInsertValues(PHPUnit_Extensions_Database_DataSet_ITable $table, $rowNum) + { + $values = array(); + foreach($table->getTableMetaData()->getColumns() as $columnName) { + $values[$columnName] = $table->getValue($rowNum, $columnName); + } + return $values; + } +} \ No newline at end of file