Merge branch 'v8/8.6' into v8/8.7

This commit is contained in:
Sebastiaan Janssen
2021-01-11 11:34:44 +01:00
2 changed files with 90 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using Umbraco.Tests.Testing;
using Umbraco.Web.Models.ContentEditing;
using Content = Umbraco.Core.Models.Content;
namespace Umbraco.Tests.Persistence.Repositories
{
@@ -997,6 +998,88 @@ namespace Umbraco.Tests.Persistence.Repositories
}
}
[Test]
public void Can_Update_Variation_Of_Element_Type_Property()
{
var provider = TestObjects.GetScopeProvider(Logger);
using (var scope = provider.CreateScope())
{
ContentTypeRepository repository;
var contentRepository = CreateRepository((IScopeAccessor) provider, out repository);
// Create elementType
var elementType = new ContentType(-1)
{
Alias = "elementType",
Name = "Element type",
Description = "Element type to use as compositions",
Icon = ".sprTreeDoc3",
Thumbnail = "doc.png",
SortOrder = 1,
CreatorId = 0,
Trashed = false,
IsElement = true,
Variations = ContentVariation.Nothing
};
var contentCollection = new PropertyTypeCollection(true);
contentCollection.Add(new PropertyType("test", ValueStorageType.Ntext)
{
Alias = "title",
Name = "Title",
Description = "",
Mandatory = false,
SortOrder = 1,
DataTypeId = Constants.DataTypes.Textbox,
LabelOnTop = true,
Variations = ContentVariation.Nothing
});
elementType.PropertyGroups.Add(new PropertyGroup(contentCollection) {Name = "Content", SortOrder = 1});
elementType.ResetDirtyProperties(false);
elementType.SetDefaultTemplate(new Template("ElementType", "elementType"));
repository.Save(elementType);
// Create the basic "home" doc type that uses element type as comp
var docType = new ContentType(-1)
{
Alias = "home",
Name = "Home",
Description = "Home containing elementType",
Icon = ".sprTreeDoc3",
Thumbnail = "doc.png",
SortOrder = 1,
CreatorId = 0,
Trashed = false,
Variations = ContentVariation.Nothing
};
var comp = new List<IContentTypeComposition>();
comp.Add(elementType);
docType.ContentTypeComposition = comp;
repository.Save(docType);
// Create "home" content
var content = new Content("Home", -1, docType){Level = 1, SortOrder = 1, CreatorId = 0, WriterId = 0};
object obj = new {title = "test title"};
content.PropertyValues(obj);
content.ResetDirtyProperties(false);
contentRepository.Save(content);
// Update variation on element type
elementType.Variations = ContentVariation.Culture;
elementType.PropertyTypes.First().Variations = ContentVariation.Culture;
repository.Save(elementType);
// Update variation on doc type
docType.Variations = ContentVariation.Culture;
repository.Save(docType);
// Re fetch renewedContent and make sure that the culture has been set.
var renewedContent = ServiceContext.ContentService.GetById(content.Id);
var hasCulture = renewedContent.Properties["title"].Values.First().Culture != null;
Assert.That(hasCulture, Is.True);
}
}
public void CreateTestData()
{
//Create and Save ContentType "umbTextpage" -> (NodeDto.NodeIdSeed)