Browse Source
chore(tests): Adapt AppManager test to the use of searchValues
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/52793/head
Côme Chilliet
1 year ago
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
3 changed files with
15 additions and
5 deletions
-
lib/private/App/AppManager.php
-
tests/lib/App/AppManagerTest.php
-
tests/lib/AppTest.php
|
|
|
@ -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(); |
|
|
|
|