Updating tests related to #U4-5986
This commit is contained in:
@@ -464,6 +464,91 @@ namespace Umbraco.Tests.Services
|
||||
Assert.AreNotEqual(clonedContentType.PropertyGroups.First(x => x.Name.StartsWith("Content")).Id, originalContentType.PropertyGroups.First(x => x.Name.StartsWith("Content")).Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Cannot_Add_Duplicate_PropertyType_Alias_To__Referenced_Composition()
|
||||
{
|
||||
//Related the second issue in screencast from this post http://issues.umbraco.org/issue/U4-5986
|
||||
|
||||
// Arrange
|
||||
var service = ServiceContext.ContentTypeService;
|
||||
|
||||
var parent = MockedContentTypes.CreateSimpleContentType();
|
||||
service.Save(parent);
|
||||
var child = MockedContentTypes.CreateSimpleContentType("simpleChildPage", "Simple Child Page", parent, true);
|
||||
service.Save(child);
|
||||
var composition = MockedContentTypes.CreateMetaContentType();
|
||||
service.Save(composition);
|
||||
|
||||
//Adding Meta-composition to child doc type
|
||||
child.AddContentType(composition);
|
||||
service.Save(child);
|
||||
|
||||
// Act
|
||||
var duplicatePropertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext)
|
||||
{
|
||||
Alias = "title", Name = "Title", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88
|
||||
};
|
||||
var added = composition.AddPropertyType(duplicatePropertyType, "Meta");
|
||||
service.Save(composition);
|
||||
|
||||
// Assert
|
||||
Assert.That(added, Is.True);
|
||||
Assert.DoesNotThrow(() => service.GetContentType("simpleChildPage"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Rename_PropertyGroup_With_Inherited_PropertyGroups()
|
||||
{
|
||||
//Related the first issue in screencast from this post http://issues.umbraco.org/issue/U4-5986
|
||||
|
||||
// Arrange
|
||||
var service = ServiceContext.ContentTypeService;
|
||||
|
||||
var page = MockedContentTypes.CreateSimpleContentType("page", "Page", null, false, "Content_");
|
||||
service.Save(page);
|
||||
var contentPage = MockedContentTypes.CreateSimpleContentType("contentPage", "Content Page", page, true);
|
||||
service.Save(contentPage);
|
||||
var composition = MockedContentTypes.CreateMetaContentType();
|
||||
composition.AddPropertyGroup("Content");
|
||||
service.Save(composition);
|
||||
//Adding Meta-composition to child doc type
|
||||
contentPage.AddContentType(composition);
|
||||
service.Save(contentPage);
|
||||
|
||||
// Act
|
||||
var propertyTypeOne = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext)
|
||||
{
|
||||
Alias = "testTextbox", Name = "Test Textbox", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88
|
||||
};
|
||||
var firstOneAdded = contentPage.AddPropertyType(propertyTypeOne, "Content_");
|
||||
var propertyTypeTwo = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext)
|
||||
{
|
||||
Alias = "anotherTextbox", Name = "Another Test Textbox", Description = "", HelpText = "", Mandatory = false, SortOrder = 1, DataTypeDefinitionId = -88
|
||||
};
|
||||
var secondOneAdded = contentPage.AddPropertyType(propertyTypeTwo, "Content");
|
||||
service.Save(contentPage);
|
||||
|
||||
Assert.That(page.PropertyGroups.Contains("Content_"), Is.True);
|
||||
var propertyGroup = page.PropertyGroups["Content_"];
|
||||
page.PropertyGroups.Add(new PropertyGroup{ Id = propertyGroup.Id, Name = "ContentTab", SortOrder = 0});
|
||||
service.Save(page);
|
||||
|
||||
// Assert
|
||||
Assert.That(firstOneAdded, Is.True);
|
||||
Assert.That(secondOneAdded, Is.True);
|
||||
|
||||
var contentType = service.GetContentType("contentPage");
|
||||
Assert.That(contentType, Is.Not.Null);
|
||||
|
||||
var compositionPropertyGroups = contentType.CompositionPropertyGroups;
|
||||
Assert.That(compositionPropertyGroups.Count(x => x.Name.Equals("Content_")), Is.EqualTo(0));
|
||||
|
||||
var propertyTypeCount = contentType.PropertyTypes.Count();
|
||||
var compPropertyTypeCount = contentType.CompositionPropertyTypes.Count();
|
||||
Assert.That(propertyTypeCount, Is.EqualTo(5));
|
||||
Assert.That(compPropertyTypeCount, Is.EqualTo(10));
|
||||
}
|
||||
|
||||
private ContentType CreateComponent()
|
||||
{
|
||||
var component = new ContentType(-1)
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public static ContentType CreateSimpleContentType(string alias, string name, IContentType parent = null, bool randomizeAliases = false)
|
||||
public static ContentType CreateSimpleContentType(string alias, string name, IContentType parent = null, bool randomizeAliases = false, string propertyGroupName = "Content")
|
||||
{
|
||||
var contentType = parent == null ? new ContentType(-1) : new ContentType(parent);
|
||||
var contentType = parent == null ? new ContentType(-1) : new ContentType(parent, alias);
|
||||
|
||||
contentType.Alias = alias;
|
||||
contentType.Name = name;
|
||||
@@ -110,7 +110,7 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TinyMCEAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("bodyText", randomizeAliases), Name = "Body Text", Description = "", HelpText = "", Mandatory = false, SortOrder = 2, DataTypeDefinitionId = -87 });
|
||||
contentCollection.Add(new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext) { Alias = RandomAlias("author", randomizeAliases) , Name = "Author", Description = "Name of the author", HelpText = "", Mandatory = false, SortOrder = 3, DataTypeDefinitionId = -88 });
|
||||
|
||||
contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = "Content", SortOrder = 1 });
|
||||
contentType.PropertyGroups.Add(new PropertyGroup(contentCollection) { Name = propertyGroupName, SortOrder = 1 });
|
||||
|
||||
//ensure that nothing is marked as dirty
|
||||
contentType.ResetDirtyProperties(false);
|
||||
@@ -167,6 +167,27 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public static ContentType CreateSimpleContentType(string alias, string name, PropertyTypeCollection collection, string propertyGroupName, IContentType parent = null)
|
||||
{
|
||||
var contentType = parent == null ? new ContentType(-1) : new ContentType(parent, alias);
|
||||
|
||||
contentType.Alias = alias;
|
||||
contentType.Name = name;
|
||||
contentType.Description = "ContentType used for simple text pages";
|
||||
contentType.Icon = ".sprTreeDoc3";
|
||||
contentType.Thumbnail = "doc2.png";
|
||||
contentType.SortOrder = 1;
|
||||
contentType.CreatorId = 0;
|
||||
contentType.Trashed = false;
|
||||
|
||||
contentType.PropertyGroups.Add(new PropertyGroup(collection) { Name = propertyGroupName, SortOrder = 1 });
|
||||
|
||||
//ensure that nothing is marked as dirty
|
||||
contentType.ResetDirtyProperties(false);
|
||||
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public static ContentType CreateSimpleContentType(string alias, string name, PropertyTypeCollection groupedCollection, PropertyTypeCollection nonGroupedCollection)
|
||||
{
|
||||
var contentType = CreateSimpleContentType(alias, name, groupedCollection);
|
||||
|
||||
Reference in New Issue
Block a user