chore(tests): Adapt AppManager test to the use of searchValues

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2025-06-02 18:05:40 +02:00
parent e8370bf73a
commit a2fdeccc31
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
3 changed files with 15 additions and 5 deletions

View file

@ -135,6 +135,7 @@ class AppManager implements IAppManager {
*/
private function getEnabledAppsValues(): array {
if (!$this->enabledAppsCache) {
/** @var array<string,string> */
$values = $this->getAppConfig()->searchValues('enabled', false, IAppConfig::VALUE_STRING);
$alwaysEnabledApps = $this->getAlwaysEnabledApps();

View file

@ -71,6 +71,17 @@ class AppManagerTest extends TestCase {
return $values;
}
});
$config->expects($this->any())
->method('searchValues')
->willReturnCallback(function ($key, $lazy, $type) use (&$appConfig) {
$values = [];
foreach ($appConfig as $appid => $appData) {
if (isset($appData[$key])) {
$values[$appid] = $appData[$key];
}
}
return $values;
});
return $config;
}

View file

@ -485,7 +485,7 @@ class AppTest extends \Test\TestCase {
\OC_User::setUserId($user);
$this->setupAppConfigMock()->expects($this->once())
->method('getValues')
->method('searchValues')
->willReturn(
[
'app3' => 'yes',
@ -495,7 +495,6 @@ class AppTest extends \Test\TestCase {
'appforgroup2' => '["group2"]',
'appforgroup12' => '["group2","group1"]',
]
);
$apps = \OC_App::getEnabledApps(false, $forceAll);
@ -524,13 +523,12 @@ class AppTest extends \Test\TestCase {
\OC_User::setUserId(self::TEST_USER1);
$this->setupAppConfigMock()->expects($this->once())
->method('getValues')
->method('searchValues')
->willReturn(
[
'app3' => 'yes',
'app2' => 'no',
]
);
$apps = \OC_App::getEnabledApps();
@ -550,7 +548,7 @@ class AppTest extends \Test\TestCase {
private function setupAppConfigMock() {
/** @var AppConfig|MockObject */
$appConfig = $this->getMockBuilder(AppConfig::class)
->onlyMethods(['getValues'])
->onlyMethods(['searchValues'])
->setConstructorArgs([\OCP\Server::get(IDBConnection::class)])
->disableOriginalConstructor()
->getMock();