diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/dbschema.php | 54 |
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.'); } } } |