From 7ed583cb8ee64f77696b0e23f79d8d1b4038bcbc Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Thu, 12 Sep 2024 16:17:19 +0200 Subject: chore: Migrate cleanAppId and getAppPath calls to IAppManager from OC_App MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/apps.php | 11 ++++++++--- tests/lib/App/AppManagerTest.php | 4 ++-- tests/lib/InfoXmlTest.php | 12 ++++++++++-- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/apps.php b/tests/apps.php index c01e364c0a8..c2015fecda9 100644 --- a/tests/apps.php +++ b/tests/apps.php @@ -44,10 +44,15 @@ function getSubclasses($parentClassName): array { } $apps = OC_App::getEnabledApps(); +$appManager = \OCP\Server::get(\OCP\App\IAppManager::class); foreach ($apps as $app) { - $dir = OC_App::getAppPath($app); - if (is_dir($dir . '/tests')) { - loadDirectory($dir . '/tests'); + try { + $dir = $appManager->getAppPath($app); + if (is_dir($dir . '/tests')) { + loadDirectory($dir . '/tests'); + } + } catch (\OCP\App\AppPathNotFoundException) { + /* ignore */ } } diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php index 82a3f0d2045..ac470c00335 100644 --- a/tests/lib/App/AppManagerTest.php +++ b/tests/lib/App/AppManagerTest.php @@ -341,7 +341,7 @@ class AppManagerTest extends TestCase { $manager->expects($this->once()) ->method('getAppPath') ->with('test') - ->willReturn(null); + ->willReturn(''); $manager->expects($this->once()) ->method('getAppInfo') @@ -402,7 +402,7 @@ class AppManagerTest extends TestCase { $manager->expects($this->once()) ->method('getAppPath') ->with('test') - ->willReturn(null); + ->willReturn(''); $manager->expects($this->once()) ->method('getAppInfo') diff --git a/tests/lib/InfoXmlTest.php b/tests/lib/InfoXmlTest.php index 702eca4c0ce..1527e363bd7 100644 --- a/tests/lib/InfoXmlTest.php +++ b/tests/lib/InfoXmlTest.php @@ -7,6 +7,7 @@ namespace Test; use OCP\App\IAppManager; +use OCP\Server; /** * Class InfoXmlTest @@ -15,6 +16,13 @@ use OCP\App\IAppManager; * @package Test */ class InfoXmlTest extends TestCase { + private IAppManager $appManager; + + protected function setUp(): void { + parent::setUp(); + $this->appManager = Server::get(IAppManager::class); + } + public function dataApps() { return [ ['admin_audit'], @@ -45,8 +53,8 @@ class InfoXmlTest extends TestCase { * @param string $app */ public function testClasses($app) { - $appInfo = \OCP\Server::get(IAppManager::class)->getAppInfo($app); - $appPath = \OC_App::getAppPath($app); + $appInfo = $this->appManager->getAppInfo($app); + $appPath = $this->appManager->getAppPath($app); \OC_App::registerAutoloading($app, $appPath); //Add the appcontainer -- cgit v1.2.3