aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/ViewTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Files/ViewTest.php')
-rw-r--r--tests/lib/Files/ViewTest.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 53e5855d0e9..d611df372e6 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -25,6 +25,7 @@ use OCP\Files\ForbiddenException;
use OCP\Files\GenericFileException;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Storage\IStorage;
+use OCP\Files\Storage\IStorageFactory;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
@@ -154,7 +155,7 @@ class ViewTest extends \Test\TestCase {
$this->userObject->delete();
$this->groupObject->delete();
- $mountProviderCollection = \OC::$server->getMountProviderCollection();
+ $mountProviderCollection = \OCP\Server::get(\OCP\Files\Config\IMountProviderCollection::class);
self::invokePrivate($mountProviderCollection, 'providers', [[]]);
parent::tearDown();
@@ -518,10 +519,10 @@ class ViewTest extends \Test\TestCase {
}
public function moveBetweenStorages($storage1, $storage2) {
- Filesystem::mount($storage1, [], '/');
- Filesystem::mount($storage2, [], '/substorage');
+ Filesystem::mount($storage1, [], '/' . $this->user . '/');
+ Filesystem::mount($storage2, [], '/' . $this->user . '/substorage');
- $rootView = new View('');
+ $rootView = new View('/' . $this->user);
$rootView->rename('foo.txt', 'substorage/folder/foo.txt');
$this->assertFalse($rootView->file_exists('foo.txt'));
$this->assertTrue($rootView->file_exists('substorage/folder/foo.txt'));
@@ -941,14 +942,16 @@ class ViewTest extends \Test\TestCase {
$storage = new Temporary([]);
$scanner = $storage->getScanner();
Filesystem::mount($storage, [], '/test/');
- $storage->file_put_contents('test.part', 'foobar');
+ $sizeWritten = $storage->file_put_contents('test.part', 'foobar');
$scanner->scan('');
$view = new View('/test');
$info = $view->getFileInfo('test.part');
$this->assertInstanceOf('\OCP\Files\FileInfo', $info);
$this->assertNull($info->getId());
+ $this->assertEquals(6, $sizeWritten);
$this->assertEquals(6, $info->getSize());
+ $this->assertEquals('foobar', $view->file_get_contents('test.part'));
}
public static function absolutePathProvider(): array {
@@ -1623,7 +1626,7 @@ class ViewTest extends \Test\TestCase {
->method('getMountsForUser')
->willReturn($mounts);
- $mountProviderCollection = \OC::$server->getMountProviderCollection();
+ $mountProviderCollection = \OCP\Server::get(\OCP\Files\Config\IMountProviderCollection::class);
$mountProviderCollection->registerProvider($mountProvider);
return $mounts;
@@ -1947,6 +1950,8 @@ class ViewTest extends \Test\TestCase {
/* Pause trash to avoid the trashbin intercepting rmdir and unlink calls */
Server::get(ITrashManager::class)->pauseTrash();
+ /* Same thing with encryption wrapper */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
Filesystem::mount($storage, [], $this->user . '/');
@@ -2097,6 +2102,8 @@ class ViewTest extends \Test\TestCase {
/* Pause trash to avoid the trashbin intercepting rmdir and unlink calls */
Server::get(ITrashManager::class)->pauseTrash();
+ /* Same thing with encryption wrapper */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
Filesystem::mount($storage, [], $this->user . '/');
@@ -2238,6 +2245,9 @@ class ViewTest extends \Test\TestCase {
$sourcePath = 'original.txt';
$targetPath = 'target.txt';
+ /* Disable encryption wrapper to avoid it intercepting mocked call */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
+
Filesystem::mount($storage, [], $this->user . '/');
$storage->mkdir('files');
$view->file_put_contents($sourcePath, 'meh');
@@ -2291,6 +2301,9 @@ class ViewTest extends \Test\TestCase {
$sourcePath = 'original.txt';
$targetPath = 'target.txt';
+ /* Disable encryption wrapper to avoid it intercepting mocked call */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
+
Filesystem::mount($storage, [], $this->user . '/');
$storage->mkdir('files');
$view->file_put_contents($sourcePath, 'meh');
@@ -2427,6 +2440,9 @@ class ViewTest extends \Test\TestCase {
$sourcePath = 'original.txt';
$targetPath = 'substorage/target.txt';
+ /* Disable encryption wrapper to avoid it intercepting mocked call */
+ Server::get(IStorageFactory::class)->removeStorageWrapper('oc_encryption');
+
Filesystem::mount($storage, [], $this->user . '/');
Filesystem::mount($storage2, [], $this->user . '/files/substorage');
$storage->mkdir('files');