UnknownContentHandler can be configued to handle models that belong to extensions that have been undeployed: $wgContentHandlers['xyzzy'] = 'UnknownContentHandler'; This way, no errors will be thrown when trying to access pages with the unsupported model. Instead, an error message is shown, and editing is prevented. This patch also improves handling of non-editable content in EditPage and in DifferenceEngine. Bug: T220608 Change-Id: Ia94521b786c0a5225a674e4dc3cb6761a723d75b
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @covers UnsupportedSlotDiffRenderer
|
|
*/
|
|
class UnsupportedSlotDiffRendererTest extends MediaWikiTestCase {
|
|
|
|
public function provideDiff() {
|
|
$oldContent = new TextContent( 'Kittens' );
|
|
$newContent = new TextContent( 'Goats' );
|
|
$badContent = new UnknownContent( 'Dragons', 'xyzzy' );
|
|
|
|
yield [ '(unsupported-content-diff)', $oldContent, null ];
|
|
yield [ '(unsupported-content-diff)', null, $newContent ];
|
|
yield [ '(unsupported-content-diff)', $oldContent, $newContent ];
|
|
yield [ '(unsupported-content-diff2)', $badContent, $newContent ];
|
|
yield [ '(unsupported-content-diff2)', $oldContent, $badContent ];
|
|
yield [ '(unsupported-content-diff)', null, $badContent ];
|
|
yield [ '(unsupported-content-diff)', $badContent, null ];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideDiff
|
|
*/
|
|
public function testDiff( $expected, $oldContent, $newContent ) {
|
|
$this->mergeMwGlobalArrayValue(
|
|
'wgContentHandlers',
|
|
[ 'xyzzy' => 'UnknownContentHandler' ]
|
|
);
|
|
|
|
$localizer = $this->getMock( MessageLocalizer::class );
|
|
|
|
$localizer->method( 'msg' )
|
|
->willReturnCallback( function ( $key, ...$params ) {
|
|
return new RawMessage( "($key)", $params );
|
|
} );
|
|
|
|
$sdr = new UnsupportedSlotDiffRenderer( $localizer );
|
|
$this->assertContains( $expected, $sdr->getDiff( $oldContent, $newContent ) );
|
|
}
|
|
|
|
}
|