ParserCacheSerializationTestCases: distinguish empty ToC from missing ToC
Add a new test case for the "empty ToC" case, to complement the existing serialization test cases for "missing ToC" and "non-empty ToC". Change-Id: I8e2ff94f871546232cbf099f98bfcce559de76f2 (cherry picked from commit cb2173c57276142adc466f7494016e2faf15b758)
This commit is contained in:
parent
5b7a803a5d
commit
0809cc355f
2 changed files with 15 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
{"Text":"","LanguageLinks":[],"Categories":[],"Indicators":[],"TitleText":"","Links":[],"LinksSpecial":[],"Templates":[],"TemplateIds":[],"Images":[],"FileSearchOptions":[],"ExternalLinks":[],"InterwikiLinks":[],"ExistenceLinks":[],"NewSection":false,"HideNewSection":false,"NoGallery":false,"HeadItems":[],"Modules":[],"ModuleStyles":[],"JsConfigVars":[],"Warnings":[],"WarningMsgs":[],"Sections":[],"Properties":[],"Timestamp":null,"EnableOOUI":false,"IndexPolicy":"","ExtensionData":[],"LimitReportData":[],"LimitReportJSData":[],"CacheMessage":"","TimeProfile":[],"ParseStartTime":[],"PreventClickjacking":false,"ExtraScriptSrcs":[],"ExtraDefaultSrcs":[],"ExtraStyleSrcs":[],"Flags":{"mw:toc-set":true},"SpeculativeRevId":null,"SpeculativePageIdUsed":null,"RevisionTimestampUsed":null,"RevisionUsedSha1Base36":null,"WrapperDivClasses":[],"ParseUsedOptions":[],"CacheExpiry":null,"CacheTime":"","CacheRevisionId":null,"TOCExtensionData":[],"_type_":"MediaWiki\\Parser\\ParserOutput","_complex_":true}
|
||||
|
|
@ -332,6 +332,9 @@ abstract class ParserCacheSerializationTestCases {
|
|||
$parserOutputWithMetadataPost1_34->addExtraCSPScriptSrc( 'script1' );
|
||||
$parserOutputWithMetadataPost1_34->addLink( Title::makeTitle( NS_SPECIAL, 'Link3' ) );
|
||||
|
||||
$parserOutputWithEmptyToC = new ParserOutput( '' );
|
||||
$parserOutputWithEmptyToC->setSections( [] );
|
||||
|
||||
MWDebug::clearDeprecationFilters();
|
||||
|
||||
$testCases = [
|
||||
|
|
@ -356,6 +359,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
$testCase->assertArrayEquals( [], $object->getIndicators() );
|
||||
$testCase->assertSame( '', $object->getTitleText() );
|
||||
$testCase->assertArrayEquals( [], $object->getSections() );
|
||||
$testCase->assertNull( $object->getTOCData() );
|
||||
$testCase->assertArrayEquals( [], $object->getLinks() );
|
||||
$testCase->assertArrayEquals( [], $object->getLinksSpecial() );
|
||||
$testCase->assertArrayEquals( [], $object->getTemplates() );
|
||||
|
|
@ -499,6 +503,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
$testCase->assertArrayEquals( [ 'indicator1' => 'indicator1_value' ], $object->getIndicators() );
|
||||
$testCase->assertSame( 'title_text1', $object->getTitleText() );
|
||||
$testCase->assertArrayEquals( self::SECTIONS, $object->getSections() );
|
||||
$testCase->assertNotNull( $object->getTOCData() );
|
||||
$testCase->assertArrayEquals( [
|
||||
NS_MAIN => [ 'Link1' => 42 ],
|
||||
NS_USER => [ 'Link2' => 43 ]
|
||||
|
|
@ -553,6 +558,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
$testCase->assertArrayEquals( [ 'indicator1' => 'indicator1_value' ], $object->getIndicators() );
|
||||
$testCase->assertSame( 'title_text1', $object->getTitleText() );
|
||||
$testCase->assertArrayEquals( self::SECTIONS, $object->getSections() );
|
||||
$testCase->assertNotNull( $object->getTOCData() );
|
||||
$testCase->assertArrayEquals( [
|
||||
NS_MAIN => [ 'Link1' => 42 ],
|
||||
NS_USER => [ 'Link2' => 43 ]
|
||||
|
|
@ -594,6 +600,7 @@ abstract class ParserCacheSerializationTestCases {
|
|||
'instance' => $parserOutputWithSections,
|
||||
'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
$testCase->assertArrayEquals( self::SECTIONS, $object->getSections() );
|
||||
$testCase->assertNotNull( $object->getTOCData() );
|
||||
}
|
||||
],
|
||||
'withMetadataPost1_31' => [
|
||||
|
|
@ -676,6 +683,13 @@ abstract class ParserCacheSerializationTestCases {
|
|||
);
|
||||
}
|
||||
],
|
||||
'withEmptyToC' => [
|
||||
'instance' => $parserOutputWithEmptyToC,
|
||||
'assertions' => static function ( MediaWikiIntegrationTestCase $testCase, ParserOutput $object ) {
|
||||
$testCase->assertArrayEquals( [], $object->getSections() );
|
||||
$testCase->assertNotNull( $object->getTOCData() );
|
||||
},
|
||||
],
|
||||
];
|
||||
// We don't serialize or restore parseStartTime any more, so
|
||||
// ensure that it is cleared in the instances we are going to
|
||||
|
|
|
|||
Loading…
Reference in a new issue