From ab9eb28826ddc6a8164b473a7b9de4eefd60ff2d Mon Sep 17 00:00:00 2001 From: yv01p Date: Tue, 23 Dec 2025 20:21:01 +0000 Subject: [PATCH] test(integration): add ContentPublishOperationService integration tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests DI resolution and basic publish/unpublish operations delegated through ContentService to the new service. Part of ContentService refactoring Phase 5. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../ContentServiceRefactoringTests.cs | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs index 5c6599eb16..8044c6dc57 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentServiceRefactoringTests.cs @@ -804,6 +804,90 @@ internal sealed class ContentServiceRefactoringTests : UmbracoIntegrationTestWit #endregion + #region Phase 5 - Publish Operation Tests + + [Test] + public void ContentPublishOperationService_Can_Be_Resolved_From_DI() + { + // Act + var publishOperationService = GetRequiredService(); + + // Assert + Assert.That(publishOperationService, Is.Not.Null); + Assert.That(publishOperationService, Is.InstanceOf()); + } + + [Test] + public async Task Publish_Through_ContentService_Uses_PublishOperationService() + { + // Arrange + var contentService = GetRequiredService(); + var contentTypeService = GetRequiredService(); + + var contentType = new ContentTypeBuilder() + .WithAlias("testPublishPage") + .Build(); + await contentTypeService.SaveAsync(contentType, Constants.Security.SuperUserId); + + var content = contentService.Create("Test Publish Page", Constants.System.Root, contentType.Alias); + contentService.Save(content); + + // Act + var result = contentService.Publish(content, new[] { "*" }); + + // Assert + Assert.That(result.Success, Is.True); + Assert.That(content.Published, Is.True); + } + + [Test] + public async Task Unpublish_Through_ContentService_Uses_PublishOperationService() + { + // Arrange + var contentService = GetRequiredService(); + var contentTypeService = GetRequiredService(); + + var contentType = new ContentTypeBuilder() + .WithAlias("testUnpublishPage") + .Build(); + await contentTypeService.SaveAsync(contentType, Constants.Security.SuperUserId); + + var content = contentService.Create("Test Unpublish Page", Constants.System.Root, contentType.Alias); + contentService.Save(content); + contentService.Publish(content, new[] { "*" }); + + // Act + var result = contentService.Unpublish(content); + + // Assert + Assert.That(result.Success, Is.True); + Assert.That(content.Published, Is.False); + } + + [Test] + public async Task IsPathPublishable_RootContent_ReturnsTrue() + { + // Arrange + var contentService = GetRequiredService(); + var contentTypeService = GetRequiredService(); + + var contentType = new ContentTypeBuilder() + .WithAlias("testPathPage") + .Build(); + await contentTypeService.SaveAsync(contentType, Constants.Security.SuperUserId); + + var content = contentService.Create("Test Path Page", Constants.System.Root, contentType.Alias); + contentService.Save(content); + + // Act + var result = contentService.IsPathPublishable(content); + + // Assert + Assert.That(result, Is.True); + } + + #endregion + /// /// Notification handler that tracks the order of notifications for test verification. ///