9
9
using Umbraco . Core . Composing ;
10
10
using Umbraco . Core . Configuration ;
11
11
using Umbraco . Core . Models ;
12
+ using Umbraco . Core . Models . ContentEditing ;
12
13
using Umbraco . Core . Models . PublishedContent ;
13
14
using Umbraco . Core . Persistence ;
14
15
using Umbraco . Core . Persistence . Dtos ;
@@ -49,7 +50,7 @@ protected override IPublishedSnapshotService CreatePublishedSnapshotService()
49
50
var runtimeStateMock = new Mock < IRuntimeState > ( ) ;
50
51
runtimeStateMock . Setup ( x => x . Level ) . Returns ( ( ) => RuntimeLevel . Run ) ;
51
52
52
- var contentTypeFactory = Factory . GetInstance < IPublishedContentTypeFactory > ( ) ;
53
+ var contentTypeFactory = Factory . GetInstance < IPublishedContentTypeFactory > ( ) ;
53
54
var documentRepository = Factory . GetInstance < IDocumentRepository > ( ) ;
54
55
var mediaRepository = Mock . Of < IMediaRepository > ( ) ;
55
56
var memberRepository = Mock . Of < IMemberRepository > ( ) ;
@@ -128,8 +129,8 @@ private string GetJson(int id)
128
129
[ TestCase ( ContentVariation . CultureAndSegment , ContentVariation . CultureAndSegment , false ) ]
129
130
public void Change_Content_Type_Variation_Clears_Redirects ( ContentVariation startingContentTypeVariation , ContentVariation changedContentTypeVariation , bool shouldUrlRedirectsBeCleared )
130
131
{
131
- var contentType = MockedContentTypes . CreateBasicContentType ( ) ;
132
- contentType . Variations = startingContentTypeVariation ;
132
+ var contentType = MockedContentTypes . CreateBasicContentType ( ) ;
133
+ contentType . Variations = startingContentTypeVariation ;
133
134
ServiceContext . ContentTypeService . Save ( contentType ) ;
134
135
var contentType2 = MockedContentTypes . CreateBasicContentType ( "test" ) ;
135
136
ServiceContext . ContentTypeService . Save ( contentType2 ) ;
@@ -408,7 +409,7 @@ public void Change_Property_Type_From_Invariant_Variant(ContentVariation invaria
408
409
Assert . AreEqual ( "hello world" , doc . GetValue ( "title" ) ) ;
409
410
Assert . IsTrue ( doc . IsCultureEdited ( "en-US" ) ) ; //invariant prop changes show up on default lang
410
411
Assert . IsTrue ( doc . Edited ) ;
411
-
412
+
412
413
//change the property type to be variant
413
414
contentType . PropertyTypes . First ( ) . Variations = variant ;
414
415
ServiceContext . ContentTypeService . Save ( contentType ) ;
@@ -436,7 +437,7 @@ public void Change_Property_Type_From_Variant_Invariant(ContentVariation variant
436
437
{
437
438
//create content type with a property type that varies by culture
438
439
var contentType = MockedContentTypes . CreateBasicContentType ( ) ;
439
- // content type supports all variations
440
+ // content type supports all variations
440
441
contentType . Variations = ContentVariation . Culture | ContentVariation . Segment ;
441
442
var properties = CreatePropertyCollection ( ( "title" , variant ) ) ;
442
443
contentType . PropertyGroups . Add ( new PropertyGroup ( properties ) { Name = "Content" } ) ;
@@ -473,7 +474,7 @@ public void Change_Property_Type_From_Variant_Invariant_On_A_Composition(Content
473
474
{
474
475
//create content type with a property type that varies by culture
475
476
var contentType = MockedContentTypes . CreateBasicContentType ( ) ;
476
- // content type supports all variations
477
+ // content type supports all variations
477
478
contentType . Variations = ContentVariation . Culture | ContentVariation . Segment ;
478
479
var properties = CreatePropertyCollection ( ( "title" , variant ) ) ;
479
480
contentType . PropertyGroups . Add ( new PropertyGroup ( properties ) { Name = "Content" } ) ;
@@ -880,14 +881,14 @@ public void Change_Property_Variations_From_Variant_To_Invariant_And_Ensure_Edit
880
881
// switch property type to Invariant
881
882
contentType . PropertyTypes . First ( x => x . Alias == "value1" ) . Variations = invariant ;
882
883
ServiceContext . ContentTypeService . Save ( contentType ) ; //This is going to have to re-normalize the "Edited" flag
883
-
884
+
884
885
document = ServiceContext . ContentService . GetById ( document . Id ) ;
885
886
Assert . IsTrue ( document . IsCultureEdited ( "en" ) ) ; //This will remain true because there is now a pending change for the invariant property data which is flagged under the default lang
886
887
Assert . IsFalse ( document . IsCultureEdited ( "fr" ) ) ; //This will be false because nothing has changed for this culture and the property no longer reflects variant changes
887
888
Assert . IsTrue ( document . Edited ) ;
888
889
889
890
//update the invariant value and publish
890
- document . SetValue ( "value1" , "v1inv" ) ;
891
+ document . SetValue ( "value1" , "v1inv" ) ;
891
892
ServiceContext . ContentService . SaveAndPublish ( document ) ;
892
893
893
894
document = ServiceContext . ContentService . GetById ( document . Id ) ;
@@ -907,7 +908,7 @@ public void Change_Property_Variations_From_Variant_To_Invariant_And_Ensure_Edit
907
908
// switch property back to Culture
908
909
contentType . PropertyTypes . First ( x => x . Alias == "value1" ) . Variations = variant ;
909
910
ServiceContext . ContentTypeService . Save ( contentType ) ;
910
-
911
+
911
912
document = ServiceContext . ContentService . GetById ( document . Id ) ;
912
913
Assert . AreEqual ( "v1inv" , document . GetValue ( "value1" , "en" ) ) ; //The invariant property value gets copied over to the default language
913
914
Assert . AreEqual ( "v1inv" , document . GetValue ( "value1" , "en" , published : true ) ) ;
@@ -971,17 +972,17 @@ public void Change_Property_Variations_From_Invariant_To_Variant_And_Ensure_Edit
971
972
Assert . AreEqual ( "doc1en" , document . GetCultureName ( "en" ) ) ;
972
973
Assert . AreEqual ( "doc1fr" , document . GetCultureName ( "fr" ) ) ;
973
974
Assert . AreEqual ( "v1en" , document . GetValue ( "value1" ) ) ;
974
- Assert . AreEqual ( "v1en-init" , document . GetValue ( "value1" , published : true ) ) ;
975
+ Assert . AreEqual ( "v1en-init" , document . GetValue ( "value1" , published : true ) ) ;
975
976
Assert . IsTrue ( document . IsCultureEdited ( "en" ) ) ; //This is true because the invariant property reflects changes on the default lang
976
- Assert . IsFalse ( document . IsCultureEdited ( "fr" ) ) ;
977
+ Assert . IsFalse ( document . IsCultureEdited ( "fr" ) ) ;
977
978
Assert . IsTrue ( document . Edited ) ;
978
979
979
980
// switch property type to Culture
980
981
contentType . PropertyTypes . First ( x => x . Alias == "value1" ) . Variations = variant ;
981
982
ServiceContext . ContentTypeService . Save ( contentType ) ; //This is going to have to re-normalize the "Edited" flag
982
983
983
984
document = ServiceContext . ContentService . GetById ( document . Id ) ;
984
- Assert . IsTrue ( document . IsCultureEdited ( "en" ) ) ; //Remains true
985
+ Assert . IsTrue ( document . IsCultureEdited ( "en" ) ) ; //Remains true
985
986
Assert . IsFalse ( document . IsCultureEdited ( "fr" ) ) ; //False because no french property has ever been edited
986
987
Assert . IsTrue ( document . Edited ) ;
987
988
@@ -1011,7 +1012,7 @@ public void Change_Property_Variations_From_Invariant_To_Variant_And_Ensure_Edit
1011
1012
Assert . IsNull ( document . GetValue ( "value1" , "fr" ) ) ; //The values are there but the business logic returns null
1012
1013
Assert . IsNull ( document . GetValue ( "value1" , "fr" , published : true ) ) ; //The values are there but the business logic returns null
1013
1014
Assert . IsFalse ( document . IsCultureEdited ( "en" ) ) ; //The variant published AND edited values are copied over to the invariant
1014
- Assert . IsFalse ( document . IsCultureEdited ( "fr" ) ) ;
1015
+ Assert . IsFalse ( document . IsCultureEdited ( "fr" ) ) ;
1015
1016
Assert . IsFalse ( document . Edited ) ;
1016
1017
1017
1018
}
@@ -1263,7 +1264,8 @@ private void CreateFrenchAndEnglishLangs()
1263
1264
{
1264
1265
Alias = alias ,
1265
1266
Name = alias ,
1266
- Variations = variance
1267
+ Variations = variance ,
1268
+ HistoryCleanup = new HistoryCleanup ( )
1267
1269
} ;
1268
1270
1269
1271
private PropertyTypeCollection CreatePropertyCollection ( params ( string alias , ContentVariation variance ) [ ] props )
0 commit comments