* 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
127 lines
4.5 KiB
C#
127 lines
4.5 KiB
C#
using NUnit.Framework;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Cache;
|
|
using Umbraco.Cms.Core.Models.ContentPublishing;
|
|
using Umbraco.Cms.Core.Notifications;
|
|
using Umbraco.Cms.Core.PublishedCache;
|
|
using Umbraco.Cms.Core.Scoping;
|
|
using Umbraco.Cms.Core.Services;
|
|
using Umbraco.Cms.Core.Sync;
|
|
using Umbraco.Cms.Tests.Common.Testing;
|
|
using Umbraco.Cms.Tests.Integration.Testing;
|
|
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.PublishedCache.HybridCache;
|
|
|
|
[TestFixture]
|
|
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
|
|
internal sealed class DocumentHybridCacheScopeTests : UmbracoIntegrationTestWithContentEditing
|
|
{
|
|
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
|
{
|
|
builder.AddNotificationHandler<ContentTreeChangeNotification, ContentTreeChangeDistributedCacheNotificationHandler>();
|
|
builder.Services.AddUnique<IServerMessenger, ContentEventsTests.LocalServerMessenger>();
|
|
}
|
|
|
|
private IPublishedContentCache PublishedContentHybridCache => GetRequiredService<IPublishedContentCache>();
|
|
|
|
private IContentPublishingService ContentPublishingService => GetRequiredService<IContentPublishingService>();
|
|
|
|
private ICoreScopeProvider CoreScopeProvider => GetRequiredService<ICoreScopeProvider>();
|
|
|
|
[Test]
|
|
public async Task Can_Get_Correct_Content_After_Rollback_With_Id()
|
|
{
|
|
using (CoreScopeProvider.CreateCoreScope())
|
|
{
|
|
await ContentPublishingService.PublishAsync(
|
|
Textpage.Key.Value,
|
|
[new CulturePublishScheduleModel { Culture = "*" }],
|
|
Constants.Security.SuperUserKey);
|
|
}
|
|
|
|
// Act
|
|
var textPage = await PublishedContentHybridCache.GetByIdAsync(TextpageId);
|
|
|
|
// Published page should not be in cache, as we rolled scope back.
|
|
Assert.IsNull(textPage);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Get_Correct_Content_After_Rollback_With_Key()
|
|
{
|
|
using (CoreScopeProvider.CreateCoreScope())
|
|
{
|
|
await ContentPublishingService.PublishAsync(Textpage.Key.Value,
|
|
[new CulturePublishScheduleModel { Culture = "*" }],
|
|
Constants.Security.SuperUserKey);
|
|
}
|
|
|
|
// Act
|
|
var textPage = await PublishedContentHybridCache.GetByIdAsync(Textpage.Key.Value);
|
|
|
|
// Published page should not be in cache, as we rolled scope back.
|
|
Assert.IsNull(textPage);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Get_Document_After_Scope_Complete_With_Id()
|
|
{
|
|
using (var scope = CoreScopeProvider.CreateCoreScope())
|
|
{
|
|
await ContentPublishingService.PublishAsync(
|
|
Textpage.Key.Value,
|
|
[new CulturePublishScheduleModel { Culture = "*" }],
|
|
Constants.Security.SuperUserKey);
|
|
scope.Complete();
|
|
}
|
|
|
|
// Act
|
|
var publishedPage = await PublishedContentHybridCache.GetByIdAsync(TextpageId);
|
|
|
|
// Published page should not be in cache, as we rolled scope back.
|
|
Assert.IsNotNull(publishedPage);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Get_Document_After_Scope_Completes_With_Key()
|
|
{
|
|
using (var scope = CoreScopeProvider.CreateCoreScope())
|
|
{
|
|
await ContentPublishingService.PublishAsync(
|
|
Textpage.Key.Value,
|
|
[new CulturePublishScheduleModel { Culture = "*" }],
|
|
Constants.Security.SuperUserKey);
|
|
scope.Complete();
|
|
}
|
|
|
|
// Act
|
|
var publishedPage = await PublishedContentHybridCache.GetByIdAsync(Textpage.Key.Value);
|
|
|
|
// Published page should not be in cache, as we rolled scope back.
|
|
Assert.IsNotNull(publishedPage);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Save_And_Publish_In_Same_Scope()
|
|
{
|
|
var key = Guid.NewGuid();
|
|
using (var scope = CoreScopeProvider.CreateCoreScope())
|
|
{
|
|
Textpage.Key = key;
|
|
var result = await ContentEditingService.CreateAsync(Textpage, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(result);
|
|
var publishResult = await ContentPublishingService.PublishAsync(Textpage.Key.Value, new List<CulturePublishScheduleModel>
|
|
{
|
|
new() { Culture = "*" },
|
|
}, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(publishResult.Success);
|
|
|
|
scope.Complete();
|
|
}
|
|
|
|
var published = await PublishedContentHybridCache.GetByIdAsync(key);
|
|
Assert.IsNotNull(published);
|
|
}
|
|
}
|