Files

602 lines
21 KiB
C#
Raw Permalink Normal View History

Remove the non-controversial, straightforward obsoleted constructs for Umbraco 16 (#18661) * Removed obsoletes from IConfigManipulator. * Removed obsolete models builder extensions. * Removed the obsolete ContentDashboardSettings. * Removed the obsolete InstallMissingDatabase setting on GlobalSettings. * Removed obsolete NuCache settings. * Removed obsolete RuntimeMinificationSettings. * Removed obsolete health check constant. * Removed obsolete icon constant. * Removed obsolete telemetry constant. * Removed obsolete property and constructor on UmbracoBuilder. * Removed obsolete constructor on AuditNotificationsHandler. * Removed obsolete constructor on HTTP header health checks. * Removed obsolete constructor on MediaFileManager. * Removed obsolete GetDefaultFileContent on ViewHelper. * Remove obsoleted methods on embed providers. * Fix tests. * Removed obsolete constructors on BlockEditorDataConverter. * Removed obsolete SeedCacheDuration property on CacheSettings. * Removed obsolete PublishCulture on ContentRepositoryExtensions. * Removed obsolete MonitorLock. * Removed obsolete synchronous HasSavedValues from IDataTypeUsageService and IDataTypeUsageRepository. * Removed obsolete HasSavedPropertyValues from IPropertyTypeUsageService and IPropertyTypeUsageRepository. * Removed obsolete methods in ITrackedReferencesService and ITrackedReferencesRepository. * Removed obsolete DateValueEditor constructors. * Removed obsolete GetAutomaticRelationTypesAliases. * Removed obsolete constructor on TextOnlyValueEditor. * Removed obsolete constructors on RegexValidator and RequiredValidator. * Removed obsolete constructs on SliderValueConverter and TagsValueConverter. * Removed obsolete GetContentType methods from IPublishedCache. * Removed ContentFinderByIdPath. * Removed obsolete constructor on DefaultMediaUrlProvider. * Removed obsolete constructor on Domain. * Removed obsolete constructor on PublishedRequest. * Removed obsolete methods on CheckPermissions. * Removed obsolete GetUserId from IBackOfficeSecurity. * Removed obsolete methods on LegacyPasswordSecurity. * Removed obsolete constructors on AuditService. * Removed obsolete methods on IContentEditingService. * Remove obsolete constructors and methods on ContentService/IContentService. * Removed obsolete constructor in ContentTypeEditingService. * Removed obsolete constructor in MediaTypeEditingService. * Removed obsolete constructor in MemberTypeEditingService. * Removed obsolete constructor in ContentTypeService. * Removed obsolete constructors in ContentTypeServiceBase. * Removed obsolete constructors and methods in ContentVersionService. * Removed obsolete constructor in DataTypeUsageService. * Removed obsolete constructor in DomainService. * Removed obsolete constructor in FileService. * Removes obsolete AttemptMove from IContentService. * Removes obsolete SetPreventCleanup from IContentVersionService. * Removes obsolete GetReferences from IDataTypeService. * Removed obsolete SetConsentLevel from IMetricsConsentService. * Removed obsolete methods from IPackageDataInstallation. * Removed obsolete methods from IPackagingService. * Removed obsolete methods on ITwoFactorLoginService. Removed obsolete ITemporaryMediaService. * Removed obsolete constructor from MediaService, MemberTypeService and MediaTypeService. * More obsolete constructors. * Removed obsoleted overloads on IPropertyValidationService. * Fixed build for tests. * Removed obsolete constructor for PublicAccessService, UserService and RelationService. * Removed GetDefaultMemberType. * Removed obsolete user group functionality from IUserService. * Removed obsolete extension methods on IUserService. * Removed obsolete method from ITelemetryService. * Removed obsolete UdiParserServiceConnectors. * Removed obsolete method on ICookieManager. * Removed obsolete DynamicContext. * Removed obsolete XmlHelper. * Fixed failing integration tests. * Removed obsoletes in Umbraco.Cms.Api.Common * Removed obsoletes in Umbraco.Cms.Api.Delivery * Removed obsoletes in Umbraco.Cms.Api.Management * Removed obsoletes in Umbraco.Examine.Lucene * Removed obsoletes in Umbraco.Infrastructure * Fix failing delivery API contract integration test. * Made integration tests internal. * Removed obsoletes from web projects. * Fix build. * Removed Twitter OEmbed provider * Removed obsolete constructor on PublishedDataType. * Removed obsolete constructors on PublishedCacheBase. * Removed the obsolete PropertyEditorTagsExtensions. * Removed obsoletion properties on configuration response models (#18697) * Removed obsolete methods from server-side models. * Update client-side types and sdk. * Update client-side files. * Removed obsoletion of Utf8ToAsciiConverter.ToAsciiString overload. (#18694) * Removed obsolete method in UserService. (#18710) * Removed obsoleted group alias keys from being publicly available. (#18682) * Removed unneceessary ApiVersion attribute. * Clean-up obsoletions on MemberService (#18703) * Removed obsoleted method on MemberService, added future obsoletion to interface and updated all callers. * Removed obsoletion on member service method that's not obsolete on the interface.
2025-03-21 18:02:31 +01:00
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Models.ContentEditing;
V17 - Removing obsoleted code from Umbraco.Core (#20009) * 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
2025-08-28 12:09:59 +02:00
using Umbraco.Cms.Core.Models.ContentPublishing;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.PublishedCache;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;
using Umbraco.Cms.Tests.Common.Builders;
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)]
Remove the non-controversial, straightforward obsoleted constructs for Umbraco 16 (#18661) * Removed obsoletes from IConfigManipulator. * Removed obsolete models builder extensions. * Removed the obsolete ContentDashboardSettings. * Removed the obsolete InstallMissingDatabase setting on GlobalSettings. * Removed obsolete NuCache settings. * Removed obsolete RuntimeMinificationSettings. * Removed obsolete health check constant. * Removed obsolete icon constant. * Removed obsolete telemetry constant. * Removed obsolete property and constructor on UmbracoBuilder. * Removed obsolete constructor on AuditNotificationsHandler. * Removed obsolete constructor on HTTP header health checks. * Removed obsolete constructor on MediaFileManager. * Removed obsolete GetDefaultFileContent on ViewHelper. * Remove obsoleted methods on embed providers. * Fix tests. * Removed obsolete constructors on BlockEditorDataConverter. * Removed obsolete SeedCacheDuration property on CacheSettings. * Removed obsolete PublishCulture on ContentRepositoryExtensions. * Removed obsolete MonitorLock. * Removed obsolete synchronous HasSavedValues from IDataTypeUsageService and IDataTypeUsageRepository. * Removed obsolete HasSavedPropertyValues from IPropertyTypeUsageService and IPropertyTypeUsageRepository. * Removed obsolete methods in ITrackedReferencesService and ITrackedReferencesRepository. * Removed obsolete DateValueEditor constructors. * Removed obsolete GetAutomaticRelationTypesAliases. * Removed obsolete constructor on TextOnlyValueEditor. * Removed obsolete constructors on RegexValidator and RequiredValidator. * Removed obsolete constructs on SliderValueConverter and TagsValueConverter. * Removed obsolete GetContentType methods from IPublishedCache. * Removed ContentFinderByIdPath. * Removed obsolete constructor on DefaultMediaUrlProvider. * Removed obsolete constructor on Domain. * Removed obsolete constructor on PublishedRequest. * Removed obsolete methods on CheckPermissions. * Removed obsolete GetUserId from IBackOfficeSecurity. * Removed obsolete methods on LegacyPasswordSecurity. * Removed obsolete constructors on AuditService. * Removed obsolete methods on IContentEditingService. * Remove obsolete constructors and methods on ContentService/IContentService. * Removed obsolete constructor in ContentTypeEditingService. * Removed obsolete constructor in MediaTypeEditingService. * Removed obsolete constructor in MemberTypeEditingService. * Removed obsolete constructor in ContentTypeService. * Removed obsolete constructors in ContentTypeServiceBase. * Removed obsolete constructors and methods in ContentVersionService. * Removed obsolete constructor in DataTypeUsageService. * Removed obsolete constructor in DomainService. * Removed obsolete constructor in FileService. * Removes obsolete AttemptMove from IContentService. * Removes obsolete SetPreventCleanup from IContentVersionService. * Removes obsolete GetReferences from IDataTypeService. * Removed obsolete SetConsentLevel from IMetricsConsentService. * Removed obsolete methods from IPackageDataInstallation. * Removed obsolete methods from IPackagingService. * Removed obsolete methods on ITwoFactorLoginService. Removed obsolete ITemporaryMediaService. * Removed obsolete constructor from MediaService, MemberTypeService and MediaTypeService. * More obsolete constructors. * Removed obsoleted overloads on IPropertyValidationService. * Fixed build for tests. * Removed obsolete constructor for PublicAccessService, UserService and RelationService. * Removed GetDefaultMemberType. * Removed obsolete user group functionality from IUserService. * Removed obsolete extension methods on IUserService. * Removed obsolete method from ITelemetryService. * Removed obsolete UdiParserServiceConnectors. * Removed obsolete method on ICookieManager. * Removed obsolete DynamicContext. * Removed obsolete XmlHelper. * Fixed failing integration tests. * Removed obsoletes in Umbraco.Cms.Api.Common * Removed obsoletes in Umbraco.Cms.Api.Delivery * Removed obsoletes in Umbraco.Cms.Api.Management * Removed obsoletes in Umbraco.Examine.Lucene * Removed obsoletes in Umbraco.Infrastructure * Fix failing delivery API contract integration test. * Made integration tests internal. * Removed obsoletes from web projects. * Fix build. * Removed Twitter OEmbed provider * Removed obsolete constructor on PublishedDataType. * Removed obsolete constructors on PublishedCacheBase. * Removed the obsolete PropertyEditorTagsExtensions. * Removed obsoletion properties on configuration response models (#18697) * Removed obsolete methods from server-side models. * Update client-side types and sdk. * Update client-side files. * Removed obsoletion of Utf8ToAsciiConverter.ToAsciiString overload. (#18694) * Removed obsolete method in UserService. (#18710) * Removed obsoleted group alias keys from being publicly available. (#18682) * Removed unneceessary ApiVersion attribute. * Clean-up obsoletions on MemberService (#18703) * Removed obsoleted method on MemberService, added future obsoletion to interface and updated all callers. * Removed obsoletion on member service method that's not obsolete on the interface.
2025-03-21 18:02:31 +01:00
internal sealed class DocumentHybridCacheTests : 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 IDocumentCacheService DocumentCacheService => GetRequiredService<IDocumentCacheService>();
private const string NewName = "New Name";
private const string NewTitle = "New Title";
[Test]
public async Task Can_Get_Draft_Content_By_Id()
{
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(TextpageId, true);
// Assert
AssertTextPage(textPage);
}
[Test]
public async Task Can_Get_Draft_Content_By_Key()
{
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(Textpage.Key.Value, true);
// Assert
AssertTextPage(textPage);
}
[Test]
public async Task Can_Get_Published_Content_By_Id()
{
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId);
// Assert
AssertPublishedTextPage(textPage);
}
[Test]
public async Task Can_Get_Published_Content_By_Key()
{
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value);
// Assert
AssertPublishedTextPage(textPage);
}
[Test]
public async Task Can_Get_Draft_Of_Published_Content_By_Id()
{
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, true);
// Assert
AssertPublishedTextPage(textPage);
Assert.IsFalse(textPage.IsPublished());
}
[TestCase(true)]
[TestCase(false)]
public async Task Can_Get_Unpublished_Content_By_Key(bool preview)
{
// Arrange
var unpublishAttempt = await ContentPublishingService.UnpublishAsync(PublishedTextPage.Key.Value, null, Constants.Security.SuperUserKey);
Assert.IsTrue(unpublishAttempt.Success);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, preview);
// Assert
if (preview)
{
Assert.IsNotNull(textPage);
Assert.IsFalse(textPage.IsPublished());
}
else
{
Assert.IsNull(textPage);
}
}
[TestCase(true)]
[TestCase(false)]
public async Task Can_Get_Unpublished_Content_By_Id(bool preview)
{
// Arrange
var unpublishAttempt = await ContentPublishingService.UnpublishAsync(PublishedTextPage.Key.Value, null, Constants.Security.SuperUserKey);
Assert.IsTrue(unpublishAttempt.Success);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, preview);
// Assert
if (preview)
{
Assert.IsNotNull(textPage);
Assert.IsFalse(textPage.IsPublished());
}
else
{
Assert.IsNull(textPage);
}
}
[Test]
public async Task Can_Get_Draft_Of_Published_Content_By_Key()
{
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, true);
// Assert
AssertPublishedTextPage(textPage);
Assert.IsFalse(textPage.IsPublished());
}
[Test]
public async Task Can_Get_Updated_Draft_Content_By_Id()
{
// Arrange
Textpage.Variants = [new() { Name = NewName }];
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = Textpage.Properties,
Variants = Textpage.Variants,
TemplateKey = Textpage.TemplateKey,
};
await ContentEditingService.UpdateAsync(Textpage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var updatedPage = await PublishedContentHybridCache.GetByIdAsync(TextpageId, true);
// Assert
Assert.AreEqual(NewName, updatedPage.Name);
}
[Test]
public async Task Can_Get_Updated_Draft_Content_By_Key()
{
// Arrange
Textpage.Variants = [new() { Name = NewName }];
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = Textpage.Properties,
Variants = Textpage.Variants,
TemplateKey = Textpage.TemplateKey,
};
await ContentEditingService.UpdateAsync(Textpage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var updatedPage = await PublishedContentHybridCache.GetByIdAsync(Textpage.Key.Value, true);
// Assert
Assert.AreEqual(NewName, updatedPage.Name);
}
[Test]
[TestCase(true, true)]
[TestCase(false, false)]
// BETTER NAMING, CURRENTLY THIS IS TESTING BOTH THE PUBLISHED AND THE DRAFT OF THE PUBLISHED.
public async Task Can_Get_Updated_Draft_Published_Content_By_Id(bool preview, bool result)
{
// Arrange
PublishedTextPage.Variants = [new() { Name = NewName }];
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = PublishedTextPage.Properties,
Variants = PublishedTextPage.Variants,
TemplateKey = PublishedTextPage.TemplateKey,
};
await ContentEditingService.UpdateAsync(PublishedTextPage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, preview);
// Assert
Assert.AreEqual(result, NewName.Equals(textPage.Name));
}
[Test]
[TestCase(true, true)]
[TestCase(false, false)]
// BETTER NAMING, CURRENTLY THIS IS TESTING BOTH THE PUBLISHED AND THE DRAFT OF THE PUBLISHED.
public async Task Can_Get_Updated_Draft_Published_Content_By_Key(bool preview, bool result)
{
// Arrange
PublishedTextPage.Variants = [new() { Name = NewName }];;
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = PublishedTextPage.Properties,
Variants = PublishedTextPage.Variants,
TemplateKey = PublishedTextPage.TemplateKey,
};
await ContentEditingService.UpdateAsync(PublishedTextPage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, preview);
// Assert
Assert.AreEqual(result, NewName.Equals(textPage.Name));
}
[Test]
public async Task Can_Get_Draft_Content_Property_By_Id()
{
// Arrange
var titleValue = Textpage.Properties.First(x => x.Alias == "title").Value;
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(TextpageId, true);
// Assert
Assert.AreEqual(titleValue, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Draft_Content_Property_By_Key()
{
// Arrange
var titleValue = Textpage.Properties.First(x => x.Alias == "title").Value;
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(Textpage.Key.Value, true);
// Assert
Assert.AreEqual(titleValue, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Published_Content_Property_By_Id()
{
// Arrange
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, true);
// Assert
Assert.AreEqual(titleValue, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Published_Content_Property_By_Key()
{
// Arrange
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, true);
// Assert
Assert.AreEqual(titleValue, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Draft_Of_Published_Content_Property_By_Id()
{
// Arrange
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, true);
// Assert
Assert.AreEqual(titleValue, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Draft_Of_Published_Content_Property_By_Key()
{
// Arrange
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, true);
// Assert
Assert.AreEqual(titleValue, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Updated_Draft_Content_Property_By_Id()
{
// Arrange
Textpage.Properties.First(x => x.Alias == "title").Value = NewTitle;
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = Textpage.Properties,
Variants = Textpage.Variants,
TemplateKey = Textpage.TemplateKey,
};
await ContentEditingService.UpdateAsync(Textpage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(TextpageId, true);
// Assert
Assert.AreEqual(NewTitle, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Updated_Draft_Content_Property_By_Key()
{
// Arrange
Textpage.Properties.First(x => x.Alias == "title").Value = NewTitle;
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = Textpage.Properties,
Variants = Textpage.Variants,
TemplateKey = Textpage.TemplateKey,
};
await ContentEditingService.UpdateAsync(Textpage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(Textpage.Key.Value, true);
// Assert
Assert.AreEqual(NewTitle, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Updated_Published_Content_Property_By_Id()
{
// Arrange
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = NewTitle;
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = PublishedTextPage.Properties,
Variants = PublishedTextPage.Variants,
TemplateKey = PublishedTextPage.TemplateKey,
};
await ContentEditingService.UpdateAsync(PublishedTextPage.Key.Value, updateModel, Constants.Security.SuperUserKey);
V17 - Removing obsoleted code from Umbraco.Core (#20009) * 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
2025-08-28 12:09:59 +02:00
await ContentPublishingService.PublishAsync(
PublishedTextPage.Key.Value,
[new CulturePublishScheduleModel { Culture = "*" }],
Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, true);
// Assert
Assert.AreEqual(NewTitle, textPage.Value("title"));
}
[Test]
public async Task Can_Get_Updated_Published_Content_Property_By_Key()
{
// Arrange
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = NewTitle;
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = PublishedTextPage.Properties,
Variants = PublishedTextPage.Variants,
TemplateKey = PublishedTextPage.TemplateKey,
};
await ContentEditingService.UpdateAsync(PublishedTextPage.Key.Value, updateModel, Constants.Security.SuperUserKey);
V17 - Removing obsoleted code from Umbraco.Core (#20009) * 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
2025-08-28 12:09:59 +02:00
await ContentPublishingService.PublishAsync(
PublishedTextPage.Key.Value,
[new CulturePublishScheduleModel { Culture = "*" }],
Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value);
// Assert
Assert.AreEqual(NewTitle, textPage.Value("title"));
}
[Test]
[TestCase(true, "New Title")]
[TestCase(false, "Welcome to our Home page")]
public async Task Can_Get_Updated_Draft_Of_Published_Content_Property_By_Id(bool preview, string titleName)
{
// Arrange
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = NewTitle;
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = PublishedTextPage.Properties,
Variants = PublishedTextPage.Variants,
TemplateKey = PublishedTextPage.TemplateKey,
};
await ContentEditingService.UpdateAsync(PublishedTextPage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, preview);
// Assert
Assert.AreEqual(titleName, textPage.Value("title"));
}
[Test]
[TestCase(true, "New Name")]
[TestCase(false, "Welcome to our Home page")]
public async Task Can_Get_Updated_Draft_Of_Published_Content_Property_By_Key(bool preview, string titleName)
{
// Arrange
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = titleName;
ContentUpdateModel updateModel = new ContentUpdateModel
{
Properties = PublishedTextPage.Properties,
Variants = PublishedTextPage.Variants,
TemplateKey = PublishedTextPage.TemplateKey,
};
await ContentEditingService.UpdateAsync(PublishedTextPage.Key.Value, updateModel, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, true);
// Assert
Assert.AreEqual(titleName, textPage.Value("title"));
}
[Test]
public async Task Can_Not_Get_Deleted_Content_By_Id()
{
// Arrange
var content = await PublishedContentHybridCache.GetByIdAsync(Subpage1Id, true);
Assert.IsNotNull(content);
await ContentEditingService.DeleteAsync(Subpage1.Key.Value, Constants.Security.SuperUserKey);
// Act
var textPagePublishedContent = await PublishedContentHybridCache.GetByIdAsync(Subpage1Id, false);
var textPage = await PublishedContentHybridCache.GetByIdAsync(Subpage1Id, true);
// Assert
Assert.IsNull(textPage);
}
[Test]
public async Task Can_Not_Get_Deleted_Content_By_Key()
{
// Arrange
await PublishedContentHybridCache.GetByIdAsync(Subpage1.Key.Value, true);
var hasContent = await PublishedContentHybridCache.GetByIdAsync(Subpage1Id, true);
Assert.IsNotNull(hasContent);
await ContentEditingService.DeleteAsync(Subpage1.Key.Value, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(Subpage1.Key.Value, true);
// Assert
Assert.IsNull(textPage);
}
[Test]
[TestCase(true)]
[TestCase(false)]
public async Task Can_Not_Get_Deleted_Published_Content_By_Id(bool preview)
{
// Arrange
await ContentEditingService.DeleteAsync(PublishedTextPage.Key.Value, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, preview);
// Assert
Assert.IsNull(textPage);
}
[Test]
[TestCase(true)]
[TestCase(false)]
public async Task Can_Not_Get_Deleted_Published_Content_By_Key(bool preview)
{
// Arrange
await ContentEditingService.DeleteAsync(PublishedTextPage.Key.Value, Constants.Security.SuperUserKey);
// Act
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, preview);
// Assert
Assert.IsNull(textPage);
}
[Test]
public async Task Can_Get_Published_Content_By_Id_After_Previous_Check_Where_Not_Found()
{
// Arrange
var testPageKey = Guid.NewGuid();
// Act & Assert
// - assert we cannot get the content that doesn't yet exist from the cache
var testPage = await PublishedContentHybridCache.GetByIdAsync(testPageKey);
Assert.IsNull(testPage);
testPage = await PublishedContentHybridCache.GetByIdAsync(testPageKey);
Assert.IsNull(testPage);
// - create and publish the content
var testPageContent = ContentEditingBuilder.CreateBasicContent(ContentType.Key, testPageKey);
var createResult = await ContentEditingService.CreateAsync(testPageContent, Constants.Security.SuperUserKey);
Assert.IsTrue(createResult.Success);
var publishResult = await ContentPublishingService.PublishAsync(testPageKey, CultureAndSchedule, Constants.Security.SuperUserKey);
Assert.IsTrue(publishResult.Success);
// - assert we can now get the content from the cache
testPage = await PublishedContentHybridCache.GetByIdAsync(testPageKey);
Assert.IsNotNull(testPage);
}
[Test]
public async Task Can_Get_Published_Content_By_Id_After_Previous_Exists_Check()
{
// Act
var hasContentForTextPageCached = await DocumentCacheService.HasContentByIdAsync(PublishedTextPageId);
Assert.IsTrue(hasContentForTextPageCached);
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId);
// Assert
AssertPublishedTextPage(textPage);
}
[Test]
public async Task Can_Do_Exists_Check_On_Created_Published_Content()
{
var testPageKey = Guid.NewGuid();
var testPageContent = ContentEditingBuilder.CreateBasicContent(ContentType.Key, testPageKey);
var createResult = await ContentEditingService.CreateAsync(testPageContent, Constants.Security.SuperUserKey);
Assert.IsTrue(createResult.Success);
var publishResult = await ContentPublishingService.PublishAsync(testPageKey, CultureAndSchedule, Constants.Security.SuperUserKey);
Assert.IsTrue(publishResult.Success);
var testPage = await PublishedContentHybridCache.GetByIdAsync(testPageKey);
Assert.IsNotNull(testPage);
var hasContentForTextPageCached = await DocumentCacheService.HasContentByIdAsync(testPage.Id);
Assert.IsTrue(hasContentForTextPageCached);
}
private void AssertTextPage(IPublishedContent textPage)
{
Assert.Multiple(() =>
{
Assert.IsNotNull(textPage);
Assert.AreEqual(Textpage.Key, textPage.Key);
Assert.AreEqual(Textpage.ContentTypeKey, textPage.ContentType.Key);
Assert.AreEqual(Textpage.Variants.Single().Name, textPage.Name);
});
AssertProperties(Textpage.Properties, textPage.Properties);
}
private void AssertPublishedTextPage(IPublishedContent textPage)
{
Assert.Multiple(() =>
{
Assert.IsNotNull(textPage);
Assert.AreEqual(PublishedTextPage.Key, textPage.Key);
Assert.AreEqual(PublishedTextPage.ContentTypeKey, textPage.ContentType.Key);
Assert.AreEqual(PublishedTextPage.Variants.Single().Name, textPage.Name);
});
AssertProperties(PublishedTextPage.Properties, textPage.Properties);
}
private void AssertProperties(IEnumerable<PropertyValueModel> propertyCollection, IEnumerable<IPublishedProperty> publishedProperties)
{
foreach (var prop in propertyCollection)
{
AssertProperty(prop, publishedProperties.First(x => x.Alias == prop.Alias));
}
}
private void AssertProperty(PropertyValueModel property, IPublishedProperty publishedProperty)
{
Assert.Multiple(() =>
{
Assert.AreEqual(property.Alias, publishedProperty.Alias);
Assert.AreEqual(property.Value, publishedProperty.GetSourceValue());
});
}
}