diff options
Diffstat (limited to 'tests/phpunit')
21 files changed, 241 insertions, 42 deletions
diff --git a/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheExpiry.json b/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheExpiry.json index 9df33193f309..1f10ad3613f8 100644 --- a/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheExpiry.json +++ b/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheExpiry.json @@ -1 +1 @@ -{"_type_":"CacheTime","UsedOptions":null,"CacheExpiry":10,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"UsedOptions":null,"CacheExpiry":10,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheRevisionId.json b/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheRevisionId.json index 74c08ba650d2..35e560eb569d 100644 --- a/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheRevisionId.json +++ b/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheRevisionId.json @@ -1 +1 @@ -{"_type_":"CacheTime","UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":1234,"Version":"1.6.4"}
\ No newline at end of file +{"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":1234,"Version":"1.6.4","_type_":"CacheTime"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheTime.json b/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheTime.json index 0dd3ae76f3e6..7703169c9c95 100644 --- a/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheTime.json +++ b/tests/phpunit/data/ParserCache/1.36-CacheTime-cacheTime.json @@ -1 +1 @@ -{"_type_":"CacheTime","UsedOptions":null,"CacheExpiry":null,"CacheTime":"20010419042521","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"UsedOptions":null,"CacheExpiry":null,"CacheTime":"20010419042521","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-CacheTime-empty.json b/tests/phpunit/data/ParserCache/1.36-CacheTime-empty.json index a5b4f5e3f2ca..b762bdd09ae1 100644 --- a/tests/phpunit/data/ParserCache/1.36-CacheTime-empty.json +++ b/tests/phpunit/data/ParserCache/1.36-CacheTime-empty.json @@ -1 +1 @@ -{"_type_":"CacheTime","UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-CacheTime-usedOptions.json b/tests/phpunit/data/ParserCache/1.36-CacheTime-usedOptions.json index 54484b948f69..67780aa147a6 100644 --- a/tests/phpunit/data/ParserCache/1.36-CacheTime-usedOptions.json +++ b/tests/phpunit/data/ParserCache/1.36-CacheTime-usedOptions.json @@ -1 +1 @@ -{"_type_":"CacheTime","UsedOptions":["optA","optX"],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"UsedOptions":["optA","optX"],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"CacheTime"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-binaryPageProperties.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-binaryPageProperties.json index 829d5ab7fb6b..a1db5a0f8c54 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-binaryPageProperties.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-binaryPageProperties.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":{"empty":"","\\x00":"\u0000","gzip":{"_type_":"string","_encoding_":"base64","_data_":"H4sIAAAAAAAAA8tIzcnJVyjPLycKCQkJLiAnykkBAIURSg0LAAAA"}},"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":{"empty":"","\\x00":"\u0000","gzip":{"_type_":"string","_encoding_":"base64","_data_":"H4sIAAAAAAAAA8tIzcnJVyjPLycKCQkJLiAnykkBAIURSg0LAAAA"}},"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-empty.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-empty.json index 5f0dfc56d8fa..d106af048996 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-empty.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-empty.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-extensionData.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-extensionData.json index 6d16d68a771d..51605f914bf1 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-extensionData.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-extensionData.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":{"boolean":true,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":{"boolean":true,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-pageProperties.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-pageProperties.json index 5eff9598e931..bde0f3cfbba3 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-pageProperties.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-pageProperties.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}},"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-text.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-text.json index a07f2fb32be0..b20f81113cbc 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-text.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-text.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"Lorem Ipsum","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"Lorem Ipsum","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-usedOptions.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-usedOptions.json index 5fb742723cea..fbc0476f93bb 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-usedOptions.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-usedOptions.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"Dummy","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":{"optA":true,"optX":true},"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"Dummy","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":{"optA":true,"optX":true},"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadata.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadata.json index 171ffa868d8d..22af27d2caff 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadata.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadata.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"","LanguageLinks":["link1","link2"],"Categories":{"category2":1,"category1":2},"Indicators":{"indicator1":"indicator1_value"},"TitleText":"title_text1","Links":{"0":{"Link1":42},"2":{"Link2":43}},"LinksSpecial":[],"Templates":{"10":{"Template1":42}},"TemplateIds":{"10":{"Template1":4242}},"Images":{"Image1":1},"FileSearchOptions":{"Image1":{"time":"19731129213309","sha1":"test_sha1"}},"ExternalLinks":{"https:\/\/test.org":1},"InterwikiLinks":{"enwiki":{"interwiki1":1,"interwiki2":1}},"NewSection":true,"HideNewSection":true,"NoGallery":false,"HeadItems":{"tag1":"head_item1"},"Modules":["module1"],"ModuleStyles":["module_style1"],"JsConfigVars":{"key1":"value1"},"OutputHooks":[["hook1",{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}}]],"Warnings":{"warning1":1},"Sections":["section1","section2"],"Properties":[],"TOCHTML":"tochtml1","Timestamp":"20010419042521","EnableOOUI":true,"IndexPolicy":"policy1","AccessedOptions":[],"ExtensionData":[],"LimitReportData":{"limit_report_key1":"value1"},"LimitReportJSData":{"limit_report_key1":"value1"},"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":{"test":true},"SpeculativeRevId":42,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"","LanguageLinks":["link1","link2"],"Categories":{"category2":1,"category1":2},"Indicators":{"indicator1":"indicator1_value"},"TitleText":"title_text1","Links":{"0":{"Link1":42},"2":{"Link2":43}},"LinksSpecial":[],"Templates":{"10":{"Template1":42}},"TemplateIds":{"10":{"Template1":4242}},"Images":{"Image1":1},"FileSearchOptions":{"Image1":{"time":"19731129213309","sha1":"test_sha1"}},"ExternalLinks":{"https:\/\/test.org":1},"InterwikiLinks":{"enwiki":{"interwiki1":1,"interwiki2":1}},"NewSection":true,"HideNewSection":true,"NoGallery":false,"HeadItems":{"tag1":"head_item1"},"Modules":["module1"],"ModuleStyles":["module_style1"],"JsConfigVars":{"key1":"value1"},"OutputHooks":[["hook1",{"boolean":true,"null":null,"number":42,"string":"string","array":[1,2,3],"map":{"key":"value"}}]],"Warnings":{"warning1":1},"Sections":["section1","section2"],"Properties":[],"TOCHTML":"tochtml1","Timestamp":"20010419042521","EnableOOUI":true,"IndexPolicy":"policy1","AccessedOptions":[],"ExtensionData":[],"LimitReportData":{"limit_report_key1":"value1"},"LimitReportJSData":{"limit_report_key1":"value1"},"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":{"test":true},"SpeculativeRevId":42,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_31.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_31.json index 456d987a9254..f745c92e24a7 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_31.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_31.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":true,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":4242,"RevisionTimestampUsed":"19731129213309","RevisionUsedSha1Base36":"test_hash","WrapperDivClasses":{"test_wrapper":true},"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":true,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":4242,"RevisionTimestampUsed":"19731129213309","RevisionUsedSha1Base36":"test_hash","WrapperDivClasses":{"test_wrapper":true},"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_34.json b/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_34.json index 3747662e408a..5805e09a902f 100644 --- a/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_34.json +++ b/tests/phpunit/data/ParserCache/1.36-ParserOutput-withMetadataPost1_34.json @@ -1 +1 @@ -{"_type_":"ParserOutput","Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":{"Link3":1},"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":["script1"],"ExtraDefaultSrcs":["default1"],"ExtraStyleSrcs":["style1"],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4"}
\ No newline at end of file +{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":{"Link3":1},"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"OutputHooks":[],"Warnings":[],"Sections":[],"Properties":[],"TOCHTML":"","Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","AccessedOptions":[],"ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":["script1"],"ExtraDefaultSrcs":["default1"],"ExtraStyleSrcs":["style1"],"Flags":[],"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"UsedOptions":null,"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"Version":"1.6.4","_type_":"ParserOutput"}
\ No newline at end of file diff --git a/tests/phpunit/includes/page/ParserOutputAccessTest.php b/tests/phpunit/includes/page/ParserOutputAccessTest.php index cad169151dae..b24cc507ae25 100644 --- a/tests/phpunit/includes/page/ParserOutputAccessTest.php +++ b/tests/phpunit/includes/page/ParserOutputAccessTest.php @@ -1,5 +1,6 @@ <?php +use MediaWiki\Json\JsonUnserializer; use MediaWiki\Page\ParserOutputAccess; use MediaWiki\Revision\MutableRevisionRecord; use MediaWiki\Revision\RevisionRecord; @@ -58,15 +59,15 @@ class ParserOutputAccessTest extends MediaWikiIntegrationTestCase { } private function getParserCache( $bag = null ) { - $hookContainer = $this->getServiceContainer()->getHookContainer(); - $stats = $this->getServiceContainer()->getStatsdDataFactory(); - $logger = new NullLogger(); - - if ( !$bag ) { - $bag = new HashBagOStuff(); - } - - $parserCache = new ParserCache( 'test', $bag, '', $hookContainer, $stats, $logger ); + $parserCache = new ParserCache( + 'test', + $bag ?: new HashBagOStuff(), + '', + $this->getServiceContainer()->getHookContainer(), + new JsonUnserializer(), + $this->getServiceContainer()->getStatsdDataFactory(), + new NullLogger() + ); // TODO: remove this once PoolWorkArticleView has the ParserCache injected $this->setService( 'ParserCache', $parserCache ); diff --git a/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php b/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php index d26f4e0b38f2..01d68f7d2b91 100644 --- a/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php +++ b/tests/phpunit/includes/parser/ParserCacheSerializationTestCases.php @@ -4,6 +4,7 @@ namespace MediaWiki\Tests\Parser; use CacheTime; use JsonSerializable; +use MediaWiki\Json\JsonUnserializer; use MediaWikiIntegrationTestCase; use MWTimestamp; use ParserOutput; @@ -407,12 +408,15 @@ abstract class ParserCacheSerializationTestCases { 'deserializer' => 'unserialize' ] ]; if ( is_subclass_of( $class, JsonSerializable::class ) ) { + $jsonUnserializer = new JsonUnserializer(); $serializationFormats[] = [ 'ext' => 'json', 'serializer' => function ( JsonSerializable $obj ) { return json_encode( $obj->jsonSerialize() ); }, - 'deserializer' => $class . '::newFromJson' + 'deserializer' => function ( $data ) use ( $jsonUnserializer ) { + return $jsonUnserializer->unserialize( $data ); + } ]; } return $serializationFormats; diff --git a/tests/phpunit/includes/parser/ParserCacheTest.php b/tests/phpunit/includes/parser/ParserCacheTest.php index ee0b45d0bc81..2eaea8fd06c6 100644 --- a/tests/phpunit/includes/parser/ParserCacheTest.php +++ b/tests/phpunit/includes/parser/ParserCacheTest.php @@ -7,6 +7,8 @@ use EmptyBagOStuff; use HashBagOStuff; use InvalidArgumentException; use MediaWiki\HookContainer\HookContainer; +use MediaWiki\Json\JsonUnserializer; +use MediaWiki\Tests\Json\JsonUnserializableSuperClass; use MediaWikiIntegrationTestCase; use MWTimestamp; use NullStatsdDataFactory; @@ -80,6 +82,7 @@ class ParserCacheTest extends MediaWikiIntegrationTestCase { $storage ?: new HashBagOStuff(), '19900220000000', $hookContainer ?: $this->createHookContainer( [] ), + new JsonUnserializer(), new NullStatsdDataFactory(), $logger ?: new NullLogger() ); @@ -517,8 +520,10 @@ class ParserCacheTest extends MediaWikiIntegrationTestCase { public function provideCorruptData() { yield 'PHP serialization, bad data' => [ false, 'bla bla' ]; yield 'JSON serialization, bad data' => [ true, 'bla bla' ]; - yield 'JSON serialization, no _type_' => [ true, '{"test":"test"}' ]; - yield 'JSON serialization, wrong _type_' => [ true, '{"_type_":"bla bla"}' ]; + yield 'JSON serialization, no _class_' => [ true, '{"test":"test"}' ]; + yield 'JSON serialization, non-existing _class_' => [ true, '{"_class_":"NonExistentBogusClass"}' ]; + $wrongInstance = new JsonUnserializableSuperClass( 'test' ); + yield 'JSON serialization, wrong class' => [ true, json_encode( $wrongInstance->jsonSerialize() ) ]; } /** diff --git a/tests/phpunit/mocks/json/JsonUnserializableSubClass.php b/tests/phpunit/mocks/json/JsonUnserializableSubClass.php new file mode 100644 index 000000000000..b20b9c95c77c --- /dev/null +++ b/tests/phpunit/mocks/json/JsonUnserializableSubClass.php @@ -0,0 +1,35 @@ +<?php + +namespace MediaWiki\Tests\Json; + +use MediaWiki\Json\JsonUnserializableTrait; +use MediaWiki\Json\JsonUnserializer; + +/** + * Testing class for JsonUnserializer unit tests. + * @package MediaWiki\Tests\Json + */ +class JsonUnserializableSubClass extends JsonUnserializableSuperClass { + use JsonUnserializableTrait; + + private $subClassField; + + public function __construct( string $superClassFieldValue, string $subClassFieldValue ) { + parent::__construct( $superClassFieldValue ); + $this->subClassField = $subClassFieldValue; + } + + public function getSubClassField(): string { + return $this->subClassField; + } + + public static function newFromJsonArray( JsonUnserializer $unserializer, array $json ) { + return new self( $json['super_class_field'], $json['sub_class_field'] ); + } + + protected function toJsonArray(): array { + return parent::toJsonArray() + [ + 'sub_class_field' => $this->getSubClassField() + ]; + } +} diff --git a/tests/phpunit/mocks/json/JsonUnserializableSuperClass.php b/tests/phpunit/mocks/json/JsonUnserializableSuperClass.php new file mode 100644 index 000000000000..bb91052b914b --- /dev/null +++ b/tests/phpunit/mocks/json/JsonUnserializableSuperClass.php @@ -0,0 +1,35 @@ +<?php + +namespace MediaWiki\Tests\Json; + +use MediaWiki\Json\JsonUnserializable; +use MediaWiki\Json\JsonUnserializableTrait; +use MediaWiki\Json\JsonUnserializer; + +/** + * Testing class for JsonUnserializer unit tests. + * @package MediaWiki\Tests\Json + */ +class JsonUnserializableSuperClass implements JsonUnserializable { + use JsonUnserializableTrait; + + private $superClassField; + + public function __construct( string $superClassFieldValue ) { + $this->superClassField = $superClassFieldValue; + } + + public function getSuperClassField(): string { + return $this->superClassField; + } + + public static function newFromJsonArray( JsonUnserializer $unserializer, array $json ) { + return new self( $json['super_class_field'] ); + } + + protected function toJsonArray(): array { + return [ + 'super_class_field' => $this->getSuperClassField() + ]; + } +} diff --git a/tests/phpunit/unit/includes/json/FormatJsonTest.php b/tests/phpunit/unit/includes/json/FormatJsonTest.php index ea280897bba1..9aeae1fe9c19 100644 --- a/tests/phpunit/unit/includes/json/FormatJsonTest.php +++ b/tests/phpunit/unit/includes/json/FormatJsonTest.php @@ -1,5 +1,7 @@ <?php +use MediaWiki\Tests\Json\JsonUnserializableSuperClass; + /** * @covers FormatJson */ @@ -82,21 +84,38 @@ class FormatJsonTest extends MediaWikiUnitTestCase { public function provideValidateSerializable() { $classInstance = new class() { }; + $serializableClass = new class() implements JsonSerializable { + public function jsonSerialize() { + return []; + } + }; - yield 'Number' => [ 1, null ]; - yield 'Null' => [ null, null ]; - yield 'Class' => [ $classInstance, '$' ]; - yield 'Empty array' => [ [], null ]; - yield 'Empty stdClass' => [ new stdClass(), null ]; - yield 'Non-empty array' => [ [ 1, 2, 3 ], null ]; - yield 'Non-empty map' => [ [ 'a' => 'b' ], null ]; - yield 'Nested, serializable' => [ [ 'a' => [ 'b' => [ 'c' => 'd' ] ] ], null ]; - yield 'Nested, serializable, with null' => [ [ 'a' => [ 'b' => null ] ], null ]; - yield 'Nested, serializable, with stdClass' => [ [ 'a' => (object)[ 'b' => [ 'c' => 'd' ] ] ], null ]; - yield 'Nested, serializable, with stdClass, with null' => [ [ 'a' => (object)[ 'b' => null ] ], null ]; - yield 'Nested, non-serializable' => [ [ 'a' => [ 'b' => $classInstance ] ], '$.a.b' ]; - yield 'Nested, non-serializable, in array' => [ [ 'a' => [ 1, 2, $classInstance ] ], '$.a.2' ]; - yield 'Nested, non-serializable, in stdClass' => [ [ 'a' => (object)[ 1, 2, $classInstance ] ], '$.a.2' ]; + yield 'Number' => [ 1, true, null ]; + yield 'Null' => [ null, true, null ]; + yield 'Class' => [ $classInstance, false, '$' ]; + yield 'Empty array' => [ [], true, null ]; + yield 'Empty stdClass' => [ new stdClass(), true, null ]; + yield 'Non-empty array' => [ [ 1, 2, 3 ], true, null ]; + yield 'Non-empty map' => [ [ 'a' => 'b' ], true, null ]; + yield 'Nested, serializable' => [ [ 'a' => [ 'b' => [ 'c' => 'd' ] ] ], true, null ]; + yield 'Nested, serializable, with null' => [ [ 'a' => [ 'b' => null ] ], true, null ]; + yield 'Nested, serializable, with stdClass' => [ [ 'a' => (object)[ 'b' => [ 'c' => 'd' ] ] ], true, null ]; + yield 'Nested, serializable, with stdClass, with null' => [ [ 'a' => (object)[ 'b' => null ] ], true, null ]; + yield 'Nested, non-serializable' => [ [ 'a' => [ 'b' => $classInstance ] ], true, '$.a.b' ]; + yield 'Nested, non-serializable, in array' => [ [ 'a' => [ 1, 2, $classInstance ] ], true, '$.a.2' ]; + yield 'Nested, non-serializable, in stdClass' => [ [ 'a' => (object)[ 1, 2, $classInstance ] ], true, '$.a.2' ]; + yield 'JsonUnserializable instance' => [ new JsonUnserializableSuperClass( 'Test' ), true, null ]; + yield 'JsonUnserializable instance, in array' => + [ [ new JsonUnserializableSuperClass( 'Test' ) ], true, null ]; + yield 'JsonUnserializable instance, in stdClass' => + [ (object)[ new JsonUnserializableSuperClass( 'Test' ) ], true, null ]; + yield 'JsonSerializable instance' => [ $serializableClass, false, null ]; + yield 'JsonSerializable instance, in array' => [ [ $serializableClass ], false, null ]; + yield 'JsonSerializable instance, in stdClass' => [ (object)[ $serializableClass ], false, null ]; + yield 'JsonSerializable instance, expect unserialize' => [ $serializableClass, true, '$' ]; + yield 'JsonSerializable instance, in array, expect unserialize' => [ [ $serializableClass ], true, '$.0' ]; + yield 'JsonSerializable instance, in stdClass, expect unserialize' => + [ (object)[ $serializableClass ], true, '$.0' ]; } /** @@ -104,10 +123,11 @@ class FormatJsonTest extends MediaWikiUnitTestCase { * @covers FormatJson::detectNonSerializableData * @covers FormatJson::detectNonSerializableDataInternal * @param $value + * @param bool $expectUnserialize * @param string|null $result */ - public function testValidateSerializable( $value, ?string $result ) { - $this->assertSame( $result, FormatJson::detectNonSerializableData( $value ) ); + public function testValidateSerializable( $value, bool $expectUnserialize, ?string $result ) { + $this->assertSame( $result, FormatJson::detectNonSerializableData( $value, $expectUnserialize ) ); } } diff --git a/tests/phpunit/unit/includes/json/JsonUnserializerTest.php b/tests/phpunit/unit/includes/json/JsonUnserializerTest.php new file mode 100644 index 000000000000..b1932e3ee174 --- /dev/null +++ b/tests/phpunit/unit/includes/json/JsonUnserializerTest.php @@ -0,0 +1,99 @@ +<?php + +namespace MediaWiki\Tests\Json; + +use FormatJson; +use InvalidArgumentException; +use MediaWiki\Json\JsonUnserializer; +use MediaWikiUnitTestCase; +use Title; + +/** + * @covers \MediaWiki\Json\JsonUnserializer + * @covers \MediaWiki\Json\JsonUnserializableTrait + * @package MediaWiki\Tests\Json + */ +class JsonUnserializerTest extends MediaWikiUnitTestCase { + + private function getUnserializer(): JsonUnserializer { + return new JsonUnserializer(); + } + + public function provideInvalidJsonData() { + yield 'Bad string' => [ 'bad string' ]; + yield 'Integer???' => [ 1 ]; + yield 'No unserialization metadata' => [ [ 'test' => 'test' ] ]; + yield 'Unserialization metadata, but class not exist' => [ [ + JsonUnserializer::TYPE_ANNOTATION => 'BadClassNotExist' + ] ]; + yield 'Unserialization metadata, but class is not JsonUnserializable' => [ [ + JsonUnserializer::TYPE_ANNOTATION => Title::class + ] ]; + } + + /** + * @dataProvider provideInvalidJsonData + * @param $jsonData + */ + public function testInvalidJsonData( $jsonData ) { + $this->expectException( InvalidArgumentException::class ); + $this->getUnserializer()->unserialize( $jsonData ); + } + + public function testUnexpectedClassUnserialized() { + $this->expectException( InvalidArgumentException::class ); + $superClassInstance = new JsonUnserializableSuperClass( 'Godzilla' ); + $this->getUnserializer()->unserialize( + $superClassInstance->jsonSerialize(), + JsonUnserializableSubClass::class + ); + } + + public function testExpectedClassUnserialized() { + $subClassInstance = new JsonUnserializableSubClass( 'Godzilla', 'But we are ready!' ); + $this->assertNotNull( $this->getUnserializer()->unserialize( + $subClassInstance->jsonSerialize(), + JsonUnserializableSuperClass::class + ) ); + $this->assertNotNull( $this->getUnserializer()->unserialize( + $subClassInstance->jsonSerialize(), + JsonUnserializableSubClass::class + ) ); + } + + public function testRoundTripSuperClass() { + $superClassInstance = new JsonUnserializableSuperClass( 'Super Value' ); + $json = $superClassInstance->jsonSerialize(); + $superClassUnserialized = $this->getUnserializer()->unserialize( $json ); + $this->assertInstanceOf( JsonUnserializableSuperClass::class, $superClassInstance ); + $this->assertSame( $superClassInstance->getSuperClassField(), $superClassUnserialized->getSuperClassField() ); + } + + public function testRoundTripSuperClassObject() { + $superClassInstance = new JsonUnserializableSuperClass( 'Super Value' ); + $json = (object)$superClassInstance->jsonSerialize(); + $superClassUnserialized = $this->getUnserializer()->unserialize( $json ); + $this->assertInstanceOf( JsonUnserializableSuperClass::class, $superClassInstance ); + $this->assertSame( $superClassInstance->getSuperClassField(), $superClassUnserialized->getSuperClassField() ); + } + + public function testRoundTripSubClass() { + $subClassInstance = new JsonUnserializableSubClass( 'Super Value', 'Sub Value' ); + $json = $subClassInstance->jsonSerialize(); + $superClassUnserialized = $this->getUnserializer()->unserialize( $json ); + $this->assertInstanceOf( JsonUnserializableSubClass::class, $subClassInstance ); + $this->assertSame( $subClassInstance->getSuperClassField(), $superClassUnserialized->getSuperClassField() ); + $this->assertSame( $subClassInstance->getSubClassField(), $superClassUnserialized->getSubClassField() ); + } + + public function testArrayRoundTrip() { + $array = [ + new JsonUnserializableSuperClass( 'Super Value' ), + new JsonUnserializableSubClass( 'Super Value', 'Sub Value' ), + 42 + ]; + $serialized = FormatJson::encode( $array ); + $unserialized = $this->getUnserializer()->unserializeArray( FormatJson::decode( $serialized ) ); + $this->assertArrayEquals( $array, $unserialized ); + } +} |