mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
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>
This commit is contained in:
parent
b80bc81579
commit
af0b8fbd17
2 changed files with 12 additions and 18 deletions
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue