From 31c01fa3da094897d2bffbbf2bd4848773c62c67 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 11 May 2023 17:51:55 +0200 Subject: fix(JSResourceLocator): Handle missing translations silently Signed-off-by: Ferdinand Thiessen --- tests/lib/Template/JSResourceLocatorTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/lib/Template/JSResourceLocatorTest.php') diff --git a/tests/lib/Template/JSResourceLocatorTest.php b/tests/lib/Template/JSResourceLocatorTest.php index 9ac6a32e22c..f5af138060a 100644 --- a/tests/lib/Template/JSResourceLocatorTest.php +++ b/tests/lib/Template/JSResourceLocatorTest.php @@ -26,6 +26,7 @@ namespace Test\Template; use OC\SystemConfig; use OC\Template\JSCombiner; use OC\Template\JSResourceLocator; +use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\Files\IAppData; use OCP\ICacheFactory; @@ -139,6 +140,27 @@ class JSResourceLocatorTest extends \Test\TestCase { $this->rrmdir($new_apps_path); } + public function testNotExistingTranslationHandledSilent() { + $this->appManager->expects($this->once()) + ->method('getAppPath') + ->with('core') + ->willThrowException(new AppPathNotFoundException()); + $this->appManager->expects($this->once()) + ->method('getAppWebPath') + ->with('core') + ->willThrowException(new AppPathNotFoundException()); + // Assert logger is not called + $this->logger->expects($this->never()) + ->method('error'); + + // Run the tests + $locator = $this->jsResourceLocator(); + $locator->find(["core/l10n/en.js"]); + + $resources = $locator->getResources(); + $this->assertCount(0, $resources); + } + public function testFindModuleJSWithFallback() { // First create new apps path, and a symlink to it $apps_dirname = $this->randomString(); -- cgit v1.2.3