mirror of
https://github.com/nextcloud/server.git
synced 2026-04-20 22:00:39 -04:00
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:
parent
e8370bf73a
commit
a2fdeccc31
3 changed files with 15 additions and 5 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue