Fix tests - but we have to fix variant names

This commit is contained in:
Stephan
2018-06-08 10:49:51 +02:00
parent 3c9ba6502a
commit e4fafd55c8
3 changed files with 12 additions and 6 deletions

View File

@@ -1091,16 +1091,18 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
{
// here we have to ensure we have names and publish names, and to try and fix the situation if we have no name, see also: U4-11286
if (string.IsNullOrWhiteSpace(content.Name) && content.ContentType.Variations.DoesNotSupportCulture())
// invariant content must have an invariant name
if (content.ContentType.Variations.DoesNotSupportCulture() && string.IsNullOrWhiteSpace(content.Name))
throw new InvalidOperationException("Cannot save content with an empty name.");
// variant content must have at least one variant name
if (content.ContentType.Variations.DoesSupportCulture())
{
// no variant name = error
if (content.CultureNames.Count == 0)
throw new InvalidOperationException("Cannot save content with an empty name.");
// sync the invariant name to the default culture name if it's empty since we can't save with an empty invariant name.
// cannot save with an empty invariant name,
// if invariant name is missing, derive it from variant names
// fixme should we always sync the invariant name with the default culture name when updating?
if (string.IsNullOrWhiteSpace(content.Name))
{

View File

@@ -12,7 +12,7 @@ namespace Umbraco.Tests.Cache
[Test]
[Ignore("TEMP - fails")]
[Explicit("Testing for timeouts cannot work on VSTS.")]
public void Can_Add_And_Expire_Struct_Strongly_Typed_With_Null()
{
var now = DateTime.Now;

View File

@@ -471,7 +471,6 @@ namespace Umbraco.Tests.Services
}
[Test]
[Ignore("TEMP - fails")]
public void EntityService_Can_Get_Child_Content_By_ParentId_And_UmbracoObjectType_With_Variant_Names()
{
var service = ServiceContext.EntityService;
@@ -480,7 +479,8 @@ namespace Umbraco.Tests.Services
contentType.Variations = ContentVariation.CultureNeutral;
ServiceContext.ContentTypeService.Save(contentType);
var root = MockedContent.CreateSimpleContent(contentType);
var root = MockedContent.CreateSimpleContent(contentType);
root.SetName("Root", _langFr.IsoCode); // else cannot save
ServiceContext.ContentService.Save(root);
for (int i = 0; i < 10; i++)
@@ -491,6 +491,10 @@ namespace Umbraco.Tests.Services
c1.SetName("Test " + i + " - FR", _langFr.IsoCode);
c1.SetName("Test " + i + " - ES", _langEs.IsoCode);
}
else
{
c1.SetName("Test", _langFr.IsoCode); // else cannot save
}
ServiceContext.ContentService.Save(c1);
}