All tests green

This commit is contained in:
Stephan
2018-04-28 09:55:36 +02:00
parent 923fdf9199
commit 27390afe86
6 changed files with 39 additions and 5 deletions

View File

@@ -20,8 +20,11 @@ namespace Umbraco.Core.Models.PublishedContent
private readonly Lazy<object> _objectValue;
private readonly Lazy<object> _xpathValue;
// RawValueProperty does not (yet?) support variants,
// only manages the current "default" value
public override object GetSourceValue(string culture = ".", string segment = ".")
=> culture == null & segment == null ? _sourceValue : null;
=> culture == "." & segment == "." ? _sourceValue : null;
public override bool HasValue(string culture = ".", string segment = ".")
{
@@ -30,10 +33,10 @@ namespace Umbraco.Core.Models.PublishedContent
}
public override object GetValue(string culture = ".", string segment = ".")
=> culture == null & segment == null ? _objectValue.Value : null;
=> culture == "." & segment == "." ? _objectValue.Value : null;
public override object GetXPathValue(string culture = ".", string segment = ".")
=> culture == null & segment == null ? _xpathValue.Value : null;
=> culture == "." & segment == "." ? _xpathValue.Value : null;
public RawValueProperty(PublishedPropertyType propertyType, IPublishedElement content, object sourceValue, bool isPreviewing = false)
: base(propertyType, PropertyCacheLevel.Unknown) // cache level is ignored

View File

@@ -565,6 +565,14 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
public static event TypedEventHandler<TRepository, ScopedEntityEventArgs> ScopeEntityRemove;
public static event TypedEventHandler<TRepository, ScopedVersionEventArgs> ScopeVersionRemove;
// used by tests to clear events
internal static void ClearScopeEvents()
{
ScopedEntityRefresh = null;
ScopeEntityRemove = null;
ScopeVersionRemove = null;
}
protected void OnUowRefreshedEntity(ScopedEntityEventArgs args)
{
ScopedEntityRefresh.RaiseEvent(args, This);

View File

@@ -22,6 +22,12 @@ namespace Umbraco.Core.Services.Implement
// that one is always immediate (transactional)
public static event TypedEventHandler<TService, ContentTypeChange<TItem>.EventArgs> UowRefreshedEntity;
// used by tests to clear events
internal static void ClearScopeEvents()
{
UowRefreshedEntity = null;
}
// these must be dispatched
public static event TypedEventHandler<TService, SaveEventArgs<TItem>> Saving;
public static event TypedEventHandler<TService, SaveEventArgs<TItem>> Saved;

View File

@@ -21,10 +21,12 @@ using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Scoping;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Stubs;
@@ -386,6 +388,14 @@ namespace Umbraco.Tests.Testing
SettingsForTests.Reset(); // fixme - should it be optional?
Mapper.Reset();
// clear static events
DocumentRepository.ClearScopeEvents();
MediaRepository.ClearScopeEvents();
MemberRepository.ClearScopeEvents();
ContentTypeService.ClearScopeEvents();
MediaTypeService.ClearScopeEvents();
MemberTypeService.ClearScopeEvents();
}
#endregion

View File

@@ -178,9 +178,14 @@ namespace Umbraco.Web.PublishedCache.NuCache
var part = parts[i++];
content = content.Children.FirstOrDefault(x =>
{
// fixme - should use ISystemDefaultCultureAccessor NOT ILocalizationService!
var urlName = x.GetUrlName(_localizationService, culture);
return urlName == part;
});
// fixme - if content has a wildcard domain, switch culture! or, shall we?
// no - do NOT support wildcard domains, it makes no sense
// OTOH support '*/en' as a valid domain
}
return content;
}

View File

@@ -1219,10 +1219,12 @@ namespace Umbraco.Web
/// <param name="culture"></param>
/// <returns></returns>
public static string GetUrlName(this IPublishedContent content, ILocalizationService localizationService, string culture = null)
{
{
// fixme publishedContent could get ISystemDefaultCultureAccessor injected!
if (content.ContentType.Variations.HasFlag(ContentVariation.CultureNeutral))
{
var cultureCode = culture ?? localizationService.GetDefaultLanguageIsoCode();
var cultureCode = culture ?? localizationService.GetDefaultLanguageIsoCode(); // fixme kill.kill.kill
if (cultureCode != null && content.CultureNames.TryGetValue(cultureCode, out var cultureName))
{
return cultureName.UrlName;