From 891bd437db841ff2ced12dadcae00210310dddab Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Wed, 14 Jul 2021 13:54:26 +0200 Subject: [PATCH] Fix failing tests by adding property group aliases --- .../Mapping/ContentTypeModelMappingTests.cs | 9 ++++++++ .../Repositories/ContentTypeRepositoryTest.cs | 7 ++++-- .../Mapping/ContentTypeMapDefinition.cs | 22 +++++-------------- .../Models/Mapping/PropertyTypeGroupMapper.cs | 10 ++++----- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs index 1480253958..32847408ca 100644 --- a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs @@ -478,6 +478,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 222, Name = "Group 1", + Alias = "group1", SortOrder = 1, Properties = new[] { @@ -549,6 +550,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 222, Name = "Group 1", + Alias = "group1", SortOrder = 1, Properties = new[] { @@ -961,6 +963,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 987, Name = "Tab 1", + Alias = "tab1", SortOrder = 0, Inherited = false, Properties = new[] @@ -1010,6 +1013,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 987, Name = "Tab 1", + Alias = "tab1", SortOrder = 0, Inherited = false, Properties = new[] @@ -1062,6 +1066,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 987, Name = "Tab 1", + Alias = "tab1", SortOrder = 0, Inherited = false, Properties = new[] @@ -1109,6 +1114,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 987, Name = "Tab 1", + Alias = "tab1", SortOrder = 0, Inherited = false, Properties = new[] @@ -1134,6 +1140,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 894, Name = "Tab 2", + Alias = "tab2", SortOrder = 0, Inherited = true, Properties = new[] @@ -1189,6 +1196,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 987, Name = "Tab 1", + Alias = "tab1", SortOrder = 0, Inherited = false, Properties = new[] @@ -1214,6 +1222,7 @@ namespace Umbraco.Tests.Models.Mapping { Id = 894, Name = "Tab 2", + Alias = "tab2", SortOrder = 0, Inherited = true, Properties = new[] diff --git a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs index 93a6daecde..6b35a79eb2 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/ContentTypeRepositoryTest.cs @@ -434,9 +434,12 @@ namespace Umbraco.Tests.Persistence.Repositories { Inherited = x.Inherited, Id = x.Id, - Properties = x.Properties, + Key = x.Key, + Type = x.Type, + Name = x.Name, + Alias = x.Alias, SortOrder = x.SortOrder, - Name = x.Name + Properties = x.Properties }).ToArray() }; } diff --git a/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs index 191201d348..52dbe549c2 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentTypeMapDefinition.cs @@ -298,9 +298,7 @@ namespace Umbraco.Web.Models.Mapping // Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate -Key -PropertyTypes private static void Map(PropertyGroupBasic source, PropertyGroup target, MapperContext context) { - if (source.Id > 0) - target.Id = source.Id; - + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; @@ -311,9 +309,7 @@ namespace Umbraco.Web.Models.Mapping // Umbraco.Code.MapAll -CreateDate -UpdateDate -DeleteDate -Key -PropertyTypes private static void Map(PropertyGroupBasic source, PropertyGroup target, MapperContext context) { - if (source.Id > 0) - target.Id = source.Id; - + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; @@ -324,32 +320,26 @@ namespace Umbraco.Web.Models.Mapping // Umbraco.Code.MapAll -ContentTypeId -ParentTabContentTypes -ParentTabContentTypeNames private static void Map(PropertyGroupBasic source, PropertyGroupDisplay target, MapperContext context) { - if (source.Id > 0) - target.Id = source.Id; - + target.Inherited = source.Inherited; + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; target.Alias = source.Alias; target.SortOrder = source.SortOrder; - - target.Inherited = source.Inherited; target.Properties = context.MapEnumerable(source.Properties); } // Umbraco.Code.MapAll -ContentTypeId -ParentTabContentTypes -ParentTabContentTypeNames private static void Map(PropertyGroupBasic source, PropertyGroupDisplay target, MapperContext context) { - if (source.Id > 0) - target.Id = source.Id; - + target.Inherited = source.Inherited; + target.Id = source.Id; target.Key = source.Key; target.Type = source.Type; target.Name = source.Name; target.Alias = source.Alias; target.SortOrder = source.SortOrder; - - target.Inherited = source.Inherited; target.Properties = context.MapEnumerable(source.Properties); } diff --git a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupMapper.cs b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupMapper.cs index d4e002bc78..8b0abd315c 100644 --- a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupMapper.cs @@ -80,10 +80,10 @@ namespace Umbraco.Web.Models.Mapping Name = propertyGroup.Name, Alias = propertyGroup.Alias, SortOrder = propertyGroup.SortOrder, + Properties = MapProperties(propertyGroup.PropertyTypes, source, propertyGroup.Id, false), ContentTypeId = source.Id }; - group.Properties = MapProperties(propertyGroup.PropertyTypes, source, propertyGroup.Id, false); groups.Add(group); } @@ -101,19 +101,19 @@ namespace Umbraco.Web.Models.Mapping var group = new PropertyGroupDisplay { + Inherited = true, Id = propertyGroup.Id, Key = propertyGroup.Key, Type = propertyGroup.Type, Name = propertyGroup.Name, Alias = propertyGroup.Alias, SortOrder = propertyGroup.SortOrder, - Inherited = true, + Properties = MapProperties(propertyGroup.PropertyTypes, definingContentType, propertyGroup.Id, true), ContentTypeId = definingContentType.Id, ParentTabContentTypes = new[] { definingContentType.Id }, ParentTabContentTypeNames = new[] { definingContentType.Name } }; - group.Properties = MapProperties(propertyGroup.PropertyTypes, definingContentType, propertyGroup.Id, true); groups.Add(group); } @@ -145,8 +145,8 @@ namespace Umbraco.Web.Models.Mapping Id = PropertyGroupBasic.GenericPropertiesGroupId, Name = "Generic properties", SortOrder = 999, - ContentTypeId = source.Id, - Properties = genericProperties + Properties = genericProperties, + ContentTypeId = source.Id }; groups.Add(genericGroup);