* Removing obsoleted code from ApiMediaQueryService.cs * Removing obsoleted code from ApiRichTextMarkupParserTests.cs * Removing obsoleted code from ContentCacheRefresher.cs * Removing obsoleted code from ContentFinderByUrlAlias.cs and adjusting its tests to use the new logic * Removing obsoleted code from ContentFinderByUrl.cs & its dependencies * Removing obsoleted code from ApiRichTextMarkupParserTests.cs * Removing obsoleted code from DocumentCache.cs & its dependencies * Removing obsoleted code from MediaCache.cs & its dependencies * Removing obsoleted code from PublishedCacheBase.cs & its dependencies * Removing obsoleted code from RenderNoContentController.cs and its tests * Removing obsoleted code from UmbracoRouteValueTransformer.cs * Removing obsoleted constructors from DefaultUrlProvider.cs * Removing accidental bookmark * Introducing a helper method to get the root keys in ApiMediaQueryService.cs * Removing obsoleted code from Cache classes * Removing unused imports * Refactoring to meet the CR * Added attribute to controller * Fixing missing using statement * Removing obsoleted constructor from ExternalLoginService.cs and making usages fit * Removing obsoleted method from IContentTypeFilter.cs * Removing obsoleted methods from IContentEditingService.cs * Removing obosoleted code from DocumentUrlService.cs * Removed obsoleted code from DataTypeService.cs * Removed obsoleted code from PublishStatusService.cs * Removing obsoleted code from the IContentPublishingService.cs and its dependencies. Also implementing a TODO in the service implementation * Removing obsoleted code from IRelationService.cs * Removing obsoleted code from ContentPublishingService.cs * Removing obsoleted code from ContentEditingService.cs * Removing obsoleted code from Constants-DataTypes.cs * Removing obsoleted code from IAction.cs and its implementations * Removing obsoleted code from IContentService.cs * Removing obsoleted code from DomainUtilities.cs * Removing obsoleted code from IIndexedEntitySearchService.cs and dependencies * Removing obsoleted code from UrlProvider.cs * Removing obsoleted code from AliasUrlProvider.cs * Removing obsoleted code from ApiContentRouteBuilder.cs * Removing obsoleted code from ApiPublishedContentCache.cs * Removing obsoleted class TemplateQueryResult.cs * Removing obsoleted code from ApiContentBuilder.cs * Removing obsoleted code from HealthCheck.cs * Removing obsoleted code from ContentTypeEditingService.cs * Removing obsoleted code from NewDefaultUrlProvider.cs * Removing obsoleted code from PublishedElementPropertyBase.cs * Removing obsoleted code from WebhookRequestService.cs * Bumping to obsolete in V18, due to usage in class that will be removed in V18 * Removing obsoleted code from PropertyValidationService.cs * Removing obsoleted code from AddUnroutableContentWarningsWhenPublishingNotificationHandler.cs * Removing obsoleted code from IMemberService.cs * Removing obsoleted code from DocumentCache.cs
146 lines
6.5 KiB
C#
146 lines
6.5 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Models.ContentEditing;
|
|
using Umbraco.Cms.Core.Models.ContentPublishing;
|
|
using Umbraco.Cms.Core.Models.ContentTypeEditing;
|
|
using Umbraco.Cms.Core.Services;
|
|
using Umbraco.Cms.Core.Services.ContentTypeEditing;
|
|
using Umbraco.Cms.Tests.Common.Builders;
|
|
using Umbraco.Cms.Tests.Common.TestHelpers;
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Testing;
|
|
|
|
public abstract class UmbracoIntegrationTestWithContentEditing : UmbracoIntegrationTest
|
|
{
|
|
protected IContentTypeEditingService ContentTypeEditingService => GetRequiredService<IContentTypeEditingService>();
|
|
|
|
protected ITemplateService TemplateService => GetRequiredService<ITemplateService>();
|
|
|
|
protected IContentEditingService ContentEditingService => (IContentEditingService)GetRequiredService<IContentEditingService>();
|
|
|
|
private IContentPublishingService ContentPublishingService => (IContentPublishingService)GetRequiredService<IContentPublishingService>();
|
|
|
|
protected int TemplateId { get; private set; }
|
|
|
|
protected ContentCreateModel Subpage1 { get; private set; }
|
|
|
|
protected ContentCreateModel Subpage2 { get; private set; }
|
|
|
|
protected ContentCreateModel PublishedTextPage { get; private set; }
|
|
|
|
protected ContentCreateModel Textpage { get; private set; }
|
|
|
|
protected ContentScheduleCollection ContentSchedule { get; private set; }
|
|
|
|
protected CultureAndScheduleModel CultureAndSchedule { get; private set; }
|
|
|
|
protected int TextpageId { get; private set; }
|
|
|
|
protected int PublishedTextPageId { get; private set; }
|
|
|
|
protected int Subpage1Id { get; private set; }
|
|
|
|
protected int Subpage2Id { get; private set; }
|
|
|
|
protected ContentTypeCreateModel ContentTypeCreateModel { get; private set; }
|
|
|
|
protected ContentTypeUpdateModel ContentTypeUpdateModel { get; private set; }
|
|
|
|
protected IContentType ContentType { get; private set; }
|
|
|
|
[SetUp]
|
|
public new void Setup() => CreateTestData();
|
|
|
|
protected async void CreateTestData()
|
|
{
|
|
// NOTE Maybe not the best way to create/save test data as we are using the services, which are being tested.
|
|
var template = TemplateBuilder.CreateTextPageTemplate("defaultTemplate");
|
|
await TemplateService.CreateAsync(template, Constants.Security.SuperUserKey);
|
|
TemplateId = template.Id;
|
|
// Create and Save ContentType "umbTextpage" -> 1051 (template), 1052 (content type)
|
|
ContentTypeCreateModel = ContentTypeEditingBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateKey: template.Key);
|
|
var contentTypeAttempt = await ContentTypeEditingService.CreateAsync(ContentTypeCreateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(contentTypeAttempt.Success);
|
|
|
|
var contentTypeResult = contentTypeAttempt.Result;
|
|
ContentTypeUpdateModel = ContentTypeUpdateHelper.CreateContentTypeUpdateModel(contentTypeResult); ContentTypeUpdateModel.AllowedContentTypes = new[]
|
|
{
|
|
new ContentTypeSort(contentTypeResult.Key, 0, ContentTypeCreateModel.Alias),
|
|
};
|
|
var updatedContentTypeResult = await ContentTypeEditingService.UpdateAsync(contentTypeResult, ContentTypeUpdateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(updatedContentTypeResult.Success);
|
|
ContentType = updatedContentTypeResult.Result;
|
|
|
|
// Create and Save Content "Homepage" based on "umbTextpage" -> 1053
|
|
Textpage = ContentEditingBuilder.CreateSimpleContent(ContentType.Key);
|
|
var createContentResultTextPage = await ContentEditingService.CreateAsync(Textpage, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(createContentResultTextPage.Success);
|
|
|
|
if (!Textpage.Key.HasValue)
|
|
{
|
|
throw new InvalidOperationException("The content page key is null.");
|
|
}
|
|
|
|
if (createContentResultTextPage.Result.Content != null)
|
|
{
|
|
TextpageId = createContentResultTextPage.Result.Content.Id;
|
|
}
|
|
|
|
// Sets the culture and schedule for the content, in this case, we are publishing immediately for all cultures
|
|
ContentSchedule = new ContentScheduleCollection();
|
|
CultureAndSchedule = new CultureAndScheduleModel
|
|
{
|
|
CulturesToPublishImmediately = new HashSet<string> { "*" }, Schedules = ContentSchedule,
|
|
};
|
|
|
|
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1054
|
|
PublishedTextPage = ContentEditingBuilder.CreateSimpleContent(ContentType.Key, "Published Page");
|
|
var createContentResultPublishPage = await ContentEditingService.CreateAsync(PublishedTextPage, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(createContentResultPublishPage.Success);
|
|
|
|
if (!PublishedTextPage.Key.HasValue)
|
|
{
|
|
throw new InvalidOperationException("The content page key is null.");
|
|
}
|
|
|
|
if (createContentResultPublishPage.Result.Content != null)
|
|
{
|
|
PublishedTextPageId = createContentResultPublishPage.Result.Content.Id;
|
|
}
|
|
|
|
var publishResult = await ContentPublishingService.PublishAsync(PublishedTextPage.Key.Value, [new CulturePublishScheduleModel()], Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(publishResult.Success);
|
|
|
|
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1055
|
|
Subpage1 = ContentEditingBuilder.CreateSimpleContent(ContentType.Key, "Text Page 1", Textpage.Key);
|
|
var createContentResultSubPage1 = await ContentEditingService.CreateAsync(Subpage1, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(createContentResultSubPage1.Success);
|
|
if (!Subpage1.Key.HasValue)
|
|
{
|
|
throw new InvalidOperationException("The content page key is null.");
|
|
}
|
|
|
|
if (createContentResultSubPage1.Result.Content != null)
|
|
{
|
|
Subpage1Id = createContentResultSubPage1.Result.Content.Id;
|
|
}
|
|
|
|
Subpage2 = ContentEditingBuilder.CreateSimpleContent(ContentType.Key, "Text Page 2", Textpage.Key);
|
|
var createContentResultSubPage2 = await ContentEditingService.CreateAsync(Subpage2, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(createContentResultSubPage2.Success);
|
|
if (!Subpage2.Key.HasValue)
|
|
{
|
|
throw new InvalidOperationException("The content page key is null.");
|
|
}
|
|
|
|
if (createContentResultSubPage2.Result.Content != null)
|
|
{
|
|
Subpage2Id = createContentResultSubPage2.Result.Content.Id;
|
|
}
|
|
}
|
|
}
|