Refactored helper to use nextcloud query builder

hoping this fixes the test problems with pgsql
This commit is contained in:
Marcos Zuriaga 2016-10-15 01:42:14 +02:00
parent 0779d79cca
commit 4086f22212
No known key found for this signature in database
GPG key ID: 7D15585354D072FF

View file

@ -68,6 +68,7 @@ abstract class DatabaseHelperTest extends PHPUnit_Extensions_Database_TestCase {
*/
public function setUpTable($table_name){
$table = $this->getTableDataset($table_name);
$table_no_prefix = substr($table_name, 3);
// Cleanup any data currently inside the table
$this->truncateTable($table_name);
@ -76,19 +77,14 @@ abstract class DatabaseHelperTest extends PHPUnit_Extensions_Database_TestCase {
for ($i = 0; $i < $table->getRowCount(); $i++) {
$row = $table->getRow($i);
$fields = "";
$values = "";
$qb = $this->db->getQueryBuilder();
$qb->insert($table_no_prefix);
foreach ($row as $key => $value){
$fields .= "`{$key}`, ";
$values .= is_numeric($value) ? $value : ("'{$value}'") ;
$values .= ", ";
$qb->setValue($key, is_numeric($value) ? $value : ("'{$value}'"));
}
$fields = substr($fields, 0, count($fields) -3);
$values = substr($values, 0, count($values) -3);
$q = "INSERT INTO $table_name ({$fields}) VALUES ({$values});";
$this->db->executeQuery($q);
$qb->execute();
}
}