diff options
Diffstat (limited to 'apps/encryption/tests/lib/MigrationTest.php')
-rw-r--r-- | apps/encryption/tests/lib/MigrationTest.php | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index 6742de574bf..a05418c5f26 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -288,16 +288,16 @@ class MigrationTest extends \Test\TestCase { // delete default values set by the encryption app during initialization - /** @var \OC\DB\Connection $connection */ + /** @var \OCP\IDBConnection $connection */ $connection = \OC::$server->getDatabaseConnection(); - $query = $connection->createQueryBuilder(); - $query->delete('`*PREFIX*appconfig`') - ->where($query->expr()->eq('`appid`', ':appid')) + $query = $connection->getQueryBuilder(); + $query->delete('*PREFIX*appconfig') + ->where($query->expr()->eq('appid', $query->createParameter('appid'))) ->setParameter('appid', 'encryption'); $query->execute(); - $query = $connection->createQueryBuilder(); - $query->delete('`*PREFIX*preferences`') - ->where($query->expr()->eq('`appid`', ':appid')) + $query = $connection->getQueryBuilder(); + $query->delete('*PREFIX*preferences') + ->where($query->expr()->eq('appid', $query->createParameter('appid'))) ->setParameter('appid', 'encryption'); $query->execute(); } @@ -308,10 +308,10 @@ class MigrationTest extends \Test\TestCase { $m = new Migration(\OC::$server->getConfig(), new \OC\Files\View(), \OC::$server->getDatabaseConnection(), $this->logger); $m->updateDB(); - $this->verifyDB('`*PREFIX*appconfig`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*preferences`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*appconfig`', 'encryption', 3); - $this->verifyDB('`*PREFIX*preferences`', 'encryption', 1); + $this->verifyDB('*PREFIX*appconfig', 'files_encryption', 0); + $this->verifyDB('*PREFIX*preferences', 'files_encryption', 0); + $this->verifyDB('*PREFIX*appconfig', 'encryption', 3); + $this->verifyDB('*PREFIX*preferences', 'encryption', 1); } @@ -327,20 +327,20 @@ class MigrationTest extends \Test\TestCase { $m = new Migration(\OC::$server->getConfig(), new \OC\Files\View(), \OC::$server->getDatabaseConnection(), $this->logger); $m->updateDB(); - $this->verifyDB('`*PREFIX*appconfig`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*preferences`', 'files_encryption', 0); - $this->verifyDB('`*PREFIX*appconfig`', 'encryption', 3); - $this->verifyDB('`*PREFIX*preferences`', 'encryption', 1); + $this->verifyDB('*PREFIX*appconfig', 'files_encryption', 0); + $this->verifyDB('*PREFIX*preferences', 'files_encryption', 0); + $this->verifyDB('*PREFIX*appconfig', 'encryption', 3); + $this->verifyDB('*PREFIX*preferences', 'encryption', 1); // check if the existing values where overwritten correctly /** @var \OC\DB\Connection $connection */ $connection = \OC::$server->getDatabaseConnection(); - $query = $connection->createQueryBuilder(); - $query->select('`configvalue`') - ->from('`*PREFIX*appconfig`') + $query = $connection->getQueryBuilder(); + $query->select('configvalue') + ->from('*PREFIX*appconfig') ->where($query->expr()->andX( - $query->expr()->eq('`appid`', ':appid'), - $query->expr()->eq('`configkey`', ':configkey') + $query->expr()->eq('appid', $query->createParameter('appid')), + $query->expr()->eq('configkey', $query->createParameter('configkey')) )) ->setParameter('appid', 'encryption') ->setParameter('configkey', 'publicShareKeyId'); @@ -349,13 +349,13 @@ class MigrationTest extends \Test\TestCase { $this->assertTrue(isset($value['configvalue'])); $this->assertSame('share_id', $value['configvalue']); - $query = $connection->createQueryBuilder(); - $query->select('`configvalue`') - ->from('`*PREFIX*preferences`') + $query = $connection->getQueryBuilder(); + $query->select('configvalue') + ->from('*PREFIX*preferences') ->where($query->expr()->andX( - $query->expr()->eq('`appid`', ':appid'), - $query->expr()->eq('`configkey`', ':configkey'), - $query->expr()->eq('`userid`', ':userid') + $query->expr()->eq('appid', $query->createParameter('appid')), + $query->expr()->eq('configkey', $query->createParameter('configkey')), + $query->expr()->eq('userid', $query->createParameter('userid')) )) ->setParameter('appid', 'encryption') ->setParameter('configkey', 'recoverKeyEnabled') @@ -368,12 +368,12 @@ class MigrationTest extends \Test\TestCase { } public function verifyDB($table, $appid, $expected) { - /** @var \OC\DB\Connection $connection */ + /** @var \OCP\IDBConnection $connection */ $connection = \OC::$server->getDatabaseConnection(); - $query = $connection->createQueryBuilder(); - $query->select('`appid`') + $query = $connection->getQueryBuilder(); + $query->select('appid') ->from($table) - ->where($query->expr()->eq('`appid`', ':appid')) + ->where($query->expr()->eq('appid', $query->createParameter('appid'))) ->setParameter('appid', $appid); $result = $query->execute(); $values = $result->fetchAll(); @@ -392,11 +392,11 @@ class MigrationTest extends \Test\TestCase { // check results - /** @var \OC\DB\Connection $connection */ + /** @var \OCP\IDBConnection $connection */ $connection = \OC::$server->getDatabaseConnection(); - $query = $connection->createQueryBuilder(); + $query = $connection->getQueryBuilder(); $query->select('*') - ->from('`*PREFIX*filecache`'); + ->from('*PREFIX*filecache'); $result = $query->execute(); $entries = $result->fetchAll(); foreach($entries as $entry) { @@ -411,25 +411,25 @@ class MigrationTest extends \Test\TestCase { } public function prepareFileCache() { - /** @var \OC\DB\Connection $connection */ + /** @var \OCP\IDBConnection $connection */ $connection = \OC::$server->getDatabaseConnection(); - $query = $connection->createQueryBuilder(); - $query->delete('`*PREFIX*filecache`'); + $query = $connection->getQueryBuilder(); + $query->delete('*PREFIX*filecache'); $query->execute(); - $query = $connection->createQueryBuilder(); - $result = $query->select('`fileid`') - ->from('`*PREFIX*filecache`') + $query = $connection->getQueryBuilder(); + $result = $query->select('fileid') + ->from('*PREFIX*filecache') ->setMaxResults(1)->execute()->fetchAll(); $this->assertEmpty($result); - $query = $connection->createQueryBuilder(); - $query->insert('`*PREFIX*filecache`') + $query = $connection->getQueryBuilder(); + $query->insert('*PREFIX*filecache') ->values( array( - '`storage`' => ':storage', - '`path_hash`' => ':path_hash', - '`encrypted`' => ':encrypted', - '`size`' => ':size', - '`unencrypted_size`' => ':unencrypted_size' + 'storage' => $query->createParameter('storage'), + 'path_hash' => $query->createParameter('path_hash'), + 'encrypted' => $query->createParameter('encrypted'), + 'size' => $query->createParameter('size'), + 'unencrypted_size' => $query->createParameter('unencrypted_size'), ) ); for ($i = 1; $i < 20; $i++) { @@ -442,9 +442,9 @@ class MigrationTest extends \Test\TestCase { $query->execute() ); } - $query = $connection->createQueryBuilder(); - $result = $query->select('`fileid`') - ->from('`*PREFIX*filecache`') + $query = $connection->getQueryBuilder(); + $result = $query->select('fileid') + ->from('*PREFIX*filecache') ->execute()->fetchAll(); $this->assertSame(19, count($result)); } |