2024-10-02 13:36:26 +02:00
|
|
|
using NUnit.Framework;
|
2024-10-02 09:10:18 +02:00
|
|
|
using Umbraco.Cms.Core;
|
2024-10-28 15:31:39 +01:00
|
|
|
using Umbraco.Cms.Core.Cache;
|
2024-10-02 09:10:18 +02:00
|
|
|
using Umbraco.Cms.Core.Models.ContentEditing;
|
2024-10-28 15:31:39 +01:00
|
|
|
using Umbraco.Cms.Core.Notifications;
|
2024-10-02 09:10:18 +02:00
|
|
|
using Umbraco.Cms.Core.PublishedCache;
|
|
|
|
|
using Umbraco.Cms.Core.Services;
|
|
|
|
|
using Umbraco.Cms.Core.Services.OperationStatus;
|
2024-10-28 15:31:39 +01:00
|
|
|
using Umbraco.Cms.Core.Sync;
|
2024-10-02 09:10:18 +02:00
|
|
|
using Umbraco.Cms.Tests.Common.Testing;
|
|
|
|
|
using Umbraco.Cms.Tests.Integration.Testing;
|
2024-10-28 15:31:39 +01:00
|
|
|
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
|
|
|
|
|
2024-10-02 09:10:18 +02:00
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.PublishedCache.HybridCache;
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
2025-03-21 18:02:31 +01:00
|
|
|
internal sealed class DocumentHybridCacheTemplateTests : UmbracoIntegrationTestWithContentEditing
|
2024-10-02 09:10:18 +02:00
|
|
|
{
|
2024-10-28 15:31:39 +01:00
|
|
|
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
builder.AddNotificationHandler<ContentTreeChangeNotification, ContentTreeChangeDistributedCacheNotificationHandler>();
|
|
|
|
|
builder.Services.AddUnique<IServerMessenger, ContentEventsTests.LocalServerMessenger>();
|
|
|
|
|
}
|
2024-10-02 09:10:18 +02:00
|
|
|
|
|
|
|
|
private IPublishedContentCache PublishedContentHybridCache => GetRequiredService<IPublishedContentCache>();
|
|
|
|
|
|
|
|
|
|
private IContentEditingService ContentEditingService => GetRequiredService<IContentEditingService>();
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public async Task Can_Get_Document_After_Removing_Template()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
var textPageBefore = await PublishedContentHybridCache.GetByIdAsync(TextpageId, true);
|
|
|
|
|
Assert.AreEqual(textPageBefore.TemplateId, TemplateId);
|
|
|
|
|
var updateModel = new ContentUpdateModel();
|
|
|
|
|
{
|
|
|
|
|
updateModel.TemplateKey = null;
|
2025-04-23 14:54:51 +02:00
|
|
|
updateModel.Variants = [new() { Name = textPageBefore.Name }];
|
2024-10-02 09:10:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
var updateContentResult = await ContentEditingService.UpdateAsync(textPageBefore.Key, updateModel, Constants.Security.SuperUserKey);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.AreEqual(updateContentResult.Status, ContentEditingOperationStatus.Success);
|
|
|
|
|
var textPageAfter = await PublishedContentHybridCache.GetByIdAsync(TextpageId, true);
|
|
|
|
|
Assert.AreEqual(textPageAfter.TemplateId, null);
|
|
|
|
|
}
|
|
|
|
|
}
|