chore(trashbin): Fix configuration mocking in trashbin tests

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2024-11-26 17:37:09 +01:00 committed by Côme Chilliet
parent 14872c8040
commit 561b590c77

View file

@ -115,8 +115,11 @@ class TrashbinTest extends \Test\TestCase {
Server::get(IAppManager::class)->enableApp('files_trashbin');
$config = Server::get(IConfig::class);
$mockConfig = $this->createMock(IConfig::class);
$mockConfig
$mockConfig = $this->getMockBuilder(AllConfig::class)
->onlyMethods(['getSystemValue'])
->setConstructorArgs([Server::get(\OC\SystemConfig::class)])
->getMock();
$mockConfig->expects($this->any())
->method('getSystemValue')
->willReturnCallback(static function ($key, $default) use ($config) {
if ($key === 'filesystem_check_changes') {
@ -125,16 +128,6 @@ class TrashbinTest extends \Test\TestCase {
return $config->getSystemValue($key, $default);
}
});
$mockConfig
->method('getUserValue')
->willReturnCallback(static function ($userId, $appName, $key, $default = '') use ($config) {
return $config->getUserValue($userId, $appName, $key, $default);
});
$mockConfig
->method('getAppValue')
->willReturnCallback(static function ($appName, $key, $default = '') use ($config) {
return $config->getAppValue($appName, $key, $default);
});
$this->overwriteService(AllConfig::class, $mockConfig);
$this->trashRoot1 = '/' . self::TEST_TRASHBIN_USER1 . '/files_trashbin';