From 71ed99f080ebcad48dcb2167c82fe259b90a3080 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 4 May 2018 18:13:06 +0200 Subject: [PATCH] Fix some tests --- src/Umbraco.Core/Models/ContentBase.cs | 2 +- src/Umbraco.Core/StringExtensions.cs | 1 - src/Umbraco.Tests/Integration/ContentEventsTests.cs | 2 +- src/Umbraco.Tests/Services/ContentServiceTests.cs | 8 ++++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentBase.cs b/src/Umbraco.Core/Models/ContentBase.cs index bbeb3f943e..80267a99a6 100644 --- a/src/Umbraco.Core/Models/ContentBase.cs +++ b/src/Umbraco.Core/Models/ContentBase.cs @@ -56,7 +56,7 @@ namespace Umbraco.Core.Models Id = 0; // no identity VersionId = 0; // no versions - SetName(culture, name); + SetName(name, culture); _contentTypeId = contentType.Id; _properties = properties ?? throw new ArgumentNullException(nameof(properties)); diff --git a/src/Umbraco.Core/StringExtensions.cs b/src/Umbraco.Core/StringExtensions.cs index 6c1bdb021c..98e831f73f 100644 --- a/src/Umbraco.Core/StringExtensions.cs +++ b/src/Umbraco.Core/StringExtensions.cs @@ -1163,7 +1163,6 @@ namespace Umbraco.Core public static string ToUrlSegment(this string text, string culture) { if (string.IsNullOrWhiteSpace(text)) throw new ArgumentNullOrEmptyException(nameof(text)); - if (culture == null) throw new ArgumentNullException(nameof(culture)); return Current.ShortStringHelper.CleanStringForUrlSegment(text, culture); } diff --git a/src/Umbraco.Tests/Integration/ContentEventsTests.cs b/src/Umbraco.Tests/Integration/ContentEventsTests.cs index 246626f0a8..73f95c44a7 100644 --- a/src/Umbraco.Tests/Integration/ContentEventsTests.cs +++ b/src/Umbraco.Tests/Integration/ContentEventsTests.cs @@ -76,7 +76,7 @@ namespace Umbraco.Tests.Integration { base.TearDown(); - _h1.Unbind(); + _h1?.Unbind(); // clear ALL events diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index 354ff85351..009020e6e4 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -978,7 +978,7 @@ namespace Umbraco.Tests.Services var content = new Content(string.Empty, -1, ServiceContext.ContentTypeService.Get("umbTextpage")); // Act & Assert - Assert.Throws(() => contentService.Save(content)); + Assert.Throws(() => contentService.Save(content)); } [Test] @@ -2562,7 +2562,11 @@ namespace Umbraco.Tests.Services Assert.AreEqual("name-fr", content2.GetName(langFr.IsoCode)); Assert.AreEqual("name-uk", content2.GetName(langUk.IsoCode)); - Assert.IsNull(content2.PublishName); // we haven't published InvariantNeutral + // we haven't published InvariantNeutral, but a document cannot be published without an invariant name, + // so when we tried and published for the first time above the french culture, the french name was used + // to populate the invariant name + Assert.AreEqual("name-fr", content2.PublishName); + Assert.AreEqual("name-fr", content2.GetPublishName(langFr.IsoCode)); Assert.AreEqual("name-uk", content2.GetPublishName(langUk.IsoCode));