aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-09-23 18:12:17 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-09-23 18:13:29 +0200
commitaf0b8fbd178bdbca159475a232a8b54ccb746df7 (patch)
treeb4781ab2a801ee8c212f93acb541da7ddddb4cc0 /apps
parentb80bc81579a09741f262b264d98196e92a262a1c (diff)
downloadnextcloud-server-af0b8fbd178bdbca159475a232a8b54ccb746df7.tar.gz
nextcloud-server-af0b8fbd178bdbca159475a232a8b54ccb746df7.zip
fix(tests): Fix tests now that trashbin listens to events properly
Hooks are cleared in test bootstrap so switching to events activates them in tests. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/tests/Command/DeleteOrphanedFilesTest.php28
1 files changed, 11 insertions, 17 deletions
diff --git a/apps/files/tests/Command/DeleteOrphanedFilesTest.php b/apps/files/tests/Command/DeleteOrphanedFilesTest.php
index 1205e204ec4..6e9fbead34e 100644
--- a/apps/files/tests/Command/DeleteOrphanedFilesTest.php
+++ b/apps/files/tests/Command/DeleteOrphanedFilesTest.php
@@ -9,7 +9,9 @@ namespace OCA\Files\Tests\Command;
use OC\Files\View;
use OCA\Files\Command\DeleteOrphanedFiles;
+use OCP\Files\IRootFolder;
use OCP\Files\StorageNotAvailableException;
+use OCP\IDBConnection;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
@@ -23,25 +25,14 @@ use Test\TestCase;
*/
class DeleteOrphanedFilesTest extends TestCase {
- /**
- * @var DeleteOrphanedFiles
- */
- private $command;
-
- /**
- * @var \OCP\IDBConnection
- */
- private $connection;
-
- /**
- * @var string
- */
- private $user1;
+ private DeleteOrphanedFiles $command;
+ private IDBConnection $connection;
+ private string $user1;
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
+ $this->connection = \OCP\Server::get(IDBConnection::class);
$this->user1 = $this->getUniqueID('user1_');
@@ -90,12 +81,13 @@ class DeleteOrphanedFilesTest extends TestCase {
->disableOriginalConstructor()
->getMock();
+ $rootFolder = \OCP\Server::get(IRootFolder::class);
+
// scan home storage so that mounts are properly setup
- \OC::$server->getRootFolder()->getUserFolder($this->user1)->getStorage()->getScanner()->scan('');
+ $rootFolder->getUserFolder($this->user1)->getStorage()->getScanner()->scan('');
$this->loginAsUser($this->user1);
-
$view = new View('/' . $this->user1 . '/');
$view->mkdir('files/test');
@@ -132,6 +124,8 @@ class DeleteOrphanedFilesTest extends TestCase {
$this->assertCount(0, $this->getFile($fileInfo->getId()), 'Asserts that file gets cleaned up');
$this->assertCount(0, $this->getMounts($numericStorageId), 'Asserts that mount gets cleaned up');
+ // Rescan folder to add back to cache before deleting
+ $rootFolder->getUserFolder($this->user1)->getStorage()->getScanner()->scan('');
// since we deleted the storage it might throw a (valid) StorageNotAvailableException
try {
$view->unlink('files/test');