Determine urls at save and publish time (#17033)
* Started work on service * temp work * temp commit * Temp commit * Added more routing logic * Fixed tests * Refactor and prepare for isdraft * Work on drafts * Fixed tests * Move to enlistment to ensure caches is only updated on scope complete * Clean up and handle null cultures * Added functionality to the INavigationQueryService to get root keys * Added migration * Fixed issue with navigation * Added migration * Temp commit, move to cache refreshers. * Fixed issues * List urls * fix build * Fixed integration tests * Refactor to create new content finder instead of changing the old * rollback wrong commited line * Clean up, and use docuemnt url service for index * Fixed List endpoin * Do not use Navigation service in methods intended by management api * Fixed examine tests * Make methods virtual * Use domain from published request * Use hybrid cache from new content finder * Eliminate nucache usage * Fixed issue with delivery api and url generation * Fixed linux tests * Added hybrid cache to all integration tests
This commit is contained in:
@@ -21,7 +21,7 @@ using Umbraco.Cms.Persistence.SqlServer;
|
||||
using Umbraco.Cms.Tests.Common.Builders;
|
||||
using Umbraco.Cms.Tests.Integration.DependencyInjection;
|
||||
using Umbraco.Cms.Tests.Integration.Extensions;
|
||||
using Umbraco.Cms.Tests.Integration.TestServerTest;
|
||||
|
||||
using Constants = Umbraco.Cms.Core.Constants;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Testing;
|
||||
@@ -162,6 +162,7 @@ public abstract class UmbracoIntegrationTest : UmbracoIntegrationTestBase
|
||||
.AddExamine()
|
||||
.AddUmbracoSqlServerSupport()
|
||||
.AddUmbracoSqliteSupport()
|
||||
.AddUmbracoHybridCache()
|
||||
.AddTestServices(TestHelper);
|
||||
|
||||
if (TestOptions.Mapper)
|
||||
@@ -171,6 +172,7 @@ public abstract class UmbracoIntegrationTest : UmbracoIntegrationTestBase
|
||||
.AddCoreMappingProfiles();
|
||||
}
|
||||
|
||||
services.RemoveAll(x=>x.ImplementationType == typeof(DocumentUrlServiceInitializer));
|
||||
services.AddSignalR();
|
||||
services.AddMvc();
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace Umbraco.Cms.Tests.Integration.Testing;
|
||||
|
||||
public abstract class UmbracoIntegrationTestWithContent : UmbracoIntegrationTest
|
||||
{
|
||||
protected const string TextpageKey = "B58B3AD4-62C2-4E27-B1BE-837BD7C533E0";
|
||||
protected const string SubPageKey = "07EABF4A-5C62-4662-9F2A-15BBB488BCA5";
|
||||
protected const string SubPage2Key = "0EED78FC-A6A8-4587-AB18-D3AFE212B1C4";
|
||||
protected const string SubPage3Key = "29BBB8CF-E69B-4A21-9363-02ED5B6637C4";
|
||||
protected const string TrashedKey = "EAE9EE57-FFE4-4841-8586-1B636C43A3D4";
|
||||
|
||||
protected IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>();
|
||||
|
||||
protected IFileService FileService => GetRequiredService<IFileService>();
|
||||
@@ -44,26 +50,30 @@ public abstract class UmbracoIntegrationTestWithContent : UmbracoIntegrationTest
|
||||
ContentTypeService.Save(ContentType);
|
||||
|
||||
// Create and Save Content "Homepage" based on "umbTextpage" -> 1053
|
||||
Textpage = ContentBuilder.CreateSimpleContent(ContentType);
|
||||
Textpage.Key = new Guid("B58B3AD4-62C2-4E27-B1BE-837BD7C533E0");
|
||||
Textpage = ContentBuilder.CreateSimpleContent(ContentType, "Textpage");
|
||||
Textpage.Key = new Guid(TextpageKey);
|
||||
ContentService.Save(Textpage, -1);
|
||||
|
||||
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1054
|
||||
Subpage = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 1", Textpage.Id);
|
||||
Subpage.Key = new Guid(SubPageKey);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(Subpage, -1, contentSchedule);
|
||||
|
||||
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1055
|
||||
Subpage2 = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 2", Textpage.Id);
|
||||
Subpage2.Key = new Guid(SubPage2Key);
|
||||
ContentService.Save(Subpage2, -1);
|
||||
|
||||
|
||||
Subpage3 = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 3", Textpage.Id);
|
||||
Subpage3.Key = new Guid(SubPage3Key);
|
||||
ContentService.Save(Subpage3, -1);
|
||||
|
||||
// Create and Save Content "Text Page Deleted" based on "umbTextpage" -> 1056
|
||||
Trashed = ContentBuilder.CreateSimpleContent(ContentType, "Text Page Deleted", -20);
|
||||
Trashed.Trashed = true;
|
||||
Trashed.Key = new Guid(TrashedKey);
|
||||
ContentService.Save(Trashed, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1148,7 +1148,7 @@ public class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
Assert.AreEqual("foo", entity.Name);
|
||||
|
||||
var e = ContentService.GetById(entity.Id);
|
||||
Assert.AreEqual("Home", e.Name);
|
||||
Assert.AreEqual("Textpage", e.Name);
|
||||
|
||||
savingWasCalled = true;
|
||||
};
|
||||
@@ -1165,7 +1165,7 @@ public class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
try
|
||||
{
|
||||
var content = ContentService.GetById(Textpage.Id);
|
||||
Assert.AreEqual("Home", content.Name);
|
||||
Assert.AreEqual("Textpage", content.Name);
|
||||
|
||||
content.Name = "foo";
|
||||
ContentService.Save(content);
|
||||
@@ -2186,7 +2186,7 @@ public class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
{
|
||||
// Arrange
|
||||
var temp = ContentService.GetById(Textpage.Id);
|
||||
Assert.AreEqual("Home", temp.Name);
|
||||
Assert.AreEqual("Textpage", temp.Name);
|
||||
Assert.AreEqual(3, ContentService.CountChildren(temp.Id));
|
||||
|
||||
// Act
|
||||
@@ -2211,7 +2211,7 @@ public class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
{
|
||||
// Arrange
|
||||
var temp = ContentService.GetById(Textpage.Id);
|
||||
Assert.AreEqual("Home", temp.Name);
|
||||
Assert.AreEqual("Textpage", temp.Name);
|
||||
Assert.AreEqual(3, ContentService.CountChildren(temp.Id));
|
||||
|
||||
// Act
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Handlers;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Infrastructure.DependencyInjection;
|
||||
using Umbraco.Cms.Infrastructure.Examine;
|
||||
using Umbraco.Cms.Infrastructure.Examine.DependencyInjection;
|
||||
using Umbraco.Cms.Infrastructure.HostedServices;
|
||||
using Umbraco.Cms.Infrastructure.Search;
|
||||
using Umbraco.Cms.Tests.Common.Attributes;
|
||||
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.Scoping;
|
||||
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
|
||||
|
||||
[TestFixture]
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Mock)]
|
||||
public class DocumentUrlServiceTest : UmbracoIntegrationTestWithContent
|
||||
{
|
||||
protected IDocumentUrlService DocumentUrlService => GetRequiredService<IDocumentUrlService>();
|
||||
protected ILanguageService LanguageService => GetRequiredService<ILanguageService>();
|
||||
|
||||
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.AddUnique<IServerMessenger, ScopedRepositoryTests.LocalServerMessenger>();
|
||||
builder.AddNotificationHandler<ContentTreeChangeNotification, ContentTreeChangeDistributedCacheNotificationHandler>();
|
||||
|
||||
builder.Services.AddHostedService<DocumentUrlServiceInitializer>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// [Test]
|
||||
// [LongRunning]
|
||||
// public async Task InitAsync()
|
||||
// {
|
||||
// // ContentService.PublishBranch(Textpage, true, []);
|
||||
// //
|
||||
// // for (int i = 3; i < 10; i++)
|
||||
// // {
|
||||
// // var unusedSubPage = ContentBuilder.CreateSimpleContent(ContentType, "Text Page " + i, Textpage.Id);
|
||||
// // unusedSubPage.Key = Guid.NewGuid();
|
||||
// // ContentService.Save(unusedSubPage);
|
||||
// // ContentService.Publish(unusedSubPage, new string[0]);
|
||||
// // }
|
||||
// //
|
||||
// // await DocumentUrlService.InitAsync(CancellationToken.None);
|
||||
//
|
||||
// }
|
||||
|
||||
[Test]
|
||||
public async Task Trashed_documents_do_not_have_a_url_segment()
|
||||
{
|
||||
var isoCode = (await LanguageService.GetDefaultLanguageAsync()).IsoCode;
|
||||
|
||||
var actual = DocumentUrlService.GetUrlSegment(Trashed.Key, isoCode, true);
|
||||
|
||||
Assert.IsNull(actual);
|
||||
}
|
||||
|
||||
//TODO test with the urlsegment property value!
|
||||
|
||||
[Test]
|
||||
public async Task Deleted_documents_do_not_have_a_url_segment__Parent_deleted()
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
|
||||
ContentService.Delete(Textpage);
|
||||
|
||||
var isoCode = (await LanguageService.GetDefaultLanguageAsync()).IsoCode;
|
||||
|
||||
var actual = DocumentUrlService.GetUrlSegment(Subpage2.Key, isoCode, false);
|
||||
|
||||
Assert.IsNull(actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Deleted_documents_do_not_have_a_url_segment()
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
|
||||
ContentService.Delete(Subpage2);
|
||||
|
||||
var isoCode = (await LanguageService.GetDefaultLanguageAsync()).IsoCode;
|
||||
|
||||
var actual = DocumentUrlService.GetUrlSegment(Subpage2.Key, isoCode, false);
|
||||
|
||||
Assert.IsNull(actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("/", "en-US", true, ExpectedResult = TextpageKey)]
|
||||
[TestCase("/text-page-1", "en-US", true, ExpectedResult = SubPageKey)]
|
||||
[TestCase("/text-page-2", "en-US", true, ExpectedResult = SubPage2Key)]
|
||||
[TestCase("/text-page-3", "en-US", true, ExpectedResult = SubPage3Key)]
|
||||
[TestCase("/", "en-US", false, ExpectedResult = TextpageKey)]
|
||||
[TestCase("/text-page-1", "en-US", false, ExpectedResult = SubPageKey)]
|
||||
[TestCase("/text-page-2", "en-US", false, ExpectedResult = SubPage2Key)]
|
||||
[TestCase("/text-page-3", "en-US", false, ExpectedResult = SubPage3Key)]
|
||||
public string? Expected_Routes(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
}
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Published_Route_when_not_published()
|
||||
{
|
||||
Assert.IsNull(DocumentUrlService.GetDocumentKeyByRoute("/text-page-1", "en-US", null, false));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[TestCase("/text-page-1/sub-page-1", "en-US", true, ExpectedResult = "DF49F477-12F2-4E33-8563-91A7CC1DCDBB")]
|
||||
[TestCase("/text-page-1/sub-page-1", "en-US", false, ExpectedResult = "DF49F477-12F2-4E33-8563-91A7CC1DCDBB")]
|
||||
public string? Expected_Routes_with_subpages(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
// Create a subpage
|
||||
var subsubpage = ContentBuilder.CreateSimpleContent(ContentType, "Sub Page 1", Subpage.Id);
|
||||
subsubpage.Key = new Guid("DF49F477-12F2-4E33-8563-91A7CC1DCDBB");
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(subsubpage, -1, contentSchedule);
|
||||
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
}
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("/second-root", "en-US", true, ExpectedResult = "8E21BCD4-02CA-483D-84B0-1FC92702E198")]
|
||||
[TestCase("/second-root", "en-US", false, ExpectedResult = "8E21BCD4-02CA-483D-84B0-1FC92702E198")]
|
||||
public string? Second_root_cannot_hide_url(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
// Create a second root
|
||||
var secondRoot = ContentBuilder.CreateSimpleContent(ContentType, "Second Root", null);
|
||||
secondRoot.Key = new Guid("8E21BCD4-02CA-483D-84B0-1FC92702E198");
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(secondRoot, -1, contentSchedule);
|
||||
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
ContentService.PublishBranch(secondRoot, true, new[] { "*" });
|
||||
}
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("/child-of-second-root", "en-US", true, ExpectedResult = "FF6654FB-BC68-4A65-8C6C-135567F50BD6")]
|
||||
[TestCase("/child-of-second-root", "en-US", false, ExpectedResult = "FF6654FB-BC68-4A65-8C6C-135567F50BD6")]
|
||||
public string? Child_of_second_root_do_not_have_parents_url_as_prefix(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
// Create a second root
|
||||
var secondRoot = ContentBuilder.CreateSimpleContent(ContentType, "Second Root", null);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(secondRoot, -1, contentSchedule);
|
||||
|
||||
// Create a child of second root
|
||||
var childOfSecondRoot = ContentBuilder.CreateSimpleContent(ContentType, "Child of Second Root", secondRoot);
|
||||
childOfSecondRoot.Key = new Guid("FF6654FB-BC68-4A65-8C6C-135567F50BD6");
|
||||
ContentService.Save(childOfSecondRoot, -1, contentSchedule);
|
||||
|
||||
// Publish both the main root and the second root with descendants
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
ContentService.PublishBranch(secondRoot, true, new[] { "*" });
|
||||
}
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Handlers;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Tests.Common.Attributes;
|
||||
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.Scoping;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
|
||||
|
||||
[TestFixture]
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console)]
|
||||
public class DocumentUrlServiceTest_HideTopLevel_False : UmbracoIntegrationTestWithContent
|
||||
{
|
||||
protected IDocumentUrlService DocumentUrlService => GetRequiredService<IDocumentUrlService>();
|
||||
protected ILanguageService LanguageService => GetRequiredService<ILanguageService>();
|
||||
|
||||
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
||||
{
|
||||
builder.Services.Configure<GlobalSettings>(x => x.HideTopLevelNodeFromPath = false);
|
||||
|
||||
builder.Services.AddUnique<IServerMessenger, ScopedRepositoryTests.LocalServerMessenger>();
|
||||
builder.AddNotificationHandler<ContentTreeChangeNotification, ContentTreeChangeDistributedCacheNotificationHandler>();
|
||||
|
||||
builder.Services.AddHostedService<DocumentUrlServiceInitializer>();
|
||||
}
|
||||
[Test]
|
||||
[TestCase("/textpage/", "en-US", true, ExpectedResult = TextpageKey)]
|
||||
[TestCase("/textpage/text-page-1", "en-US", true, ExpectedResult = SubPageKey)]
|
||||
[TestCase("/textpage/text-page-2", "en-US", true, ExpectedResult = SubPage2Key)]
|
||||
[TestCase("/textpage/text-page-3", "en-US", true, ExpectedResult = SubPage3Key)]
|
||||
[TestCase("/textpage/", "en-US", false, ExpectedResult = TextpageKey)]
|
||||
[TestCase("/textpage/text-page-1", "en-US", false, ExpectedResult = SubPageKey)]
|
||||
[TestCase("/textpage/text-page-2", "en-US", false, ExpectedResult = SubPage2Key)]
|
||||
[TestCase("/textpage/text-page-3", "en-US", false, ExpectedResult = SubPage3Key)]
|
||||
public string? Expected_Routes(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
}
|
||||
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("/textpage/text-page-1/sub-page-1", "en-US", true, ExpectedResult = "DF49F477-12F2-4E33-8563-91A7CC1DCDBB")]
|
||||
[TestCase("/textpage/text-page-1/sub-page-1", "en-US", false, ExpectedResult = "DF49F477-12F2-4E33-8563-91A7CC1DCDBB")]
|
||||
public string? Expected_Routes_with_subpages(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
// Create a subpage
|
||||
var subsubpage = ContentBuilder.CreateSimpleContent(ContentType, "Sub Page 1", Subpage.Id);
|
||||
subsubpage.Key = new Guid("DF49F477-12F2-4E33-8563-91A7CC1DCDBB");
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(subsubpage, -1, contentSchedule);
|
||||
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
}
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("/second-root", "en-US", true, ExpectedResult = "8E21BCD4-02CA-483D-84B0-1FC92702E198")]
|
||||
[TestCase("/second-root", "en-US", false, ExpectedResult = "8E21BCD4-02CA-483D-84B0-1FC92702E198")]
|
||||
public string? Second_root_cannot_hide_url(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
// Create a second root
|
||||
var secondRoot = ContentBuilder.CreateSimpleContent(ContentType, "Second Root", null);
|
||||
secondRoot.Key = new Guid("8E21BCD4-02CA-483D-84B0-1FC92702E198");
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(secondRoot, -1, contentSchedule);
|
||||
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
ContentService.PublishBranch(secondRoot, true, new[] { "*" });
|
||||
}
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("/second-root/child-of-second-root", "en-US", true, ExpectedResult = "FF6654FB-BC68-4A65-8C6C-135567F50BD6")]
|
||||
[TestCase("/second-root/child-of-second-root", "en-US", false, ExpectedResult = "FF6654FB-BC68-4A65-8C6C-135567F50BD6")]
|
||||
public string? Child_of_second_root_do_not_have_parents_url_as_prefix(string route, string isoCode, bool loadDraft)
|
||||
{
|
||||
// Create a second root
|
||||
var secondRoot = ContentBuilder.CreateSimpleContent(ContentType, "Second Root", null);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(secondRoot, -1, contentSchedule);
|
||||
|
||||
// Create a child of second root
|
||||
var childOfSecondRoot = ContentBuilder.CreateSimpleContent(ContentType, "Child of Second Root", secondRoot);
|
||||
childOfSecondRoot.Key = new Guid("FF6654FB-BC68-4A65-8C6C-135567F50BD6");
|
||||
ContentService.Save(childOfSecondRoot, -1, contentSchedule);
|
||||
|
||||
// Publish both the main root and the second root with descendants
|
||||
if (loadDraft is false)
|
||||
{
|
||||
ContentService.PublishBranch(Textpage, true, new[] { "*" });
|
||||
ContentService.PublishBranch(secondRoot, true, new[] { "*" });
|
||||
}
|
||||
|
||||
return DocumentUrlService.GetDocumentKeyByRoute(route, isoCode, null, loadDraft)?.ToString()?.ToUpper();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ using Umbraco.Cms.Infrastructure.Search;
|
||||
using Umbraco.Cms.Tests.Common.Builders;
|
||||
using Umbraco.Cms.Tests.Common.Builders.Extensions;
|
||||
using Umbraco.Cms.Tests.Common.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping;
|
||||
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
||||
using Umbraco.Cms.Web.Common.Security;
|
||||
|
||||
@@ -64,11 +65,8 @@ public class BackOfficeExamineSearcherTests : ExamineBaseTest
|
||||
|
||||
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
||||
{
|
||||
base.CustomTestSetup(builder);
|
||||
builder.Services.AddUnique<IBackOfficeExamineSearcher, BackOfficeExamineSearcher>();
|
||||
builder.Services.AddUnique<IServerMessenger, ContentEventsTests.LocalServerMessenger>();
|
||||
builder
|
||||
.AddNotificationHandler<ContentTreeChangeNotification,
|
||||
ContentTreeChangeDistributedCacheNotificationHandler>();
|
||||
builder.AddNotificationHandler<ContentCacheRefresherNotification, ContentIndexingNotificationHandler>();
|
||||
builder.AddExamineIndexes();
|
||||
builder.Services.AddHostedService<QueuedHostedService>();
|
||||
|
||||
@@ -5,15 +5,19 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Hosting;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Infrastructure.Examine;
|
||||
using Umbraco.Cms.Infrastructure.Persistence;
|
||||
using Umbraco.Cms.Tests.Integration.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.Examine.Lucene.UmbracoExamine;
|
||||
|
||||
@@ -33,6 +37,16 @@ public abstract class ExamineBaseTest : UmbracoIntegrationTest
|
||||
protected override void ConfigureTestServices(IServiceCollection services)
|
||||
=> services.AddSingleton<IndexInitializer>();
|
||||
|
||||
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
||||
{
|
||||
base.CustomTestSetup(builder);
|
||||
builder.Services.AddUnique<IServerMessenger, ContentEventsTests.LocalServerMessenger>();
|
||||
builder
|
||||
.AddNotificationHandler<ContentTreeChangeNotification,
|
||||
ContentTreeChangeDistributedCacheNotificationHandler>();
|
||||
builder.Services.AddHostedService<DocumentUrlServiceInitializer>();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Used to create and manage a testable index
|
||||
/// </summary>
|
||||
|
||||
@@ -48,6 +48,7 @@ public class ExamineExternalIndexTests : ExamineBaseTest
|
||||
Services.DisposeIfDisposable();
|
||||
}
|
||||
|
||||
|
||||
private IExamineExternalIndexSearcherTest ExamineExternalIndexSearcher =>
|
||||
GetRequiredService<IExamineExternalIndexSearcherTest>();
|
||||
|
||||
@@ -66,11 +67,8 @@ public class ExamineExternalIndexTests : ExamineBaseTest
|
||||
|
||||
protected override void CustomTestSetup(IUmbracoBuilder builder)
|
||||
{
|
||||
base.CustomTestSetup(builder);
|
||||
builder.Services.AddUnique<IExamineExternalIndexSearcherTest, ExamineExternalIndexSearcherTest>();
|
||||
builder.Services.AddUnique<IServerMessenger, ContentEventsTests.LocalServerMessenger>();
|
||||
builder
|
||||
.AddNotificationHandler<ContentTreeChangeNotification,
|
||||
ContentTreeChangeDistributedCacheNotificationHandler>();
|
||||
builder.AddNotificationHandler<ContentCacheRefresherNotification, ContentIndexingNotificationHandler>();
|
||||
builder.AddExamineIndexes();
|
||||
builder.Services.AddHostedService<QueuedHostedService>();
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.ContentEditing;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.Packaging;
|
||||
using Umbraco.Cms.Core.Routing;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Services.OperationStatus;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Cms.Core.Web;
|
||||
using Umbraco.Cms.Tests.Common;
|
||||
using Umbraco.Cms.Tests.Common.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Testing;
|
||||
using Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Scoping;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.Web.BackOffice.UrlAndDomains;
|
||||
|
||||
@@ -69,6 +73,12 @@ public class DomainAndUrlsTests : UmbracoIntegrationTest
|
||||
builder.Services.AddUnique<IVariationContextAccessor>(_variationContextAccessor);
|
||||
builder.AddUmbracoHybridCache();
|
||||
builder.AddNuCache();
|
||||
|
||||
// Ensure cache refreshers runs
|
||||
builder.Services.AddUnique<IServerMessenger, ScopedRepositoryTests.LocalServerMessenger>();
|
||||
builder.AddNotificationHandler<ContentTreeChangeNotification, ContentTreeChangeDistributedCacheNotificationHandler>();
|
||||
builder.AddNotificationHandler<DomainSavedNotification, DomainSavedDistributedCacheNotificationHandler>();
|
||||
|
||||
}
|
||||
|
||||
private readonly TestVariationContextAccessor _variationContextAccessor = new();
|
||||
|
||||
Reference in New Issue
Block a user