Merge remote-tracking branch 'origin/v8/dev' into v9/feature/merge_v8_03-11-2021
# Conflicts: # src/Umbraco.Core/Configuration/GlobalSettings.cs # src/Umbraco.Core/Configuration/IGlobalSettings.cs # src/Umbraco.Core/Constants-AppSettings.cs # src/Umbraco.Tests/Umbraco.Tests.csproj # src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs # src/Umbraco.Web.UI/umbraco/config/lang/en.xml # src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml # src/Umbraco.Web.UI/web.Template.config # src/Umbraco.Web/Editors/ContentTypeController.cs # src/Umbraco.Web/HealthCheck/Checks/Security/BaseHttpHeaderCheck.cs # tests/Umbraco.Tests.UnitTests/Umbraco.Core/Configurations/LanguageXmlTests.cs
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Configurations
|
||||
{
|
||||
[TestFixture]
|
||||
public class LanguageXmlTests
|
||||
{
|
||||
[Test]
|
||||
public void Can_Load_Language_Xml_Files()
|
||||
{
|
||||
var languageDirectory = GetLanguageDirectory();
|
||||
var readFilesCount = 0;
|
||||
var xmlDocument = new XmlDocument();
|
||||
foreach (var languageFile in languageDirectory.EnumerateFiles("*.xml"))
|
||||
{
|
||||
// Load will throw an exception if the XML isn't valid.
|
||||
xmlDocument.Load(languageFile.FullName);
|
||||
readFilesCount++;
|
||||
}
|
||||
|
||||
// Ensure that at least one file was read.
|
||||
Assert.AreNotEqual(0, readFilesCount);
|
||||
}
|
||||
|
||||
private static DirectoryInfo GetLanguageDirectory()
|
||||
{
|
||||
var testDirectoryPathParts = Path.GetDirectoryName(TestContext.CurrentContext.TestDirectory)
|
||||
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var solutionDirectoryPathParts = testDirectoryPathParts
|
||||
.Take(Array.IndexOf(testDirectoryPathParts, "tests"));
|
||||
var languageFolderPathParts = new List<string>(solutionDirectoryPathParts);
|
||||
var additionalPathParts = new[] { "Umbraco.Web.UI", "umbraco", "config", "lang" };
|
||||
languageFolderPathParts.AddRange(additionalPathParts);
|
||||
|
||||
// Hack for build-server - when this path is generated in that envrionment it's missing the "src" folder.
|
||||
// Not sure why, but if it's missing we'll add it in the right place.
|
||||
if (!languageFolderPathParts.Contains("src"))
|
||||
{
|
||||
languageFolderPathParts.Insert(languageFolderPathParts.Count - additionalPathParts.Length, "src");
|
||||
}
|
||||
|
||||
return new DirectoryInfo(string.Join(Path.DirectorySeparatorChar.ToString(), languageFolderPathParts));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user