2021-10-19 11:29:25 +01:00
|
|
|
// Copyright (c) Umbraco.
|
2020-12-23 11:35:49 +01:00
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
2020-10-27 14:10:19 +01:00
|
|
|
using NUnit.Framework;
|
2021-02-09 10:22:42 +01:00
|
|
|
using Umbraco.Cms.Core.Models;
|
|
|
|
|
using Umbraco.Cms.Core.Services;
|
2021-02-10 14:45:44 +01:00
|
|
|
using Umbraco.Cms.Tests.Common.Builders;
|
2020-10-11 22:31:54 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
namespace Umbraco.Cms.Tests.Integration.Testing;
|
2020-10-11 22:31:54 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public abstract class UmbracoIntegrationTestWithContent : UmbracoIntegrationTest
|
|
|
|
|
{
|
2025-11-11 06:59:25 +01:00
|
|
|
protected const string TextpageContentTypeKey = "1D3A8E6E-2EA9-4CC1-B229-1AEE19821522";
|
|
|
|
|
|
2024-09-27 09:12:19 +02:00
|
|
|
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";
|
|
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected IContentTypeService ContentTypeService => GetRequiredService<IContentTypeService>();
|
2020-10-11 22:31:54 +02:00
|
|
|
|
2025-06-24 13:43:34 +02:00
|
|
|
protected IDataTypeService DataTypeService => GetRequiredService<IDataTypeService>();
|
|
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected IFileService FileService => GetRequiredService<IFileService>();
|
2020-10-11 22:31:54 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected ContentService ContentService => (ContentService)GetRequiredService<IContentService>();
|
2021-01-20 15:53:19 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected Content Trashed { get; private set; }
|
2021-01-20 15:53:19 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected Content Subpage2 { get; private set; }
|
|
|
|
|
protected Content Subpage3 { get; private set; }
|
2020-10-12 19:49:50 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected Content Subpage { get; private set; }
|
2020-10-12 19:49:50 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected Content Textpage { get; private set; }
|
2020-10-12 19:49:50 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
protected ContentType ContentType { get; private set; }
|
2020-10-12 19:49:50 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
[SetUp]
|
2024-10-28 12:10:38 +01:00
|
|
|
public virtual void Setup() => CreateTestData();
|
2020-10-12 19:49:50 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public virtual void CreateTestData()
|
|
|
|
|
{
|
|
|
|
|
// NOTE Maybe not the best way to create/save test data as we are using the services, which are being tested.
|
2023-06-06 13:45:39 +02:00
|
|
|
var template = TemplateBuilder.CreateTextPageTemplate("defaultTemplate");
|
2022-06-21 08:09:38 +02:00
|
|
|
FileService.SaveTemplate(template);
|
|
|
|
|
|
|
|
|
|
// Create and Save ContentType "umbTextpage" -> 1051 (template), 1052 (content type)
|
|
|
|
|
ContentType =
|
|
|
|
|
ContentTypeBuilder.CreateSimpleContentType("umbTextpage", "Textpage", defaultTemplateId: template.Id);
|
2025-11-11 06:59:25 +01:00
|
|
|
ContentType.Key = new Guid(TextpageContentTypeKey);
|
2022-06-21 08:09:38 +02:00
|
|
|
ContentTypeService.Save(ContentType);
|
|
|
|
|
|
|
|
|
|
// Create and Save Content "Homepage" based on "umbTextpage" -> 1053
|
2024-09-27 09:12:19 +02:00
|
|
|
Textpage = ContentBuilder.CreateSimpleContent(ContentType, "Textpage");
|
|
|
|
|
Textpage.Key = new Guid(TextpageKey);
|
2023-08-16 23:37:10 +02:00
|
|
|
ContentService.Save(Textpage, -1);
|
2022-06-21 08:09:38 +02:00
|
|
|
|
|
|
|
|
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1054
|
|
|
|
|
Subpage = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 1", Textpage.Id);
|
2024-09-27 09:12:19 +02:00
|
|
|
Subpage.Key = new Guid(SubPageKey);
|
2025-04-14 14:50:02 +02:00
|
|
|
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.UtcNow.AddMinutes(-5), null);
|
2023-08-16 23:37:10 +02:00
|
|
|
ContentService.Save(Subpage, -1, contentSchedule);
|
2022-06-21 08:09:38 +02:00
|
|
|
|
|
|
|
|
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1055
|
|
|
|
|
Subpage2 = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 2", Textpage.Id);
|
2024-09-27 09:12:19 +02:00
|
|
|
Subpage2.Key = new Guid(SubPage2Key);
|
2023-08-16 23:37:10 +02:00
|
|
|
ContentService.Save(Subpage2, -1);
|
2022-06-21 08:09:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Subpage3 = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 3", Textpage.Id);
|
2024-09-27 09:12:19 +02:00
|
|
|
Subpage3.Key = new Guid(SubPage3Key);
|
2023-08-16 23:37:10 +02:00
|
|
|
ContentService.Save(Subpage3, -1);
|
2022-06-21 08:09:38 +02:00
|
|
|
|
|
|
|
|
// Create and Save Content "Text Page Deleted" based on "umbTextpage" -> 1056
|
|
|
|
|
Trashed = ContentBuilder.CreateSimpleContent(ContentType, "Text Page Deleted", -20);
|
|
|
|
|
Trashed.Trashed = true;
|
2024-09-27 09:12:19 +02:00
|
|
|
Trashed.Key = new Guid(TrashedKey);
|
2023-08-16 23:37:10 +02:00
|
|
|
ContentService.Save(Trashed, -1);
|
2020-10-11 22:31:54 +02:00
|
|
|
}
|
|
|
|
|
}
|