aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-05-12 13:54:20 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-05-30 23:34:42 +0200
commit999f6216dcfea2d5344c2ceda744461e18d32241 (patch)
treef99dbdfcb889f8c3c870b6a4bf1e656f0874806b /tests
parentda6aae28ad0cb1bad3d0693f126a5436af64240d (diff)
downloadnextcloud-server-999f6216dcfea2d5344c2ceda744461e18d32241.tar.gz
nextcloud-server-999f6216dcfea2d5344c2ceda744461e18d32241.zip
- fix dropTable() and introduce tableExists()
- kill replaceDB() - this function is unused and it's implementation obviously wrong - add method annotation OC_DB_StatementWrapper::fetchAll - remove duplicate code in Test_DBSchema and reuse OC_DB::tableExists - remove unused variables
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/dbschema.php54
1 files changed, 5 insertions, 49 deletions
diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php
index cfa2d6fd9aa..c07e32a404e 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/dbschema.php
@@ -24,10 +24,8 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
$content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content );
file_put_contents( $this->schema_file2, $content );
- $prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
-
- $this->table1 = $prefix.$r.'cntcts_addrsbks';
- $this->table2 = $prefix.$r.'cntcts_cards';
+ $this->table1 = $r.'cntcts_addrsbks';
+ $this->table2 = $r.'cntcts_cards';
}
public function tearDown() {
@@ -74,51 +72,8 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
/**
* @param string $table
*/
- public function tableExist($table) {
-
- switch (OC_Config::getValue( 'dbtype', 'sqlite' )) {
- case 'sqlite':
- case 'sqlite3':
- $sql = "SELECT name FROM sqlite_master "
- . "WHERE type = 'table' AND name = ? "
- . "UNION ALL SELECT name FROM sqlite_temp_master "
- . "WHERE type = 'table' AND name = ?";
- $result = \OC_DB::executeAudited($sql, array($table, $table));
- break;
- case 'mysql':
- $sql = 'SHOW TABLES LIKE ?';
- $result = \OC_DB::executeAudited($sql, array($table));
- break;
- case 'pgsql':
- $sql = 'SELECT tablename AS table_name, schemaname AS schema_name '
- . 'FROM pg_tables WHERE schemaname NOT LIKE \'pg_%\' '
- . 'AND schemaname != \'information_schema\' '
- . 'AND tablename = ?';
- $result = \OC_DB::executeAudited($sql, array($table));
- break;
- case 'oci':
- $sql = 'SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME = ?';
- $result = \OC_DB::executeAudited($sql, array($table));
- break;
- case 'mssql':
- $sql = 'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ?';
- $result = \OC_DB::executeAudited($sql, array($table));
- break;
- }
-
- $name = $result->fetchOne();
- if ($name === $table) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * @param string $table
- */
public function assertTableExist($table) {
- $this->assertTrue($this->tableExist($table), 'Table ' . $table . ' does not exist');
+ $this->assertTrue(OC_DB::tableExists($table), 'Table ' . $table . ' does not exist');
}
/**
@@ -128,8 +83,9 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
$type=OC_Config::getValue( "dbtype", "sqlite" );
if( $type == 'sqlite' || $type == 'sqlite3' ) {
// sqlite removes the tables after closing the DB
+ $this->assertTrue(true);
} else {
- $this->assertFalse($this->tableExist($table), 'Table ' . $table . ' exists.');
+ $this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.');
}
}
}