diff options
Diffstat (limited to 'tests/lib/AppTest.php')
-rw-r--r-- | tests/lib/AppTest.php | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index b817d968910..e174a59bfaf 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -1,4 +1,5 @@ <?php + /** * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -10,6 +11,7 @@ namespace Test; use OC\App\AppManager; use OC\App\InfoParser; use OC\AppConfig; +use OC\Config\ConfigManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\IAppConfig; use OCP\ICacheFactory; @@ -18,6 +20,7 @@ use OCP\IDBConnection; use OCP\IGroupManager; use OCP\IUserManager; use OCP\IUserSession; +use OCP\Server; use OCP\ServerVersion; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; @@ -311,9 +314,7 @@ class AppTest extends \Test\TestCase { ]; } - /** - * @dataProvider appVersionsProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('appVersionsProvider')] public function testIsAppCompatible($ocVersion, $appInfo, $expectedResult): void { $this->assertEquals($expectedResult, \OC_App::isAppCompatible($ocVersion, $appInfo)); } @@ -465,12 +466,11 @@ class AppTest extends \Test\TestCase { /** * Test enabled apps - * - * @dataProvider appConfigValuesProvider */ + #[\PHPUnit\Framework\Attributes\DataProvider('appConfigValuesProvider')] public function testEnabledApps($user, $expectedApps, $forceAll): void { - $userManager = \OCP\Server::get(IUserManager::class); - $groupManager = \OCP\Server::get(IGroupManager::class); + $userManager = Server::get(IUserManager::class); + $groupManager = Server::get(IGroupManager::class); $user1 = $userManager->createUser(self::TEST_USER1, 'NotAnEasyPassword123456+'); $user2 = $userManager->createUser(self::TEST_USER2, 'NotAnEasyPassword123456_'); $user3 = $userManager->createUser(self::TEST_USER3, 'NotAnEasyPassword123456?'); @@ -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); @@ -518,19 +517,18 @@ class AppTest extends \Test\TestCase { * enabled apps more than once when a user is set. */ public function testEnabledAppsCache(): void { - $userManager = \OCP\Server::get(IUserManager::class); + $userManager = Server::get(IUserManager::class); $user1 = $userManager->createUser(self::TEST_USER1, 'NotAnEasyPassword123456+'); \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,8 +548,8 @@ class AppTest extends \Test\TestCase { private function setupAppConfigMock() { /** @var AppConfig|MockObject */ $appConfig = $this->getMockBuilder(AppConfig::class) - ->onlyMethods(['getValues']) - ->setConstructorArgs([\OCP\Server::get(IDBConnection::class)]) + ->onlyMethods(['searchValues']) + ->setConstructorArgs([Server::get(IDBConnection::class)]) ->disableOriginalConstructor() ->getMock(); @@ -567,13 +565,14 @@ class AppTest extends \Test\TestCase { private function registerAppConfig(AppConfig $appConfig) { $this->overwriteService(AppConfig::class, $appConfig); $this->overwriteService(AppManager::class, new AppManager( - \OCP\Server::get(IUserSession::class), - \OCP\Server::get(IConfig::class), - \OCP\Server::get(IGroupManager::class), - \OCP\Server::get(ICacheFactory::class), - \OCP\Server::get(IEventDispatcher::class), - \OCP\Server::get(LoggerInterface::class), - \OCP\Server::get(ServerVersion::class), + Server::get(IUserSession::class), + Server::get(IConfig::class), + Server::get(IGroupManager::class), + Server::get(ICacheFactory::class), + Server::get(IEventDispatcher::class), + Server::get(LoggerInterface::class), + Server::get(ServerVersion::class), + Server::get(ConfigManager::class), )); } @@ -622,10 +621,10 @@ class AppTest extends \Test\TestCase { /** * Test app info parser * - * @dataProvider appDataProvider * @param array $data * @param array $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('appDataProvider')] public function testParseAppInfo(array $data, array $expected): void { $this->assertSame($expected, \OC_App::parseAppInfo($data)); } |