summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-07 20:13:16 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-07 20:13:16 +0100
commit1cc6fddead3f71d170557e99ef8676724cb58a6e (patch)
tree62afe797fb92bba787b98345264cbe10644c1863 /tests
parente30740648686c6b9e6743f8551487274d43b006c (diff)
parent190cc2bb6762c5f505e1e90bd582caa4fecb9cce (diff)
downloadnextcloud-server-1cc6fddead3f71d170557e99ef8676724cb58a6e.tar.gz
nextcloud-server-1cc6fddead3f71d170557e99ef8676724cb58a6e.zip
Merge pull request #21498 from owncloud/cleanup-OC_DB
Cleanup OC_DB methods
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/app.php6
-rw-r--r--tests/lib/db.php4
-rw-r--r--tests/lib/db/connection.php2
-rw-r--r--tests/lib/db/mdb2schemamanager.php4
-rw-r--r--tests/lib/db/migrator.php2
-rw-r--r--tests/lib/db/mysqlmigration.php2
-rw-r--r--tests/lib/db/sqlitemigration.php2
-rw-r--r--tests/lib/dbschema.php4
-rw-r--r--tests/lib/repair/repaircollation.php2
-rw-r--r--tests/lib/repair/repairinnodb.php2
-rw-r--r--tests/lib/repair/repairlegacystorage.php2
-rw-r--r--tests/lib/repair/repairsqliteautoincrement.php2
-rw-r--r--tests/lib/tags.php4
13 files changed, 19 insertions, 19 deletions
diff --git a/tests/lib/app.php b/tests/lib/app.php
index 1c38a1c161f..389c9e5d2cf 100644
--- a/tests/lib/app.php
+++ b/tests/lib/app.php
@@ -461,7 +461,7 @@ class Test_App extends \Test\TestCase {
$appConfig = $this->getMock(
'\OC\AppConfig',
array('getValues'),
- array(\OC_DB::getConnection()),
+ array(\OC::$server->getDatabaseConnection()),
'',
false
);
@@ -488,8 +488,8 @@ class Test_App extends \Test\TestCase {
* Restore the original app config service.
*/
private function restoreAppConfig() {
- \OC::$server->registerService('AppConfig', function ($c) {
- return new \OC\AppConfig(\OC_DB::getConnection());
+ \OC::$server->registerService('AppConfig', function (\OC\Server $c) {
+ return new \OC\AppConfig($c->getDatabaseConnection());
});
\OC::$server->registerService('AppManager', function (\OC\Server $c) {
return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager(), $c->getMemCacheFactory());
diff --git a/tests/lib/db.php b/tests/lib/db.php
index 95eca4774b7..88c9ee75b3b 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -111,11 +111,11 @@ class Test_DB extends \Test\TestCase {
public function testLastInsertId() {
$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result1 = OC_DB::executeAudited($query, array('insertid 1','uri_1'));
- $id1 = OC_DB::insertid('*PREFIX*'.$this->table2);
+ $id1 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2);
// we don't know the id we should expect, so insert another row
$result2 = OC_DB::executeAudited($query, array('insertid 2','uri_2'));
- $id2 = OC_DB::insertid('*PREFIX*'.$this->table2);
+ $id2 = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*'.$this->table2);
// now we can check if the two ids are in correct order
$this->assertGreaterThan($id1, $id2);
}
diff --git a/tests/lib/db/connection.php b/tests/lib/db/connection.php
index ab3b48b259f..348a5e31e09 100644
--- a/tests/lib/db/connection.php
+++ b/tests/lib/db/connection.php
@@ -40,7 +40,7 @@ class Connection extends \Test\TestCase {
protected static function dropTestTable()
{
if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') !== 'oci') {
- \OC_DB::dropTable('table');
+ \OC::$server->getDatabaseConnection()->dropTable('table');
}
}
diff --git a/tests/lib/db/mdb2schemamanager.php b/tests/lib/db/mdb2schemamanager.php
index e194e701d84..fd412bdec2d 100644
--- a/tests/lib/db/mdb2schemamanager.php
+++ b/tests/lib/db/mdb2schemamanager.php
@@ -24,7 +24,7 @@ class MDB2SchemaManager extends \Test\TestCase {
// do not drop the table for Oracle as it will create a bogus transaction
// that will break the following test suites requiring transactions
if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') !== 'oci') {
- \OC_DB::dropTable('table');
+ \OC::$server->getDatabaseConnection()->dropTable('table');
}
parent::tearDown();
@@ -32,7 +32,7 @@ class MDB2SchemaManager extends \Test\TestCase {
public function testAutoIncrement() {
- $connection = \OC_DB::getConnection();
+ $connection = \OC::$server->getDatabaseConnection();
if ($connection->getDatabasePlatform() instanceof OraclePlatform) {
$this->markTestSkipped('Adding auto increment columns in Oracle is not supported.');
}
diff --git a/tests/lib/db/migrator.php b/tests/lib/db/migrator.php
index a50c5f1b864..84a98c1e338 100644
--- a/tests/lib/db/migrator.php
+++ b/tests/lib/db/migrator.php
@@ -45,7 +45,7 @@ class Migrator extends \Test\TestCase {
parent::setUp();
$this->config = \OC::$server->getConfig();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$this->markTestSkipped('DB migration tests are not supported on OCI');
}
diff --git a/tests/lib/db/mysqlmigration.php b/tests/lib/db/mysqlmigration.php
index 50b9d91d4ee..51e8801dc3b 100644
--- a/tests/lib/db/mysqlmigration.php
+++ b/tests/lib/db/mysqlmigration.php
@@ -22,7 +22,7 @@ class TestMySqlMigration extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
}
diff --git a/tests/lib/db/sqlitemigration.php b/tests/lib/db/sqlitemigration.php
index 3674d452bae..f23f4d4ee86 100644
--- a/tests/lib/db/sqlitemigration.php
+++ b/tests/lib/db/sqlitemigration.php
@@ -22,7 +22,7 @@ class TestSqliteMigration extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->markTestSkipped("Test only relevant on Sqlite");
}
diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php
index 46d7559acc2..d96f8195770 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/dbschema.php
@@ -51,7 +51,7 @@ class Test_DBSchema extends \Test\TestCase {
* @medium
*/
public function testSchema() {
- $platform = \OC_DB::getConnection()->getDatabasePlatform();
+ $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
$this->doTestSchemaCreating();
$this->doTestSchemaChanging();
$this->doTestSchemaDumping();
@@ -94,7 +94,7 @@ class Test_DBSchema extends \Test\TestCase {
* @param string $table
*/
public function assertTableNotExist($table) {
- $platform = \OC_DB::getConnection()->getDatabasePlatform();
+ $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
if ($platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
// sqlite removes the tables after closing the DB
$this->assertTrue(true);
diff --git a/tests/lib/repair/repaircollation.php b/tests/lib/repair/repaircollation.php
index f9d921e88a4..8d609aeed38 100644
--- a/tests/lib/repair/repaircollation.php
+++ b/tests/lib/repair/repaircollation.php
@@ -48,7 +48,7 @@ class TestRepairCollation extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
$this->config = \OC::$server->getConfig();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
diff --git a/tests/lib/repair/repairinnodb.php b/tests/lib/repair/repairinnodb.php
index e7d2b83c224..5c73b931367 100644
--- a/tests/lib/repair/repairinnodb.php
+++ b/tests/lib/repair/repairinnodb.php
@@ -28,7 +28,7 @@ class RepairInnoDB extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
}
diff --git a/tests/lib/repair/repairlegacystorage.php b/tests/lib/repair/repairlegacystorage.php
index 44afd6125ab..3ae6578f7ec 100644
--- a/tests/lib/repair/repairlegacystorage.php
+++ b/tests/lib/repair/repairlegacystorage.php
@@ -99,7 +99,7 @@ class RepairLegacyStorages extends TestCase {
$numRows = $this->connection->executeUpdate($sql, array($storageId));
$this->assertEquals(1, $numRows);
- return \OC_DB::insertid('*PREFIX*storages');
+ return \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*storages');
}
/**
diff --git a/tests/lib/repair/repairsqliteautoincrement.php b/tests/lib/repair/repairsqliteautoincrement.php
index e3bb110191b..6f0c2cb8d28 100644
--- a/tests/lib/repair/repairsqliteautoincrement.php
+++ b/tests/lib/repair/repairsqliteautoincrement.php
@@ -38,7 +38,7 @@ class RepairSqliteAutoincrement extends \Test\TestCase {
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
$this->config = \OC::$server->getConfig();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->markTestSkipped("Test only relevant on Sqlite");
diff --git a/tests/lib/tags.php b/tests/lib/tags.php
index 537c898da13..91472d5ceb8 100644
--- a/tests/lib/tags.php
+++ b/tests/lib/tags.php
@@ -60,7 +60,7 @@ class Test_Tags extends \Test\TestCase {
}
protected function tearDown() {
- $conn = \OC_DB::getConnection();
+ $conn = \OC::$server->getDatabaseConnection();
$conn->executeQuery('DELETE FROM `*PREFIX*vcategory_to_object`');
$conn->executeQuery('DELETE FROM `*PREFIX*vcategory`');
@@ -199,7 +199,7 @@ class Test_Tags extends \Test\TestCase {
$tagId = $tagData[0]['id'];
$tagType = $tagData[0]['type'];
- $conn = \OC_DB::getConnection();
+ $conn = \OC::$server->getDatabaseConnection();
$statement = $conn->prepare(
'INSERT INTO `*PREFIX*vcategory_to_object` ' .
'(`objid`, `categoryid`, `type`) VALUES ' .