summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-06-13 11:55:37 +0200
committerGitHub <noreply@github.com>2022-06-13 11:55:37 +0200
commit8809de1eefbfa78998d9379a7040858d8e01e820 (patch)
tree4e58c2153749cb486472efc8bcc220318c0f50a0 /tests
parentc26ddf10de489fe86be6232d9d409b3acb930cec (diff)
parent8238582e59b7b6ec03318bcf81bf47cce54af320 (diff)
downloadnextcloud-server-8809de1eefbfa78998d9379a7040858d8e01e820.tar.gz
nextcloud-server-8809de1eefbfa78998d9379a7040858d8e01e820.zip
Merge pull request #31966 from nextcloud/unencrypted-size
store unencrypted size in the unencrypted_size column
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/DB/QueryBuilder/FunctionBuilderTest.php17
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php7
-rw-r--r--tests/lib/HelperStorageTest.php3
3 files changed, 24 insertions, 3 deletions
diff --git a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
index 08392b09d8d..0ea6e69c956 100644
--- a/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
+++ b/tests/lib/DB/QueryBuilder/FunctionBuilderTest.php
@@ -501,4 +501,21 @@ class FunctionBuilderTest extends TestCase {
$result->closeCursor();
$this->assertEquals(1, $row);
}
+
+ public function testCase() {
+ $query = $this->connection->getQueryBuilder();
+
+ $query->select($query->func()->case([
+ ['when' => $query->expr()->gt($query->expr()->literal(1, IQueryBuilder::PARAM_INT), $query->expr()->literal(2, IQueryBuilder::PARAM_INT)), 'then' => $query->expr()->literal('first')],
+ ['when' => $query->expr()->lt($query->expr()->literal(1, IQueryBuilder::PARAM_INT), $query->expr()->literal(2, IQueryBuilder::PARAM_INT)), 'then' => $query->expr()->literal('second')],
+ ['when' => $query->expr()->eq($query->expr()->literal(1, IQueryBuilder::PARAM_INT), $query->expr()->literal(2, IQueryBuilder::PARAM_INT)), 'then' => $query->expr()->literal('third')],
+ ], $query->createNamedParameter('else')));
+ $query->from('appconfig')
+ ->setMaxResults(1);
+
+ $result = $query->execute();
+ $row = $result->fetchOne();
+ $result->closeCursor();
+ $this->assertEquals('second', $row);
+ }
}
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index d26e5c499e7..ebb97a25c77 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -5,6 +5,7 @@ namespace Test\Files\Storage\Wrapper;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\Encryption\Update;
use OC\Encryption\Util;
+use OC\Files\Cache\CacheEntry;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
@@ -259,7 +260,7 @@ class EncryptionTest extends Storage {
->method('get')
->willReturnCallback(
function ($path) use ($encrypted) {
- return ['encrypted' => $encrypted, 'path' => $path, 'size' => 0, 'fileid' => 1];
+ return new CacheEntry(['encrypted' => $encrypted, 'path' => $path, 'size' => 0, 'fileid' => 1]);
}
);
@@ -332,7 +333,7 @@ class EncryptionTest extends Storage {
->disableOriginalConstructor()->getMock();
$cache->expects($this->any())
->method('get')
- ->willReturn(['encrypted' => true, 'path' => '/test.txt', 'size' => 0, 'fileid' => 1]);
+ ->willReturn(new CacheEntry(['encrypted' => true, 'path' => '/test.txt', 'size' => 0, 'fileid' => 1]));
$this->instance = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption')
->setConstructorArgs(
@@ -910,7 +911,7 @@ class EncryptionTest extends Storage {
if ($copyResult) {
$cache->expects($this->once())->method('get')
->with($sourceInternalPath)
- ->willReturn(['encrypted' => $encrypted, 'size' => 42]);
+ ->willReturn(new CacheEntry(['encrypted' => $encrypted, 'size' => 42]));
if ($encrypted) {
$instance->expects($this->once())->method('updateUnencryptedSize')
->with($mountPoint . $targetInternalPath, 42);
diff --git a/tests/lib/HelperStorageTest.php b/tests/lib/HelperStorageTest.php
index 6d7ea513d3f..d3f480502b2 100644
--- a/tests/lib/HelperStorageTest.php
+++ b/tests/lib/HelperStorageTest.php
@@ -104,6 +104,9 @@ class HelperStorageTest extends \Test\TestCase {
$extStorage->file_put_contents('extfile.txt', 'abcdefghijklmnopq');
$extStorage->getScanner()->scan(''); // update root size
+ $config = \OC::$server->getConfig();
+ $config->setSystemValue('quota_include_external_storage', false);
+
\OC\Files\Filesystem::mount($extStorage, [], '/' . $this->user . '/files/ext');
$storageInfo = \OC_Helper::getStorageInfo('');