aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2024-09-24 17:15:39 +0200
committerGitHub <noreply@github.com>2024-09-24 17:15:39 +0200
commit280f6df66c199b9e72c23ffa921bbdad7c68d3c0 (patch)
treeb26ff144caabbe4094fbdd710dc6dfbab9b0cd22 /tests
parente247c260715c0dc7db7b4c0649413bed2629aafa (diff)
parent4adf5fd5b0f409d9f6bd7ffd8b4293e4a1cfa03c (diff)
downloadnextcloud-server-280f6df66c199b9e72c23ffa921bbdad7c68d3c0.tar.gz
nextcloud-server-280f6df66c199b9e72c23ffa921bbdad7c68d3c0.zip
Merge pull request #32018 from nextcloud/cleanup/event/trashbin
Port files trashbin events to IEventDispatcher/IEventListener
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/ViewTest.php17
-rw-r--r--tests/lib/Security/CertificateManagerTest.php2
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 636280f89eb..133f6d123cf 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -16,6 +16,7 @@ use OC\Files\Storage\Storage;
use OC\Files\Storage\Temporary;
use OC\Files\View;
use OC\Share20\ShareDisableChecker;
+use OCA\Files_Trashbin\Trash\ITrashManager;
use OCP\Cache\CappedMemoryCache;
use OCP\Constants;
use OCP\Files\Config\IMountProvider;
@@ -26,9 +27,11 @@ use OCP\Files\Storage\IStorage;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
+use OCP\Server;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
use OCP\Util;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\HookHelper;
use Test\TestMoveableMountPoint;
use Test\Traits\UserTrait;
@@ -1858,11 +1861,14 @@ class ViewTest extends \Test\TestCase {
): void {
$view = new View('/' . $this->user . '/files/');
- /** @var Temporary|\PHPUnit\Framework\MockObject\MockObject $storage */
+ /** @var Temporary&MockObject $storage */
$storage = $this->getMockBuilder(Temporary::class)
->setMethods([$operation])
->getMock();
+ /* Pause trash to avoid the trashbin intercepting rmdir and unlink calls */
+ Server::get(ITrashManager::class)->pauseTrash();
+
Filesystem::mount($storage, [], $this->user . '/');
// work directly on disk because mkdir might be mocked
@@ -1898,6 +1904,9 @@ class ViewTest extends \Test\TestCase {
}
$this->assertEquals($expectedStrayLock, $this->getFileLockType($view, $lockedPath));
+
+ /* Resume trash to avoid side effects */
+ Server::get(ITrashManager::class)->resumeTrash();
}
/**
@@ -2007,6 +2016,9 @@ class ViewTest extends \Test\TestCase {
->setMethods([$operation])
->getMock();
+ /* Pause trash to avoid the trashbin intercepting rmdir and unlink calls */
+ Server::get(ITrashManager::class)->pauseTrash();
+
Filesystem::mount($storage, [], $this->user . '/');
// work directly on disk because mkdir might be mocked
@@ -2033,6 +2045,9 @@ class ViewTest extends \Test\TestCase {
}
$this->assertTrue($thrown, 'Exception was rethrown');
$this->assertNull($this->getFileLockType($view, $path), 'File got unlocked after exception');
+
+ /* Resume trash to avoid side effects */
+ Server::get(ITrashManager::class)->resumeTrash();
}
public function testLockBasicOperationUnlocksAfterLockException(): void {
diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php
index 095512d0b4f..1c168228b6a 100644
--- a/tests/lib/Security/CertificateManagerTest.php
+++ b/tests/lib/Security/CertificateManagerTest.php
@@ -41,7 +41,7 @@ class CertificateManagerTest extends \Test\TestCase {
$this->registerMount($this->username, $storage, '/' . $this->username . '/');
\OC_Util::tearDownFS();
- \OC_User::setUserId('');
+ \OC_User::setUserId($this->username);
\OC\Files\Filesystem::tearDown();
\OC_Util::setupFS($this->username);