Adding a few new test cases to verify that AllowedChildContentTypes are saved correctly on ContentTypes and MediaTypes.
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
namespace Umbraco.Core.Persistence.Querying
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Sql Translator for translating a <see cref="IQuery"/> object to Sql
|
||||
/// Represents the Sql Translator for translating a IQuery object to Sql
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class SqlTranslator<T>
|
||||
internal class SqlTranslator<T>
|
||||
{
|
||||
private readonly Sql _sql;
|
||||
|
||||
|
||||
54
src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs
Normal file
54
src/Umbraco.Tests/LegacyApi/MediaTypeTests.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using umbraco.cms.businesslogic.media;
|
||||
|
||||
namespace Umbraco.Tests.LegacyApi
|
||||
{
|
||||
[TestFixture]
|
||||
public class MediaTypeTests : BaseDatabaseFactoryTest
|
||||
{
|
||||
[SetUp]
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
CreateTestData();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Verify_AllowedChildContentTypes_On_MediaType()
|
||||
{
|
||||
// Arrange
|
||||
var folder = MediaType.GetByAlias("Folder");
|
||||
var folderStructure = folder.AllowedChildContentTypeIDs.ToList();
|
||||
folderStructure.Add(1045);
|
||||
|
||||
// Act
|
||||
folder.AllowedChildContentTypeIDs = folderStructure.ToArray();
|
||||
folder.Save();
|
||||
|
||||
// Assert
|
||||
var updated = MediaType.GetByAlias("Folder");
|
||||
|
||||
Assert.That(updated.AllowedChildContentTypeIDs.Any(), Is.True);
|
||||
Assert.That(updated.AllowedChildContentTypeIDs.Any(x => x == 1045), Is.True);
|
||||
}
|
||||
|
||||
public void CreateTestData()
|
||||
{
|
||||
//Create and Save ContentType "video" -> 1045
|
||||
var videoMediaType = MockedContentTypes.CreateVideoMediaType();
|
||||
ServiceContext.ContentTypeService.Save(videoMediaType);
|
||||
}
|
||||
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -227,6 +228,48 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.That(contentType.PropertyGroups.Count(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Verify_AllowedChildContentTypes_On_ContentType()
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = RepositoryResolver.Current.ResolveByType<IContentTypeRepository>(unitOfWork);
|
||||
|
||||
var subpageContentType = MockedContentTypes.CreateSimpleContentType("umbSubpage", "Subpage");
|
||||
var simpleSubpageContentType = MockedContentTypes.CreateSimpleContentType("umbSimpleSubpage", "Simple Subpage");
|
||||
repository.AddOrUpdate(subpageContentType);
|
||||
repository.AddOrUpdate(simpleSubpageContentType);
|
||||
unitOfWork.Commit();
|
||||
|
||||
// Act
|
||||
var contentType = repository.Get(1045);
|
||||
contentType.AllowedContentTypes = new List<ContentTypeSort>
|
||||
{
|
||||
new ContentTypeSort
|
||||
{
|
||||
Alias = subpageContentType.Alias,
|
||||
Id = new Lazy<int>(() => subpageContentType.Id),
|
||||
SortOrder = 0
|
||||
},
|
||||
new ContentTypeSort
|
||||
{
|
||||
Alias = simpleSubpageContentType.Alias,
|
||||
Id = new Lazy<int>(() => simpleSubpageContentType.Id),
|
||||
SortOrder = 1
|
||||
}
|
||||
};
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
|
||||
//Assert
|
||||
var updated = repository.Get(1045);
|
||||
|
||||
Assert.That(updated.AllowedContentTypes.Any(), Is.True);
|
||||
Assert.That(updated.AllowedContentTypes.Any(x => x.Alias == subpageContentType.Alias), Is.True);
|
||||
Assert.That(updated.AllowedContentTypes.Any(x => x.Alias == simpleSubpageContentType.Alias), Is.True);
|
||||
}
|
||||
|
||||
public void CreateTestData()
|
||||
{
|
||||
//Create and Save ContentType "umbTextpage" -> 1045
|
||||
|
||||
@@ -158,6 +158,7 @@
|
||||
<Compile Include="CodeFirst\TypeInheritanceTest.cs" />
|
||||
<Compile Include="Configurations\FileSystemProviderTests.cs" />
|
||||
<Compile Include="ContentStores\PublishMediaStoreTests.cs" />
|
||||
<Compile Include="LegacyApi\MediaTypeTests.cs" />
|
||||
<Compile Include="Migrations\AlterMigrationTests.cs" />
|
||||
<Compile Include="Migrations\Upgrades\BaseUpgradeTest.cs" />
|
||||
<Compile Include="Migrations\FindingMigrationsTest.cs" />
|
||||
|
||||
Reference in New Issue
Block a user