From 43bdad59b6fc4dbb1e7bc4dfaa3b249074b7092f Mon Sep 17 00:00:00 2001 From: Lars-Erik Aabech Date: Thu, 20 Nov 2025 06:54:35 +0100 Subject: [PATCH] Integration Tests: Use empty temp folder for legacy lang config when using integration tests outside core (closes #20888) (#20889) * Use empty folder under temp as localized text source folder in non umbraco core integration tests. * Added clarifying comment to the GetLocalizedTextService override for tests --- .../UmbracoBuilderExtensions.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/Umbraco.Tests.Integration/DependencyInjection/UmbracoBuilderExtensions.cs b/tests/Umbraco.Tests.Integration/DependencyInjection/UmbracoBuilderExtensions.cs index 958d328c1b..51445c86e5 100644 --- a/tests/Umbraco.Tests.Integration/DependencyInjection/UmbracoBuilderExtensions.cs +++ b/tests/Umbraco.Tests.Integration/DependencyInjection/UmbracoBuilderExtensions.cs @@ -125,18 +125,15 @@ public static class UmbracoBuilderExtensions if (!currFolder.Exists) { - currFolder = new DirectoryInfo(Path.GetTempPath()); + // When Umbraco.Integration.Tests is installed in a "consumer" Umbraco site, the src/tests path might not be there. + // This replaces the folder reference with an empty folder under temp + // such that the LocalizedTextServiceFileSources don't blow up from directory not found, + // or reading random xml files from the base temp folder. + var tempPath = Path.GetTempPath(); + currFolder = new DirectoryInfo(Path.GetFullPath("Umbraco.Integration.Tests.Fake.SrcRoot", tempPath)); + currFolder.Create(); } - var uiProject = currFolder.GetDirectories("Umbraco.Web.UI", SearchOption.TopDirectoryOnly).FirstOrDefault(); - if (uiProject == null) - { - uiProject = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "Umbraco.Web.UI")); - uiProject.Create(); - } - - var mainLangFolder = new DirectoryInfo(Path.Combine(uiProject.FullName, Constants.System.DefaultUmbracoPath.TrimStart(Constants.CharArrays.TildeForwardSlash), "config", "lang")); - return new LocalizedTextServiceFileSources( loggerFactory.CreateLogger(), appCaches,