2019-04-15 17:14:45 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Umbraco.Core;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
using Umbraco.Core.Models.PublishedContent;
|
|
|
|
|
|
using Umbraco.Core.PropertyEditors;
|
|
|
|
|
|
using Umbraco.Core.PropertyEditors.ValueConverters;
|
|
|
|
|
|
using Umbraco.Tests.TestHelpers;
|
|
|
|
|
|
using Moq;
|
2018-07-20 16:39:39 +02:00
|
|
|
|
using Umbraco.Core.Composing;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
using Umbraco.Core.Logging;
|
|
|
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
using Umbraco.Web.PropertyEditors;
|
2019-09-10 11:47:52 +01:00
|
|
|
|
using Umbraco.Core.Services;
|
2019-09-12 09:40:21 +01:00
|
|
|
|
using Umbraco.Web;
|
2019-10-21 23:53:14 +11:00
|
|
|
|
using Umbraco.Web.Templates;
|
2020-02-07 15:01:03 -08:00
|
|
|
|
using Umbraco.Web.Models;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Tests.PublishedContent
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Abstract base class for tests for published content and published media
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class PublishedContentTestBase : BaseWebTest
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override void Compose()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Compose();
|
|
|
|
|
|
|
2019-01-27 01:17:32 -05:00
|
|
|
|
// FIXME: what about the if (PropertyValueConvertersResolver.HasCurrent == false) ??
|
2018-06-29 19:52:40 +02:00
|
|
|
|
// can we risk double - registering and then, what happens?
|
|
|
|
|
|
|
2018-11-28 17:35:12 +01:00
|
|
|
|
Composition.WithCollectionBuilder<PropertyValueConverterCollectionBuilder>()
|
2018-11-26 16:54:32 +01:00
|
|
|
|
.Clear()
|
2018-06-29 19:52:40 +02:00
|
|
|
|
.Append<DatePickerValueConverter>()
|
|
|
|
|
|
.Append<TinyMceValueConverter>()
|
|
|
|
|
|
.Append<YesNoValueConverter>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
2018-11-28 12:59:40 +01:00
|
|
|
|
var converters = Factory.GetInstance<PropertyValueConverterCollection>();
|
2019-10-23 14:35:43 +11:00
|
|
|
|
var umbracoContextAccessor = Mock.Of<IUmbracoContextAccessor>();
|
2019-10-21 23:53:14 +11:00
|
|
|
|
var logger = Mock.Of<ILogger>();
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
2019-10-23 19:08:03 +11:00
|
|
|
|
var imageSourceParser = new HtmlImageSourceParser(umbracoContextAccessor);
|
|
|
|
|
|
var pastedImages = new RichTextEditorPastedImages(umbracoContextAccessor, logger, Mock.Of<IMediaService>(), Mock.Of<IContentTypeBaseServiceProvider>());
|
2019-10-23 14:55:18 +11:00
|
|
|
|
var localLinkParser = new HtmlLocalLinkParser(umbracoContextAccessor);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
var dataTypeService = new TestObjects.TestDataTypeService(
|
2020-02-07 15:01:03 -08:00
|
|
|
|
new DataType(new RichTextPropertyEditor(logger, umbracoContextAccessor, imageSourceParser, localLinkParser, pastedImages, Mock.Of<IImageUrlGenerator>())) { Id = 1 });
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
|
|
var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of<IPublishedModelFactory>(), converters, dataTypeService);
|
|
|
|
|
|
|
2019-04-15 17:14:45 +02:00
|
|
|
|
IEnumerable<IPublishedPropertyType> CreatePropertyTypes(IPublishedContentType contentType)
|
2018-06-29 19:52:40 +02:00
|
|
|
|
{
|
2019-04-15 17:14:45 +02:00
|
|
|
|
yield return publishedContentTypeFactory.CreatePropertyType(contentType, "content", 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var type = new AutoPublishedContentType(0, "anything", CreatePropertyTypes);
|
2018-06-29 19:52:40 +02:00
|
|
|
|
ContentTypesCache.GetPublishedContentTypeByAlias = alias => type;
|
|
|
|
|
|
|
|
|
|
|
|
var umbracoContext = GetUmbracoContext("/test");
|
|
|
|
|
|
Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|